Open nyqui opened 1 year ago
I have the same isse, any image type, in img2img tab
The error is caused by the image shape being incorrect, in the extensions Scripts\app.py file, modify the file starting on line 125
from
img = im.fromarray(nimg)
to
# Check the number of channels in the nimg array
num_channels = nimg.shape[2]
if num_channels > 4:
# Select only the first 3 or 4 channels (RGB or RGBA)
nimg = nimg[:, :, :4]
# Ensure the data type is uint8
nimg = nimg.astype(np.uint8)
# Convert the image back to a format that can be saved
img = im.fromarray(nimg)
The error is caused by the image shape being incorrect, in the extensions Scripts\app.py file, modify the file starting on line 125
from
img = im.fromarray(nimg)
to
# Check the number of channels in the nimg array num_channels = nimg.shape[2] if num_channels > 4: # Select only the first 3 or 4 channels (RGB or RGBA) nimg = nimg[:, :, :4] # Ensure the data type is uint8 nimg = nimg.astype(np.uint8) # Convert the image back to a format that can be saved img = im.fromarray(nimg)
That worked nicely. Thank you.
numpy 1.23.3 onnx 1.13.1 onnxruntime 1.14.1 opencv-python 4.7.0.72 Pillow 9.4.0
This script runs fine in txt2img, but I can't get it to work in img2img. Not sure how the process would differ between the two.
Traceback (most recent call last): File "C:\Stable Diffusion\venv\lib\site-packages\PIL\Image.py", line 3080, in fromarray mode, rawmode = _fromarray_typemap[typekey] KeyError: ((1, 1, 5), '|u1')
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Stable Diffusion\modules\call_queue.py", line 56, in f res = list(func(*args, *kwargs)) File "C:\Stable Diffusion\modules\call_queue.py", line 37, in f res = func(args, *kwargs) File "C:\Stable Diffusion\modules\img2img.py", line 170, in img2img processed = modules.scripts.scripts_img2img.run(p, args) File "C:\Stable Diffusion\modules\scripts.py", line 407, in run processed = script.run(p, *script_args) File "C:\Stable Diffusion\extensions\ABG_extension\scripts\app.py", line 125, in run img = im.fromarray(nimg) File "C:\Stable Diffusion\venv\lib\site-packages\PIL\Image.py", line 3083, in fromarray raise TypeError(msg) from e TypeError: Cannot handle this data type: (1, 1, 5), |u1