camenduru / stable-diffusion-webui-colab

stable diffusion webui colab
The Unlicense
15.64k stars 2.61k forks source link

[Bug]: controlnet #485

Open armpitranger opened 11 months ago

armpitranger commented 11 months ago

What happened?

Ordinary image generation works fine, but using controlnet (tile_resample) results in distorted images due to errors

Colab cell output

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gradio/routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet_ui/controlnet_ui_group.py", line 614, in filter_selected
    ) = global_state.select_control_type(k, global_state.get_sd_version())
  File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/global_state.py", line 249, in get_sd_version
    if shared.sd_model.is_sdxl:
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1614, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'LatentDiffusion' object has no attribute 'is_sdxl'
*** Error running process: /content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py
    Traceback (most recent call last):
      File "/content/stable-diffusion-webui/modules/scripts.py", line 474, in process
        script.process(p, *script_args)
      File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 993, in process
        self.controlnet_hack(p)
      File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 982, in controlnet_hack
        self.controlnet_main_entry(p)
      File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 692, in controlnet_main_entry
        Script.check_sd_version_compatible(unit)
      File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/controlnet.py", line 640, in check_sd_version_compatible
        sd_version = global_state.get_sd_version()
      File "/content/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/global_state.py", line 249, in get_sd_version
        if shared.sd_model.is_sdxl:
      File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1614, in __getattr__
        raise AttributeError("'{}' object has no attribute '{}'".format(
    AttributeError: 'LatentDiffusion' object has no attribute 'is_sdxl'

Which colab and model(s) were you using when the error occurred?

https://colab.research.google.com/github/camenduru/stable-diffusion-webui-colab/blob/main/stable/edgeorealism_pink_hare_webui_colab.ipynb 〇 I personally added !pip install httpx==0.24.1 because it wasn't working properly

Which Public WebUI Colab URL were you using when the error occurred?

gradio.live

If you used HiRes mode when the error occurred, please provide the Hires info

No response

ManHinnn0509 commented 11 months ago

Having the same error too, I was using the drive branch one.

Installed with install.ipynb and ran it with run.ipynb

Also added the line !pip install httpx==0.24.1 because it won't work without installing this version

Anyone know how to fix this?

Thanks!

fireincairo00 commented 11 months ago

same here, maybe the latest controlnet version uses a model only compatible with SDXL, like one can guess from the error message. For me it's using inpaint of controlnet under tab txt2img. The result is just nonsense and I got similar error complaining AttributeError: 'LatentDiffusion' object has no attribute 'is_sdxl'

ManHinnn0509 commented 11 months ago

I run sd-webui on both local PC and colab too, I checked the ControlNet's version and both of them are the same. I used the same model (control_v1p_sd15_qrcode_monster) and the error message is only showing on colab side and never on the local side.

Anyone know what's the cause & solution to this error? I bought colab pro and I want to solve this error message ASAP :<

fireincairo00 commented 11 months ago

Hi hope this help: I tried the nightly build and it seems to be working without this bug

easyspace commented 11 months ago

Yup, same here. Controlnet not working on the stable builds.

ManHinnn0509 commented 11 months ago

EDIT: Added this line and fixed the error: !pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118 -U

Also tried nightly build but I couldn't launch the program, it gives me this error:

Traceback (most recent call last):
  File "/content/drive/MyDrive/stable-diffusion-webui-colab/nightly/stable-diffusion-webui/launch.py", line 48, in <module>
    main()
  File "/content/drive/MyDrive/stable-diffusion-webui-colab/nightly/stable-diffusion-webui/launch.py", line 44, in main
    start()
  File "/content/drive/MyDrive/stable-diffusion-webui-colab/nightly/stable-diffusion-webui/modules/launch_utils.py", line 432, in start
    import webui
  File "/content/drive/MyDrive/stable-diffusion-webui-colab/nightly/stable-diffusion-webui/webui.py", line 13, in <module>
    initialize.imports()
  File "/content/drive/MyDrive/stable-diffusion-webui-colab/nightly/stable-diffusion-webui/modules/initialize.py", line 16, in imports
    import pytorch_lightning  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/__init__.py", line 35, in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/__init__.py", line 14, in <module>
    from pytorch_lightning.callbacks.batch_size_finder import BatchSizeFinder
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/batch_size_finder.py", line 24, in <module>
    from pytorch_lightning.callbacks.callback import Callback
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/callbacks/callback.py", line 25, in <module>
    from pytorch_lightning.utilities.types import STEP_OUTPUT
  File "/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/types.py", line 27, in <module>
    from torchmetrics import Metric
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/__init__.py", line 22, in <module>
    from torchmetrics import functional  # noqa: E402
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/functional/__init__.py", line 14, in <module>
    from torchmetrics.functional.audio._deprecated import _permutation_invariant_training as permutation_invariant_training
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/functional/audio/__init__.py", line 14, in <module>
    from torchmetrics.functional.audio.pit import permutation_invariant_training, pit_permutate
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/functional/audio/pit.py", line 22, in <module>
    from torchmetrics.utilities import rank_zero_warn
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/utilities/__init__.py", line 14, in <module>
    from torchmetrics.utilities.checks import check_forward_full_state_property
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/utilities/checks.py", line 25, in <module>
    from torchmetrics.metric import Metric
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/metric.py", line 30, in <module>
    from torchmetrics.utilities.data import (
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/utilities/data.py", line 22, in <module>
    from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_1_12, _XLA_AVAILABLE
  File "/usr/local/lib/python3.10/dist-packages/torchmetrics/utilities/imports.py", line 45, in <module>
    _TORCHVISION_GREATER_EQUAL_0_8: Optional[bool] = compare_version("torchvision", operator.ge, "0.8.0")
  File "/usr/local/lib/python3.10/dist-packages/lightning_utilities/core/imports.py", line 77, in compare_version
    pkg = importlib.import_module(package)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.10/dist-packages/torchvision/__init__.py", line 6, in <module>
    from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
  File "/usr/local/lib/python3.10/dist-packages/torchvision/_meta_registrations.py", line 7, in <module>
    import torchvision.extension  # noqa: F401
  File "/usr/local/lib/python3.10/dist-packages/torchvision/extension.py", line 92, in <module>
    _check_cuda_version()
  File "/usr/local/lib/python3.10/dist-packages/torchvision/extension.py", line 78, in _check_cuda_version
    raise RuntimeError(
RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA major versions. PyTorch has CUDA Version=12.1 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install.