s1dlx / sd-webui-bayesian-merger

opinionated bayesian optimisation for stable diffusion models block merge
MIT License
119 stars 18 forks source link

Trying to run from the automatic version of vlanmandic result in clip error #62

Closed bmaltais closed 1 year ago

bmaltais commented 1 year ago

Good afternoon,

I tought I would try to run the merger under vladmandic port of auto1111 webui and it is giving me a CLIP error...

(venv) PS D:\automatic\extensions\sd-webui-bayesian-merger> python.exe .\bayesian_merger.py
Loading sac+logos+ava1-l14-linearMSE.pth
Loading ViT-L/14
Error executing job with overrides: []
Traceback (most recent call last):
  File "D:\automatic\extensions\sd-webui-bayesian-merger\bayesian_merger.py", line 37, in main
    bo = cls(cfg)
  File "<string>", line 5, in __init__
  File "D:\automatic\extensions\sd-webui-bayesian-merger\sd_webui_bayesian_merger\optimiser.py", line 127, in __post_init__
    self.scorer = AestheticScorer(self.cfg)
  File "<string>", line 4, in __init__
  File "D:\automatic\extensions\sd-webui-bayesian-merger\sd_webui_bayesian_merger\scorer.py", line 79, in __post_init__
    self.load_model()
  File "D:\automatic\extensions\sd-webui-bayesian-merger\sd_webui_bayesian_merger\scorer.py", line 144, in load_model
    self.load_clip()
  File "D:\automatic\extensions\sd-webui-bayesian-merger\sd_webui_bayesian_merger\scorer.py", line 155, in load_clip
    self.clip_model, self.clip_preprocess = clip.load(
AttributeError: module 'clip' has no attribute 'load'

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

I know you are developping for auto1111 but many users are now moving away from it because it is becoming stale... and falling behind from a support and feature point of view. Perhaps you might consider making this great extension work under vladmandic fork:

https://github.com/vladmandic/automatic

This is a fresh install of vladmandic with no customization... so it is as pure as can be.

s1dlx commented 1 year ago

hello @bmaltais!

that error is possibly because you do not have clip library installed in the venv where you are running the script

webui calls install.py which, in turn, calls pip install -r requirements.txt for you. I'm not sure the same is true for vladmandic fork. Follow these instructions and before point 6 do python3 -m pip install -r requirements.txt to install the required libraries. That should fix your issue

apart from that, this script uses webui only because of its api, there's no other particular feature used. As long as the fork uses the same api, we should be good.

bmaltais commented 1 year ago

Many thanks. I will give that a try...

bmaltais commented 1 year ago

Hummm... looking at pip freeze it look like vladmandic install clip @ git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1

I tried uninstalling that and dod a pip upgrade -r requirements.txt and it installed the standard clip==0.2.0 but still the same error.

I guess I can always run the merger from within the auto1111 repo...

UPDATE:

I will be damned... After uninstalling clip==0.2.0 I restarted vladmandic and it re-installed the missing clip module and now all is working! Not sure why that is but perhaps the original clip install had failed.