Cannot load custom pipeline modules defined in the main script
See original GitHub issueDescribe the bug
pipeline_util.register_modules
tries to retrieve __module__
from pipeline modules and crashes for modules defined in the main class because the module __main__
does not contain a .
Reproduction
Create a pipeline with an own safetychecker class, e.g.:
class DummyChecker:
def __call__(self, clip_input, images):
images, False
create a pipe with that module:
pipe = StableDiffusionImg2ImgPipeline(
vae,
text_encoder,
tokenizer,
unet,
scheduler,
DummyChecker(),
feature_extractor)
Logs
With an added `print(name, module.__module__)`:
vae diffusers.models.vae
text_encoder transformers.models.clip.modeling_clip
tokenizer transformers.models.clip.tokenization_clip
unet diffusers.models.unet_2d_condition
scheduler diffusers.schedulers.scheduling_lms_discrete
safety_checker __main__
(...)
File "diffusers/src/diffusers/pipeline_utils.py", line 88, in register_modules
pipeline_dir = module.__module__.split(".")[-2]
IndexError: list index out of range
### System Info
diffusers git checkout
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Google Dataflow - Failed to import custom python modules
In case of Dataflow runner, pipeline fails with module import error. How do I make custom modules available to all the dataflow workers?...
Read more >The specified module 'Module Name' was not loaded because ...
Solution: · Step 1: Get the Path of your custom PowerShell Module. · Step 2: Verify if the custom module's path is added...
Read more >How to create a custom pipeline? - Hugging Face
In this guide, we will see how to create a custom pipeline and share it on the Hub or add it to the...
Read more >Extending with Shared Libraries - Jenkins
It is already loaded by the time the script starts, and a library of a given name may not be loaded twice. Retrieval...
Read more >ModuleNotFoundError: No module named x
import a. Python will execute the above statement in two steps: Locate, load and initialise (if required) the requested module; Define ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just found a simple solution, but not sure what the side effect is:
My script is using the Pipelines without safetychecker since weeks, I saw no point in hiding it. I think it’s 700 MB for something that only benefits one when one wants to provide a public service. shrugs
My current issue is, that I need to reload the model to change between generation/img2img/inpainting and I’d like to re-use the already loaded nets, so one can change the pipeline from a prompt in my script. And when I completely deleted the net in the old pipeline, I cannot pass it to the constructor of the new one. Constructing one to delete it again could also work, but I think when the old pipeline already filled the VRAM I cannot even construct a temporary checker. I didn’t put too much energy into trying to construct something to delete it again, though 😉
So … I could just plug it into my source checkout of diffusors, but I think each part of the pipeline will have the problem when someone wants to replace it by an own part, so maybe it is better to improve the utils class.