Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File is a RealESRGAN model, it can't be used as a ESRGAN model #2562

Closed
maikelsz opened this issue Oct 14, 2022 · 6 comments
Closed

File is a RealESRGAN model, it can't be used as a ESRGAN model #2562

maikelsz opened this issue Oct 14, 2022 · 6 comments
Labels
bug-report Report of a bug, yet to be confirmed

Comments

@maikelsz
Copy link

maikelsz commented Oct 14, 2022

I have had this problem for a while, but I had not reported it so I started using BSRGAN.
The problem occurs when using any RealESRGAN option. happens equally with 2x and 4x
console:

Error completing request
Arguments: (0, 0, <PIL.Image.Image image mode=RGB size=512x501 at 0x1CD2D186FD0>, None, 1, 1, 1, 2, 512, 512, True, 4, 0, 1) {}
Traceback (most recent call last):
File "F:\stable-diffusion-webui\stable-diffusion-webui\modules\ui.py", line 186, in f
res = list(func(*args, **kwargs))
File "f:\stable-diffusion-webui\stable-diffusion-webui\webui.py", line 64, in f
res = func(*args, **kwargs)
File "F:\stable-diffusion-webui\stable-diffusion-webui\modules\extras.py", line 95, in run_extras
res = upscale(image, extras_upscaler_1, upscaling_resize, resize_mode, upscaling_resize_w, upscaling_resize_h, upscaling_crop)
File "F:\stable-diffusion-webui\stable-diffusion-webui\modules\extras.py", line 85, in upscale
c = upscaler.scaler.upscale(image, resize, upscaler.data_path)
File "F:\stable-diffusion-webui\stable-diffusion-webui\modules\upscaler.py", line 62, in upscale
img = self.do_upscale(img, selected_model)
File "F:\stable-diffusion-webui\stable-diffusion-webui\modules\esrgan_model.py", line 94, in do_upscale
model = self.load_model(selected_model)
File "F:\stable-diffusion-webui\stable-diffusion-webui\modules\esrgan_model.py", line 115, in load_model
pretrained_net = fix_model_layers(crt_model, pretrained_net)
File "F:\stable-diffusion-webui\stable-diffusion-webui\modules\esrgan_model.py", line 22, in fix_model_layers
raise Exception("The file is a RealESRGAN model, it can't be used as a ESRGAN model.")
Exception: The file is a RealESRGAN model, it can't be used as a ESRGAN model.


Windows 10

Firefox

Commit hash: 08b3f7a (but it already happened from several previous)

@maikelsz maikelsz added the bug-report Report of a bug, yet to be confirmed label Oct 14, 2022
@victorca25
Copy link
Contributor

You're trying to use a real-ESRGAN model in the ESRGAN directory. Unless you use: #2067, it will not work, there's a separate directory for real-ESRGAN models.

@kybercore
Copy link
Contributor

You can't use Real ESRGAN models with ESRGAN. Only the models for ESRGAN work.

https://upscale.wiki/wiki/Model_Database

This isn't a bug, you can close the issue.

@victorca25
Copy link
Contributor

You can't use Real ESRGAN models with ESRGAN. Only the models for ESRGAN work.

https://upscale.wiki/wiki/Model_Database

This isn't a bug, you can close the issue.

As mentioned, you can use the real-ESRGAN models with ESRGAN if you use the code in the PR.

@maikelsz
Copy link
Author

maikelsz commented Oct 14, 2022

real-ESRGAN

yeah, I saw #2067.

But, after a lot of work and realizing that the WebUI defines the scalers available at startup from the folders it has in models, I was able to use RealESRGAN and ESRGAN. but..

RealESRGAN_x2plus - OK, works, but softens the image a quite a bit
RealESRGAN_x4plus - does not appear in the interface
RealESRGAN_x4plus_anime_6B - does not appear in the interface
ESRGANx4 - OK, works, has little visible SR effect and softens a bit.
According to what I read, the smoothing problem seems to be an intrinsic defect of the ESRGAN-type models. Perhaps those are more useful for images with less detail and texture (such as anime/cartoons).

The thing was that for some reason, before it was trying to put and get the RealESRGAN models from the ESRGAN folder, or so it seemed.


one more thing...

About ScuNet.
when selecting GAN or PSNR, in both cases the file that is downloaded is renamed the same way, "ScuNet.pth" and overwrites the existing file, regardless of whether the downloaded file is "scunet_color_real_psnr.pth" or "scunet_color_real_gan.pth".

then, if I rename one of these models to ScuNet.pth, only selecting "ScuNet PSNR" on the interface works, if I select "ScuNet GAN", an error occurs:

Traceback (most recent call last):
File "f:\stable-diffusion-webui\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 275, in run_predict
output = await app.blocks.process_api(
File "f:\stable-diffusion-webui\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 782, in process_api
inputs = self.preprocess_data(fn_index, inputs, state)
File "f:\stable-diffusion-webui\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 679, in preprocess_data
processed_input.append(block.preprocess(raw_input[i]))
File "f:\stable-diffusion-webui\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 1091, in preprocess
return self.choices.index(x)
ValueError: 'ScuNET GAN' is not in list

If I leave both models in the folder with their original names, that's how they appear (with their full names) in the interface and both work.


one more...

The model proposed by #2092 does not work for me.

to use SwinSR (SwinSR 4x) I had to download the model "003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth" from https://github.com/JingyunLiang/, and not "Swin2SR_RealworldSR_X4_64_BSRGAN_PSNR.pth" from "https://github.com/mv -lab/swin2sr" as #2092 says.

I did this by seeing what the console says:

Downloading: "https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth " to F:\stable-diffusion-webui\stable-diffusion-webui\models\SwinIR\SwinIR_4x .pth

but it fails me with a long error that is basically a connection failure to the source. I download it separately, and it works, slow, but it's the best result I've seen so far among scaling models used in webui.


one more more...

LDSR wont work. it wont download. the model is in a web that requires an account (heibox.uni-heidelberg.de). so, the console spit an error that ends with:
"urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)>"


can i report these as separated issues?

@C43H66N12O12S2
Copy link
Collaborator

C43H66N12O12S2 commented Oct 15, 2022

SwinIR and SwinIR v2 (what the mv-lab repo contains) are different things. SwinIR v2 needs to have the extension/file type .v2.pth

@maikelsz
Copy link
Author

SwinIR and SwinIR v2 (what the mv-lab repo contains) are different things. SwinIR v2 needs to have the extension/file type .v2.pth

I will report these three last issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report Report of a bug, yet to be confirmed
Projects
None yet
Development

No branches or pull requests

4 participants