-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradio seems to break Pillow / PIL.Image format support #2843
Comments
@jokkebk can you see my issue report python-pillow/Pillow#6809 and if you can reproduce what I discovered? It would help if you also managed to reproduce and comment under the issue so they can notice it quickly. |
Wow, awesome detective work @aliencaocao ! Tried your example in pillow issue report and can replicate, I commented there as well. So it seems like this is an issue with Pillow's PngImagePlugin (or some interplay of its internal components), just that it is triggered by Gradio that uses both. |
Very interesting, thanks for pointing out the issue @jokkebk as well as the underlying problem @aliencaocao. It sounds like the issue needs to be addressed in PIL, but we'll look to see if there's something we can do in gradio too as a patch. |
@abidlabs following PIL author's suggestion, gradio should add the following code: from PIL import Image
Image.init() python-pillow/Pillow#6809 (comment) They have also made a PR that is pending to be merged, but the code above should be the proper patch before the PR is merged and they release a new version (which would be in Jan 2023) I have made a PR: #2846 |
I'm having this issue, probably related. The
prints:
I'm using:
|
Describe the bug
Encountered this on latest Automatic1111 Stable Diffusion Webui, suddenly PIL on my Win10 machine had lost all but PNG support:
registered_extensions
gives me about 20 file formatsimport gradio
first and then PIL.Image, I only get{'.png': 'PNG', '.apng': 'PNG'}
I am not well versed enough with Gradio to understand what gets broken, my hunch would be Gradio tinkering with Pillow (as it is one requirements) upon initialization, or Gradio introducing some global variable/function that "pollutes" PIL.Image initialization.
Tried with WSL2 on Ubuntu (Gradio 3.14) and same happens, so it is not "some Windows issue" 😇
Workaround is to
import PIL.Image
before gradio, but this should not happen.Is there an existing issue for this?
Reproduction
Normal PIL Image support:
Outputs
{'.blp': 'BLP', '.bmp': 'BMP', '.dib': 'DIB', '.bufr': 'BUFR', '.cur': 'CUR', '.pcx': 'PCX', '.dcx': 'DCX', '.dds': 'DDS', '.ps': 'EPS', '.eps': 'EPS', '.fit': 'FITS', '.fits': 'FITS', '.fli': 'FLI', '.flc': 'FLI', '.ftc': 'FTEX', '.ftu': 'FTEX', '.gbr': 'GBR', '.gif': 'GIF', '.grib': 'GRIB', '.h5': 'HDF5', '.hdf': 'HDF5', '.png': 'PNG', '.apng': 'PNG', '.jp2': 'JPEG2000', '.j2k': 'JPEG2000', '.jpc': 'JPEG2000', '.jpf': 'JPEG2000', '.jpx': 'JPEG2000', '.j2c': 'JPEG2000', '.icns': 'ICNS', '.ico': 'ICO', '.im': 'IM', '.iim': 'IPTC', '.tif': 'TIFF', '.tiff': 'TIFF', '.jfif': 'JPEG', '.jpe': 'JPEG', '.jpg': 'JPEG', '.jpeg': 'JPEG', '.mpg': 'MPEG', '.mpeg': 'MPEG', '.mpo': 'MPO', '.msp': 'MSP', '.palm': 'PALM', '.pcd': 'PCD', '.pdf': 'PDF', '.pxr': 'PIXAR', '.pbm': 'PPM', '.pgm': 'PPM', '.ppm': 'PPM', '.pnm': 'PPM', '.psd': 'PSD', '.bw': 'SGI', '.rgb': 'SGI', '.rgba': 'SGI', '.sgi': 'SGI', '.ras': 'SUN', '.tga': 'TGA', '.icb': 'TGA', '.vda': 'TGA', '.vst': 'TGA', '.webp': 'WEBP', '.wmf': 'WMF', '.emf': 'WMF', '.xbm': 'XBM', '.xpm': 'XPM'}
With Gradio imported first:
Outputs only
{'.png': 'PNG', '.apng': 'PNG'}
Screenshot
$ python3
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
$ python3
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Logs
See the "screenshot" above.
System Info
Severity
serious, but I can work around it
The text was updated successfully, but these errors were encountered: