import torch
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline,StableDiffusionInpaintPipelineLegacy, DDIMScheduler, AutoencoderKL
from PIL import Image
from ip_adapter import IPAdapter
When i run above lines of code i got error as mention below:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
File ~/IP-Adapter/imgToimg_venv/lib/python3.8/site- packages/diffusers/utils/import_utils.py:710, in _LazyModule._get_module(self, module_name)
709 try:
--> 710 return importlib.import_module("." + module_name, self.__name__)
711 except Exception as e:
File /usr/lib/python3.8/importlib/__init__.py:127, in import_module(name, package)
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1014, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:991, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:973, in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'diffusers.models.autoencoder_kl'
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
Cell In[33], line 2
1 import torch
----> 2 from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, StableDiffusionInpaintPipelineLegacy, DDIMScheduler, AutoencoderKL
3 from PIL import Image
5 from ip_adapter import IPAdapter
File <frozen importlib._bootstrap>:1039, in _handle_fromlist(module, fromlist, import_, recursive)
File ~/IP-Adapter/imgToimg_venv/lib/python3.8/site- packages/diffusers/utils/import_utils.py:701, in _LazyModule.__getattr__(self, name)
699 elif name in self._class_to_module.keys():
700 module = self._get_module(self._class_to_module[name])
--> 701 value = getattr(module, name)
702 else:
703 raise AttributeError(f"module {self.__name__} has no attribute {name}")
File ~/IP-Adapter/imgToimg_venv/lib/python3.8/site- packages/diffusers/utils/import_utils.py:700, in _LazyModule.__getattr__(self, name)
698 value = self._get_module(name)
699 elif name in self._class_to_module.keys():
--> 700 module = self._get_module(self._class_to_module[name])
701 value = getattr(module, name)
702 else:
File ~/IP-Adapter/imgToimg_venv/lib/python3.8/site-packages/diffusers/utils/import_utils.py:712, in _LazyModule._get_module(self, module_name)
710 return importlib.import_module("." + module_name, self.__name__)
711 except Exception as e:
--> 712 raise RuntimeError(
713 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
714 f" traceback):\n{e}"
715 ) from e
RuntimeError: Failed to import diffusers.models.autoencoder_kl because of the following error (look up to see its traceback):
No module named 'diffusers.models.autoencoder_kl'
i tried to upgrade the diffusers but still i got these problem. this is a part of image generation git repo you can just search "IP-adpater" actually i am working on image generation task previously i am done my work on my local system and now first time i am working in server where i got GPU access but same code run successful when i shifted to server i got these error.
The issue is due to the improper setup of the environment for
IP-adapter. Follow below steps for correct installation.After starting your compute instance, create a setup bash script for
IP-adapter.You will get the prompt below. Select File type as
Bashand give the file a name.After creating, add the content below to the file and save.
Next, open the terminal of your compute instance and select the
Azureml PyTorch and Tensorflowenvironment using the command below. You will need to select the same kernel while running the notebook as well.and
conda activate azureml_py38_PT_TFNext, run the script you created.
Wait for the script execution. Since it has to download large model files, it will take some time.
After execution, run your import statements in the notebook. Make sure you select the Python 3.8 - Pytorch And Tensorflow kernel.