English follows Japanese
こんにちはchupiokaです。皆さん、Stable Diffusionで画像生成する際にアップスケールは行っていますでしょうか?現在の多くのモデルは512*512や768*768といった比較的低い解像度の画像でトレーニングを行っているため、最初から1024*1024のような解像度で画像を生成しようとすると高い確率で破綻してしまいます。そのため、512*512の解像度で作成した画像をアップスケーラーで高解像度化するというのが一般的なテクニックとして存在します
私はなるべく楽をしたいエンジニア気質の人間なので、一度作った画像をimg2imgでアップスケールするという方法は面倒なのでやりたくないです。なので今回はtxt2imgで画像の生成とアップスケールを同時にやっちゃう方法について述べていきたいと思います
アップスケールする方法は様々なものがあり、拡張機能であるMultiDiffusionを使う方法、ultimate-upscaleを使う方法、ControlNet Tileを使う方法などがありますが、今回は最も基本である”Hires. fix”でのアップスケールでどこまで良い感じに高解像度の画像が作れるか試してみたいと思います
Hello, this is chupioka. Ladies and gentlemen, do you perform upscaling when generating images with Stable Diffusion? Many current models are trained with relatively low resolution images such as 512*512 and 768*768, so if you try to generate an image with a resolution like 1024*1024 from the beginning, there is a high probability that it will fail. put away. Therefore, a common technique is to use an upscaler to increase the resolution of an image created with a resolution of 512*512.
I’m an engineer who wants to make it as easy as possible, so I don’t want to use img2img to upscale an image once it’s created because it’s troublesome. So this time I would like to describe how to generate and upscale images at the same time with txt2img.
There are various methods of upscaling, such as using the extension MultiDiffusion, ultimate-upscale, and ControlNet Tile. I would like to test how well upscaling can create high-resolution images.
- Hires. fixの設定 – Hires. fix settings
- デフォルト以外のモデルのダウンロード – Downloading non-default models
- 比較結果サマリ – Comparison result summary
- 結論 – Conclusion
- None
- Latent
- Latent (antialiased)
- Latent (bicubic)
- Latent (bicubic antialiased)
- Latent (nearest)
- Latent (nearest-exact)
- Lanczos
- Nearest
- ESRGAN_4x
- LDSR
- R-ESRGAN 4x+
- R-ESRGAN 4x+ Anime6B
- ScuNET
- ScuNET PSNR
- SwinIR_4x
- 4x-UltraSharp
- 4x-UniScale-Balanced [72000g]
- 4x_Faces_04_N_180000_G
- 4x_foolhardy_Remacri
- 4x_RealisticRescaler_100000_G
- 4x_Valar_v1
Hires. fixの設定 – Hires. fix settings
まずは”Hires. fix”の設定を行っていきます。Stable Diffusion WebUIのtxt2imgのタブを開いた後、”Hires. fix”のチェックボックスにチェックを入れます
First, we will set up “Hires. fix”. After opening the txt2img tab of the Stable Diffusion WebUI, check the “Hires. fix” checkbox.
Upscaler: ここでアップスケールに採用するモデルを選択します。モデルによってアップスケールの方向性が違うので非常に大事な設定です。今回の検証ではこのモデルを複数比較してみたいと思います
Hires steps: アップスケールは一度低解像度の画像を作った後にリサイズしていくような処理となり、ここではリサイズにおいての推論のステップ数を決めます。”0″にするとSampling stepsの値と同じステップ数となりますが、あまりリサイズにステップ数を多く設定しても品質に大きな影響は与えないため、私はいつもSampling stepsの半分の値を設定しています
Denoising strength: アップスケール時に修正する強さです。数字が大きいと強力に修正してくれますが元の絵から大きく変化してしまい、数字が小さいと元の絵に忠実になりますが修正が弱くなります。今回は”0.5″を設定しています
Upscale by: 何倍の大きさにアップスケールするかの設定です。2にすると、512*512の画像であれば1024*1024の解像度の画像となります。今回は512*512から1024*1024にアップスケールしています
Upscaler: Select the model to adopt for upscaling here. This is a very important setting because the direction of upscaling differs depending on the model. In this verification, I would like to compare multiple models.
Hires steps: Upscaling is a process that resizes after creating a low-resolution image once, and here you decide the number of inference steps in resizing. If you set it to “0”, the number of steps will be the same as the value of Sampling steps, but setting too many steps for resizing will not greatly affect the quality, so I always set the value to half the value of Sampling steps. increase.
Denoising strength: Strength to modify when upscaling. If the number is large, it will be corrected strongly, but it will change greatly from the original picture, and if the number is small, it will be faithful to the original picture, but the correction will be weak. This time, “0.5” is set.
Upscale by: It is a setting of how many times the size is upscaled. If you set it to 2, a 512*512 image will be a 1024*1024 resolution image. This time it is upscaled from 512*512 to 1024*1024.
デフォルト以外のモデルのダウンロード – Downloading non-default models
デフォルトモデルだけだと面白くないため、他のモデルも比較してみたいと思います。他のアップスケールモデルはこちらからダウンロードできます。かなりの数があるため、今回は実写に適していそうな以下のモデルを試してみたいと思います
モデルの使い方は、”models”フォルダ内の”ESRGAN”フォルダにpthファイルを格納し、その後Stable Diffusion WebUIを再起動すればOKです
It’s not interesting if it’s just the default model, so I’d like to compare other models as well. Other upscale models can be downloaded here. Since there are quite a few, I would like to try the following models that seem to be suitable for live action.
To use the model, store the pth file in the “ESRGAN” folder in the “models” folder, and then restart the Stable Diffusion WebUI.
・Default Models
None
Latent
Latent (antialiased)
Latent (bicubic)
Latent (bicubic antialiased)
Latent (nearest)
Latent (nearest-exact)
Lanczos
Nearest
ESRGAN_4x
LDSR
R-ESRGAN 4x+
R-ESRGAN 4x+ Anime6B
ScuNET
ScuNET PSNR
SwinIR_4x
・Downloaded Models
4x-UltraSharp
4x-UniScale-Balanced [72000g]
4x_Faces_04_N_180000_G
4x_foolhardy_Remacri
4x_RealisticRescaler_100000_G
4x_Valar_v1
比較結果サマリ – Comparison result summary
まず元の画像は512*512の解像度のこちらです
First of all, the original image is here with a resolution of 512*512.
指が写っている、服のしわ、髪の毛、髪のハイライト、手に持っている謎の小物、あたりが描写が難しそうなところでしょうか?それでは比較結果をご覧ください
Fingers, wrinkles on clothes, hair, hair mesh, mysterious accessories in hand, are there any parts that seem difficult to depict? Now let’s look at the comparison results.
結論 – Conclusion
・元絵の再現性と精度のバランスを求める方
LDSR (全体的に優秀だが生成時間が遅い)
4x_RealisticRescaler_100000_G (ボケた背景にも修正が入るため注意)
4x_Valar_v1 (少し陰影が薄くなりますが全体的に優秀)
・多少元絵と変わってもいいからとにかく精度を求める方
R-ESRGAN 4x+
SwinIR_4x
が良いのではないでしょうか?各モデルの簡単な感想については以下をご覧ください
・Those who seek a balance between reproducibility and accuracy of the original picture
LDSR (Excellent overall, but slow generation time)
4x_RealisticRescaler_100000_G (Note that the blurred background will also be corrected)
4x_Valar_v1 (Slightly darker, but excellent overall)
・People who want accuracy even if it is slightly different from the original picture
R-ESRGAN 4x+
SwinIR_4x
Isn’t it better? See below for brief impressions of each model.
None
“None”を指定した場合、画質が荒い状態でアップスケールされます。服の模様が無くなったり表情も変わっていますので、敢えて”None”を選択する理由は無さそうです。ただ意外だったのは、”None”でも元絵をただ大きくするだけではなく、何らかの処理をしているというところですね
If “None” is specified, the image will be upscaled with coarse quality. Since the patterns on her clothes have disappeared and her facial expressions have changed, there doesn’t seem to be any reason to choose “None”. But what surprised me was that “None” didn’t just enlarge the original image, but did some kind of processing.
Latent
“None”よりは精度が高いですが、服のデザインが大幅に変わってしまい、指も変形してしまいました
It’s more accurate than “None”, but the design of the clothes has changed drastically, and the fingers have also been deformed.
Latent (antialiased)
“Latent”との違いが分かりませんでした。アンチエイリアスの処理がされている?
I didn’t understand the difference with “Latent”. Is it anti-aliased?
Latent (bicubic)
服のデザインが大幅に変わっていますが破綻も小さく精度も高めです
The design of the clothes has changed significantly, but the failure is small and the accuracy is high.
Latent (bicubic antialiased)
“Latent (bicubic)”との違いが判別できません
The difference with “Latent (bicubic)” cannot be determined.
Latent (nearest)
髪の毛はなかなかですが、服や小物が大幅に変わってしまっています。あと少し顔がシャープな雰囲気に変わったような気がします
Her hair are fine, but her clothes and accessories have changed significantly. I feel like my face has changed to a sharper atmosphere.
Latent (nearest-exact)
“Latent (nearest)”との違いが判別できませんでした
Couldn’t tell the difference from “Latent (nearest)”.
Lanczos
“None”に近い感じで少しボケた表現になってしまいました
It feels like “None” and the expression is a little blurry.
Nearest
画質が荒くなってしまいました。元絵からの再現度も低いのでイマイチです。髪のハイライトがヘアバンドに変化してしまっています
Image quality has deteriorated. The degree of reproduction from the original picture is also low, so it’s not good. Hair highlights have changed to hair bands.
ESRGAN_4x
精度の高い画像になりましたが服の模様が消えていたり、髪色が再現できていなかったりします
The image is highly accurate, but the patterns on the clothes have disappeared, and the hair color has not been reproduced.
LDSR
服の模様や髪色などの再現度が良かったです。ただ他のモデルに比べて処理に時間がかかりました
The reproducibility of the clothing pattern and hair color was good. However, it took longer to process than other models.
R-ESRGAN 4x+
少し指が破綻してしまいましたが全体的に完成度が高いです。元の絵を再現するというよりは、高精細な新しい絵を作ったという感じですね
A little finger broke, but overall the degree of completion is high. Rather than reproducing the original picture, it feels like creating a new high-definition picture.
R-ESRGAN 4x+ Anime6B
こちらも完成度は高めです。発色が良くなるので確かにアニメなどの絵には合いそうです
It is also highly complete. The color development is improved, so it certainly seems to be suitable for drawings such as animation.
ScuNET
全体的にピンぼけな感じになってしまいました。アップスケールには向いていないです
I felt totally out of focus. Not suitable for upscaling.
ScuNET PSNR
こちらも”ScuNET”同様にピンぼけな感じになってしまいました
Like “ScuNET”, this one also feels out of focus.
SwinIR_4x
“R-ESRGAN 4x+”と近い感じで高精細な絵となります。こちらも新しく絵を描きなおしましたという感じで、元絵をそこまで再現するわけではなさそうです
High-definition images are similar to those of “R-ESRGAN 4x+”. This is also a new drawing, so it doesn’t seem like the original picture will be recreated that much.
4x-UltraSharp
服の柄など元絵の再現性が高く良さそうです。少し指が破綻してしまった点は気になりますが
The reproducibility of the original picture such as the pattern of the clothes is high and it seems to be good. I’m a little concerned about the broken finger.
4x-UniScale-Balanced [72000g]
ややピンボケな感じに。元絵の再現性もそこまで高くは無くイマイチです
Feeling a little out of focus. The reproducibility of the original picture is not so high and it is not good.
4x_Faces_04_N_180000_G
割と破綻も少なくアップスケーラーとしては優秀です。ただ確かに顔は良いのですが、少し指先などが怪しい表現になってしまっています
It is excellent as an upscaler with relatively few bankruptcies. Although he does have a nice face, his fingertips have a slightly suspicious expression.
4x_foolhardy_Remacri
身体部分が少しボケた感じになってしまっています
The body part has become a little blurry.
4x_RealisticRescaler_100000_G
元絵の再現性が結構高く、全体的に高精細になりオススメです。少し気になったのは、背景にあるライトやソファのボケ感が薄まった点で、敢えて背景をボカしている場合には注意が必要だと感じました
The reproducibility of the original picture is quite high, and the overall high definition is highly recommended. One thing that bothered me a little was that the background lights and the blurring of the sofa had faded.
4x_Valar_v1
全体的に淡い色味に。ただ元絵の再現性は高く、精度も高いので悪くないです
Light color overall. However, the reproducibility of the original picture is high, and the accuracy is also high, so it’s not bad.
AI画像生成を楽しむにはGPUを備えたPCが不可欠です!
価格も落ち着いてきたので、この機会にGPUマシンの検討をオススメします。
コメント
非常に参考になり助かりました。