diffusers: Custom pipelines are broken
Describe the bug
It worked a couple of days ago, but today it stopped to. I wish I have never restarted none my space. Downgrading to diffusers 0.11.0, 0.12.0, 0.14.0 etc didn’t help.
Please help me!
Reproduction
from diffusers import DiffusionPipeline, EulerAncestralDiscreteScheduler
import gradio as gr
import numpy as np
import imageio
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
import glob
import torch
from time import gmtime, strftime
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe = DiffusionPipeline.from_pretrained("NickKolok/meryl-stryfe-20230123-2300-6k-2400-steps_1", custom_pipeline="lpw_stable_diffusion", torch_dtype=torch.float32)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
pipe.to(device)
def resize(height,img):
baseheight = height
img = Image.open(img)
hpercent = (baseheight/float(img.size[1]))
wsize = int((float(img.size[0])*float(hpercent)))
img = img.resize((wsize,baseheight), Image.Resampling.LANCZOS)
return img
def predict(prompt, negative_prompt):
image = pipe(prompt=prompt, negative_prompt=negative_prompt, num_inference_steps=30, width=512, height=576).images[0]
timestamp = strftime("%Y-%m-%d---%H-%M-%S", gmtime())
#img = Image.open(image)
image.save("./diffused__"+timestamp+"_.png")
return glob.glob('./diffused_*.png')[-4:]
title="test"
description="test"
gr.Interface(
fn=predict,
inputs=[
#gr.Image(source="upload", type="numpy", tool="sketch", elem_id="source_container"),
gr.Textbox(label='What you want the AI to Generate, 77 Token limit'),
gr.Textbox(label='What you Do Not want the AI to generate')
],
outputs=[
gr.Gallery(
label="Generated images", show_label=False, elem_id="output_container_0"
).style(grid=[2], height="auto"),
#gr.Image(elem_id="output_container_0"),
#gr.Image(elem_id="output_container_1"),
],
title=title,
description=description,
article = ""
).launch(max_threads=True, debug=True)
Logs
Downloading (…)_stable_diffusion.py: 0%| | 0.00/13.9k [00:00<?, ?B/s]
Downloading (…)_stable_diffusion.py: 76.5kB [00:00, 17.6MB/s]
Traceback (most recent call last):
File "app.py", line 16, in <module>
pipe = DiffusionPipeline.from_pretrained("NickKolok/meryl-stryfe-20230123-2300-6k-2400-steps_1", custom_pipeline="lpw_stable_diffusion", torch_dtype=torch.float32)
File "/home/user/.local/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 655, in from_pretrained
pipeline_class = get_class_from_dynamic_module(
File "/home/user/.local/lib/python3.8/site-packages/diffusers/utils/dynamic_modules_utils.py", line 456, in get_class_from_dynamic_module
return get_class_in_module(class_name, final_module.replace(".py", ""))
File "/home/user/.local/lib/python3.8/site-packages/diffusers/utils/dynamic_modules_utils.py", line 163, in get_class_in_module
module = importlib.import_module(module_path)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/.cache/huggingface/modules/diffusers_modules/git/lpw_stable_diffusion.py", line 13, in <module>
from diffusers.image_processor import VaeImageProcessor
ModuleNotFoundError: No module named 'diffusers.image_processor'
System Info
huggingface spaces (It runs on cpu, on a free HF instance - if that helps.) different diffusers versions (from 0.11.0 to 0.14.0 and even newest)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 29 (18 by maintainers)
True, (()) is not there. Thinking of taking prompt weighting of lpw as separate lib, to get out of this dependency.
Hey, we’ll revert the PR. We think what’s happening here is that the custom pipeline code downloads the pipeline at diffusers
main
even if you’re on a older version of diffusers. We should better pin down the compatibility story for community pipelines. Just being safe right now and going to revert the PR.A simple change to defaulting to pulling in code from the installed version rather than from
main
I think is the best solution here, which I would imagine is the intended behavior.Execution of dynamic remote code can also be a serious security risk, not sure if this is a standard practice in other places in the code.
Happy to help on a PR for that.
You can pin the dependency for dynamic imports. We use
0.15.1
.That’s here again
What’s happening? Could you please stop breaking everything every other day?
Agree @ghunkins we should default downloading to currently installed version
I’m really happy to confirm that everything is working like a charm again! Thank you all for your help 😃
PR is reverted
At least, it should be emphasized in the docs. That’s really non-obvious.
@ghunkins, thank you very much!
This is a more minimal reproduction:
Error:
This reproduction was run with:
This import error is appearing in code that has not been redeployed, and is running the same container image that worked previously.