Cloud not import module AutoImageProcessor

Currently I am just copy pasting the code for Inapinting using SDXL and IPAdapter as provided in the IPAdapter section. The code is:

Importing required packages

import torch
from diffusers import AutoPipelineForImage2Image
from PIL import Image
import matplotlib.pyplot as plt
print(“The Libraries are loaded Successfully”)

Creating the pieline using SDXL and IPAdapter

pipeline = AutoPipelineForImage2Image.from_pretrained(
“stabilityai/stable-diffusion-xl-base-1.0”,
torch_dtype=torch.float16
).to(“cuda”)
print(“The Stable Diffusion XL pipeline created successfully”)

Attaching the IP Adapter pipeline

pipeline.load_ip_adapter(
“h94/IP-Adapter”,
subfolder=“sdxl_models”,
weight_name=“ip-adapter_sdxl.bin”)
print(“The IP Adapter is attached with the SDXL pipeline”)

Setting the IP Adapter guidance scale

pipeline.set_ip_adapter_scale(0.6)

Setting the mask image, saree image and reference image for IP Adapter

mask_image = Image.open(r"C:\Users\Webbies\Jupyter_Notebooks\Titan_Saree_VTON\Inverted_Saree_Masks.png")
image = Image.open(r"C:\Users\Webbies\Jupyter_Notebooks\Titan_Saree_VTON\Source_Model.jpg")
ip_image = Image.open(r"C:\Users\Webbies\Jupyter_Notebooks\Titan_Saree_VTON\Control_Image.jpg")
print(“Images are read successfully”)

Get the output image

output = pipeline(
prompt=“A mature heavy weight plus sized indian woman”,
image=image,
mask_image=mask_image,
ip_adapter_image=ip_image,).images[0]
print(“The output image is generated”)

Visualize the output

print(“The output image visualization process starts from here”)
plt.imshow(output)
plt.axis(‘off’)
plt.show()

The above code gives me the error:
RuntimeError: Failed to import diffusers.pipelines.auto_pipeline because of the following error (look up to see its traceback):
Could not import module ‘AutoImageProcessor’. Are this object’s requirements defined correctly?

Is this the issue with the version of diffusers? Or what is the problem here? I have recently installed safetensors and xformers, can this be the problem?

1 Like

I don’t get errors in the import section of your code…

Could not import module ‘AutoImageProcessor’. Are this object’s requirements defined correctly?

AutoImageProcessor is also used by Diffusers, but since it is a class in the Transformers library, there may be issues with the installation of Transformers. Possible causes include Diffusers being too new and Transformers being too old, or vice versa. Try:

pip install transformers<=4.48.3

safetensors and xformers, can this be the problem?

safetensors library rarely causes problems, but xformers has very strict version requirements. However, I don’t think that’s the cause of this issue. The error message appears differently in most cases.