Tok / sd-forge-deforum

Fluxabled fork of the Deforum extension for Stable Dissusion WebUI Forge with keyframe redistribution logic.
Other
29 stars 1 forks source link

[Bug]: Version conflict: basicsr vs torchvision #1

Closed asdrabael closed 1 month ago

asdrabael commented 1 month ago

I followed all the directions. I have cuda 12.1, I followed the install directions for forge, and then followed the install directions here. I tried both versions of basicsr, i disabled free-u and kohya. I just get this error:

** Error loading script: deforum.py Traceback (most recent call last): File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/modules/scripts.py", line 525, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/modules/script_loading.py", line 13, in load_module module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/extensions/sd-forge-deforum/scripts/deforum.py", line 41, in init_deforum() File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/extensions/sd-forge-deforum/scripts/deforum.py", line 33, in init_deforum from deforum_helpers.ui_right import on_ui_tabs File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/extensions/sd-forge-deforum/scripts/deforum_helpers/ui_right.py", line 17, in from .args import DeforumOutputArgs, get_component_names, get_settings_component_names File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/extensions/sd-forge-deforum/scripts/deforum_helpers/args.py", line 27, in from .deforum_controlnet import controlnet_component_names File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/extensions/sd-forge-deforum/scripts/deforum_helpers/deforum_controlnet.py", line 29, in from .general_utils import count_files_in_folder, clean_gradio_path_strings # TODO: do it another way File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/extensions/sd-forge-deforum/scripts/deforum_helpers/general_utils.py", line 21, in from basicsr.utils.download_util import load_file_from_url File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/venv/lib/python3.10/site-packages/basicsr/init.py", line 4, in from .data import File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/venv/lib/python3.10/site-packages/basicsr/data/init.py", line 22, in _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/venv/lib/python3.10/site-packages/basicsr/data/init.py", line 22, in _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] File "/home/asdra/miniconda3/envs/forge/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/venv/lib/python3.10/site-packages/basicsr/data/realesrgan_dataset.py", line 11, in from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels File "/home/asdra/Desktop/forge/stable-diffusion-webui-forge2/venv/lib/python3.10/site-packages/basicsr/data/degradations.py", line 8, in from torchvision.transforms.functional_tensor import rgb_to_grayscale ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'

No deforum tab shows up. My forge normal functions still works. I can gen pictures and all, but the deforum itself doesn't work. This error message is with 1.4.2 but i get identical with 1.3.5

Tok commented 1 month ago

Hi @asdrabael Thanks for reporting the error. It appears to be an issue with a version conflict between 'basicsr' and torchvision.

Reason: Both versions of "basicsr" are importing a method (rgb_to_grayscale) from torchvision, but the method was relocated between different versions of torchvision, which is causing problems now with some setups. In one version, the method is available at: torchvision.transforms.functional_tensor In the other version at: torchvision.transforms.functional

Here's a workaround that should work:

Here's a thread with discussions and solutions about the same problem at A1111s GitHub: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13985#issuecomment-1813885266

While modifying lines directly in the venv is somewhat ugly, it should work fine for the specific purpose of this workaround.

The Deforum extension is currently not using BasicSR for actually doing super resolution, but just because it provides a neat method to download some required files for other purposes from the Pytorch hub. I'll see if I can replace it with something else that is less error prone in the future.

asdrabael commented 1 month ago

Thanks very much, that fixed it. It's working now with no issues. You're a superstar!

Tok commented 1 month ago

Permanently solved by removing the basicsr dependency and instead using a method from torch.hub, which is provided by Forge. Commit: https://github.com/Tok/sd-forge-deforum/commit/0acd7910d0ffcbd4a30ce7eb82d44a77ff46b06e