vladmandic / automatic

SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models
https://github.com/vladmandic/automatic
GNU Affero General Public License v3.0
5.36k stars 382 forks source link

[Issue]: Bug: header b"b'Exif\\x" not valid #1668

Closed VitaliyAT closed 1 year ago

VitaliyAT commented 1 year ago

Issue Description

Trying upscale photos, got error. Full cmd log: `Using VENV: C:\ai\VladDif\venv 19:37:18-428889 INFO Starting SD.Next 19:37:18-446811 INFO Python 3.10.9 on Windows 19:37:19-038429 INFO Version: 0891b30f Sat May 20 08:29:02 2023 -0400 19:37:21-648036 INFO Latest published version: 186bd236f592991cc9d9303689846c6d9eb68bb3 2023-07-13T13:50:38Z 19:37:21-650072 INFO Setting environment tuning 19:37:21-653060 INFO nVidia CUDA toolkit detected 19:37:28-811502 INFO Torch 2.0.1+cu118 19:37:28-831434 INFO Torch backend: nVidia CUDA 11.8 cuDNN 8700 19:37:28-834597 INFO Torch detected GPU: NVIDIA RTX A4000 VRAM 16376 Arch (8, 6) Cores 48 19:37:28-837279 INFO Verifying requirements 19:37:28-867419 INFO Installing packages 19:37:28-933557 INFO No changes detected: Quick launch active 19:37:28-948547 INFO Running extension preloading 19:37:28-951724 INFO Server arguments: [] No module 'xformers'. Proceeding without it. 19:37:50-952785 INFO Libraries loaded 19:37:50-955780 INFO Using data path: C:\ai\VladDif 19:37:50-962803 INFO Available VAEs: C:\ai\VladDif\models\VAE 2 19:37:52-027768 INFO Available models: C:\ai\VladDif\models\Stable-diffusion 75 2023-07-13 19:37:54,294 - ControlNet - INFO - ControlNet v1.1.227 ControlNet preprocessor location: C:\ai\VladDif\extensions-builtin\sd-webui-controlnet\annotator\downloads 2023-07-13 19:37:54,502 - ControlNet - INFO - ControlNet v1.1.227 2023-07-13 19:37:57,039 - roop - INFO - roop v0.0.2 2023-07-13 19:37:57,042 - roop - INFO - roop v0.0.2 19:37:57-320126 INFO Loading UI theme: name=black-orange style=Auto Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch(). 19:38:02-264493 INFO Local URL: http://127.0.0.1:7860/ 19:38:02-266457 INFO API Docs: http://127.0.0.1:7860/docs 19:38:02-268446 INFO Initializing middleware 19:38:02-635977 INFO Setting Torch parameters: dtype=torch.float16 vae=torch.float16 unet=torch.float16 Loading weights: C:\ai\VladDif\models\Stable-diffusion\Reliberate-inpainting.safetensors ----------- 0.0/2.1 GB -:--:-- LatentInpaintDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.54 M params. 19:38:03-228073 INFO Model created from config: C:\ai\VladDif\configs\v1-inpainting-inference.yaml 19:38:04-897525 INFO Applying scaled dot product cross attention optimization 19:38:05-349922 INFO Embeddings loaded: 15 ['bad-artist', 'bad-artist-anime', 'bad-hands-5', 'bad-image-v2-39000', 'bad_prompt_version2', 'dairokutenma-8100', 'darkskin_style', 'easynegative', 'epiCNegative', 'HyperStylizeV6', 'lam-20000', 'ng_deepnegative_v1_75t', 'tabi', 'verybadimagenegative_v1.3', 'vile_prompt3'] 19:38:05-357179 INFO Textual inversion embeddings skipped(1): NegLowRes-2400 19:38:05-364754 INFO Model loaded in 2.8s (load=0.2s create=0.4s apply=0.4s vae=0.5s move=0.7s embeddings=0.5s) 19:38:05-589673 INFO Model load finished: {'ram': {'used': 3.1, 'total': 63.85}, 'gpu': {'used': 3.15, 'total': 15.99}, 'retries': 0, 'oom': 0} 19:38:06-455552 INFO Setting Torch parameters: dtype=torch.float16 vae=torch.float16 unet=torch.float16 Loading weights: C:\ai\VladDif\models\Stable-diffusion\Reliberate-inpainting.safetensors ----------- 0.0/2.1 GB -:--:-- LatentInpaintDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.54 M params. 19:38:07-071211 INFO Model created from config: C:\ai\VladDif\configs\v1-inpainting-inference.yaml 19:38:08-793177 INFO Applying scaled dot product cross attention optimization 19:38:08-816241 INFO Model loaded in 3.1s (load=1.0s create=0.4s apply=0.4s vae=0.5s move=0.8s) 19:38:09-034287 INFO Model load finished: {'ram': {'used': 3.1, 'total': 63.85}, 'gpu': {'used': 3.15, 'total': 15.99}, 'retries': 0, 'oom': 0} 19:38:09-323366 INFO Startup time: 40.3s (torch=17.3s gradio=2.5s libraries=2.2s models=1.1s codeformer=0.2s scripts=4.9s opts onchange=0.1s ui=4.5s start=0.4s scripts app_started_callback=0.1s checkpoint=7.0s) 19:38:09-327307 INFO Memory used: 1.12 total: 63.85 Traceback (most recent call last): File "C:\ai\VladDif\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict output = await app.get_blocks().process_api( File "C:\ai\VladDif\venv\lib\site-packages\gradio\blocks.py", line 1321, in process_api inputs = self.preprocess_data(fn_index, inputs, state) File "C:\ai\VladDif\venv\lib\site-packages\gradio\blocks.py", line 1171, in preprocess_data processed_input.append(block.preprocess(inputs[i])) File "C:\ai\VladDif\venv\lib\site-packages\gradio\components.py", line 1792, in preprocess im = processing_utils.decode_base64_to_image(x) File "C:\ai\VladDif\venv\lib\site-packages\gradio\processing_utils.py", line 52, in decode_base64_to_image exif = img.getexif() File "C:\ai\VladDif\venv\lib\site-packages\PIL\PngImagePlugin.py", line 1028, in getexif return super().getexif() File "C:\ai\VladDif\venv\lib\site-packages\PIL\Image.py", line 1455, in getexif self._exif.load(exif_info) File "C:\ai\VladDif\venv\lib\site-packages\PIL\Image.py", line 3719, in load self._info = TiffImagePlugin.ImageFileDirectory_v2(self.head) File "C:\ai\VladDif\venv\lib\site-packages\PIL\TiffImagePlugin.py", line 507, in init raise SyntaxError(msg) SyntaxError: not a TIFF file (header b"b'Exif\x" not valid) Traceback (most recent call last): File "C:\ai\VladDif\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict output = await app.get_blocks().process_api( File "C:\ai\VladDif\venv\lib\site-packages\gradio\blocks.py", line 1321, in process_api inputs = self.preprocess_data(fn_index, inputs, state) File "C:\ai\VladDif\venv\lib\site-packages\gradio\blocks.py", line 1171, in preprocess_data processed_input.append(block.preprocess(inputs[i])) File "C:\ai\VladDif\venv\lib\site-packages\gradio\components.py", line 1792, in preprocess im = processing_utils.decode_base64_to_image(x) File "C:\ai\VladDif\venv\lib\site-packages\gradio\processing_utils.py", line 52, in decode_base64_to_image exif = img.getexif() File "C:\ai\VladDif\venv\lib\site-packages\PIL\PngImagePlugin.py", line 1028, in getexif return super().getexif() File "C:\ai\VladDif\venv\lib\site-packages\PIL\Image.py", line 1455, in getexif self._exif.load(exif_info) File "C:\ai\VladDif\venv\lib\site-packages\PIL\Image.py", line 3719, in load self._info = TiffImagePlugin.ImageFileDirectory_v2(self.head) File "C:\ai\VladDif\venv\lib\site-packages\PIL\TiffImagePlugin.py", line 507, in init raise SyntaxError(msg) SyntaxError: not a TIFF file (header b"b'Exif\x" not valid) Traceback (most recent call last): File "C:\ai\VladDif\venv\lib\site-packages\gradio\routes.py", line 414, in run_predict output = await app.get_blocks().process_api( File "C:\ai\VladDif\venv\lib\site-packages\gradio\blocks.py", line 1321, in process_api inputs = self.preprocess_data(fn_index, inputs, state) File "C:\ai\VladDif\venv\lib\site-packages\gradio\blocks.py", line 1171, in preprocess_data processed_input.append(block.preprocess(inputs[i])) File "C:\ai\VladDif\venv\lib\site-packages\gradio\components.py", line 1792, in preprocess im = processing_utils.decode_base64_to_image(x) File "C:\ai\VladDif\venv\lib\site-packages\gradio\processing_utils.py", line 52, in decode_base64_to_image exif = img.getexif() File "C:\ai\VladDif\venv\lib\site-packages\PIL\PngImagePlugin.py", line 1028, in getexif return super().getexif() File "C:\ai\VladDif\venv\lib\site-packages\PIL\Image.py", line 1455, in getexif self._exif.load(exif_info) File "C:\ai\VladDif\venv\lib\site-packages\PIL\Image.py", line 3719, in load self._info = TiffImagePlugin.ImageFileDirectory_v2(self.head) File "C:\ai\VladDif\venv\lib\site-packages\PIL\TiffImagePlugin.py", line 507, in init raise SyntaxError(msg) SyntaxError: not a TIFF file (header b"b'Exif\x" not valid)`

Version Platform Description

win10

Acknowledgements

vladmandic commented 1 year ago

seems there is some corruption in image header - can you upload that image (here or somewhere else)?

VitaliyAT commented 1 year ago

00088 00088.zip

Even if I resave it PS - error the same

vladmandic commented 1 year ago

that image really does have corrupt exif header and i cannot ignore it as error happens within gradio before app has any chance to do something. how was that image generated?

vladmandic commented 1 year ago

btw, this is raw output of the header - it has exif inside exif.

PNG metadata: {
  "jfif": "257",
  "jfif_version": "(1, 1)",
  "jfif_unit": "0",
  "jfif_density": "(1, 1)",
  "exif": "b'Exif\\x00\\x00MM\\x00*\\x00\\x00\\x00\\x08\\x00\\x01\\x87i\\x00\\x04\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x1a\\x00\\x00\\x00\\x00\\x00\\x01\\x92\\x86\\x00\\x07\\x00\\x00\\x07\\xf4\\x00\\x00\\x00(UNICODE\\x00\\x00e\\x00y\\x00e\\x00s\\x00,\\x00 \\x00d\\x00e\\x00t\\x00a\\x00i\\x00l\\x00e\\x00d\\x00,\\x00 \\x008\\x00k\\x00,\\x00
\\x00(\\x00(\\x00f\\x00o\\x00c\\x00u\\x00s\\x00)\\x00)\\x00\\n\\x00N\\x00e\\x00g\\x00a\\x00t\\x00i\\x00v\\x00e\\x00 \\x00p\\x00r\\x00o\\x00m\\x00p\\x00t\\x00:\\x00 \\x00(\\x00d\\x00e\\x00f\\x00o\\x00r\\x00m\\x00e\\x00d\\x00 \\x00i\\x00r\\x00i\\x00s\\x00,\\x00 \\x00d\\x00e\\x00f\\x00o\\x00r\\x00m\\x00e\\x00d\\x00
\\x00p\\x00u\\x00p\\x00i\\x00l\\x00s\\x00,\\x00 \\x00s\\x00e\\x00m\\x00i\\x00-\\x00r\\x00e\\x00a\\x00l\\x00i\\x00s\\x00t\\x00i\\x00c\\x00,\\x00 \\x00c\\x00g\\x00i\\x00,\\x00 \\x003\\x00d\\x00,\\x00 \\x00r\\x00e\\x00n\\x00d\\x00e\\x00r\\x00,\\x00 \\x00s\\x00k\\x00e\\x00t\\x00c\\x00h\\x00,\\x00
\\x00c\\x00a\\x00r\\x00t\\x00o\\x00o\\x00n\\x00,\\x00 \\x00d\\x00r\\x00a\\x00w\\x00i\\x00n\\x00g\\x00,\\x00 \\x00a\\x00n\\x00i\\x00m\\x00e\\x00:\\x001\\x00.\\x004\\x00)\\x00,\\x00 \\x00t\\x00e\\x00x\\x00t\\x00,\\x00 \\x00c\\x00l\\x00o\\x00s\\x00e\\x00 \\x00u\\x00p\\x00,\\x00 \\x00c\\x00r\\x00o\\x00p\\x00p\\x00e\\x00d\\x00,\\x00
\\x00o\\x00u\\x00t\\x00 \\x00o\\x00f\\x00 \\x00f\\x00r\\x00a\\x00m\\x00e\\x00,\\x00 \\x00w\\x00o\\x00r\\x00s\\x00t\\x00 \\x00q\\x00u\\x00a\\x00l\\x00i\\x00t\\x00y\\x00,\\x00 \\x00l\\x00o\\x00w\\x00 \\x00q\\x00u\\x00a\\x00l\\x00i\\x00t\\x00y\\x00,\\x00 \\x00j\\x00p\\x00e\\x00g\\x00
\\x00a\\x00r\\x00t\\x00i\\x00f\\x00a\\x00c\\x00t\\x00s\\x00,\\x00 \\x00u\\x00g\\x00l\\x00y\\x00,\\x00 \\x00d\\x00u\\x00p\\x00l\\x00i\\x00c\\x00a\\x00t\\x00e\\x00,\\x00 \\x00m\\x00o\\x00r\\x00b\\x00i\\x00d\\x00,\\x00 \\x00m\\x00u\\x00t\\x00i\\x00l\\x00a\\x00t\\x00e\\x00d\\x00,\\x00 \\x00e\\x00x\\x00t\\x00r\\x00a\\x00
\\x00f\\x00i\\x00n\\x00g\\x00e\\x00r\\x00s\\x00,\\x00 \\x00m\\x00u\\x00t\\x00a\\x00t\\x00e\\x00d\\x00 \\x00h\\x00a\\x00n\\x00d\\x00s\\x00,\\x00 \\x00p\\x00o\\x00o\\x00r\\x00l\\x00y\\x00 \\x00d\\x00r\\x00a\\x00w\\x00n\\x00 \\x00h\\x00a\\x00n\\x00d\\x00s\\x00,\\x00 \\x00p\\x00o\\x00o\\x00r\\x00l\\x00y\\x00
\\x00d\\x00r\\x00a\\x00w\\x00n\\x00 \\x00f\\x00a\\x00c\\x00e\\x00,\\x00 \\x00m\\x00u\\x00t\\x00a\\x00t\\x00i\\x00o\\x00n\\x00,\\x00 \\x00d\\x00e\\x00f\\x00o\\x00r\\x00m\\x00e\\x00d\\x00,\\x00 \\x00b\\x00l\\x00u\\x00r\\x00r\\x00y\\x00,\\x00 \\x00d\\x00e\\x00h\\x00y\\x00d\\x00r\\x00a\\x00t\\x00e\\x00d\\x00,\\x00 \\x00b\\x00a\\x00d\\x00
\\x00a\\x00n\\x00a\\x00t\\x00o\\x00m\\x00y\\x00,\\x00 \\x00b\\x00a\\x00d\\x00 \\x00p\\x00r\\x00o\\x00p\\x00o\\x00r\\x00t\\x00i\\x00o\\x00n\\x00s\\x00,\\x00 \\x00e\\x00x\\x00t\\x00r\\x00a\\x00 \\x00l\\x00i\\x00m\\x00b\\x00s\\x00,\\x00 \\x00c\\x00l\\x00o\\x00n\\x00e\\x00d\\x00 \\x00f\\x00a\\x00c\\x00e\\x00,\\x00
\\x00d\\x00i\\x00s\\x00f\\x00i\\x00g\\x00u\\x00r\\x00e\\x00d\\x00,\\x00 \\x00g\\x00r\\x00o\\x00s\\x00s\\x00 \\x00p\\x00r\\x00o\\x00p\\x00o\\x00r\\x00t\\x00i\\x00o\\x00n\\x00s\\x00,\\x00 \\x00m\\x00a\\x00l\\x00f\\x00o\\x00r\\x00m\\x00e\\x00d\\x00 \\x00l\\x00i\\x00m\\x00b\\x00s\\x00,\\x00 \\x00m\\x00i\\x00s\\x00s\\x00i\\x00n\\x00g\\x00
\\x00a\\x00r\\x00m\\x00s\\x00,\\x00 \\x00m\\x00i\\x00s\\x00s\\x00i\\x00n\\x00g\\x00 \\x00l\\x00e\\x00g\\x00s\\x00,\\x00 \\x00e\\x00x\\x00t\\x00r\\x00a\\x00 \\x00a\\x00r\\x00m\\x00s\\x00,\\x00 \\x00e\\x00x\\x00t\\x00r\\x00a\\x00 \\x00l\\x00e\\x00g\\x00s\\x00,\\x00 \\x00f\\x00u\\x00s\\x00e\\x00d\\x00
\\x00f\\x00i\\x00n\\x00g\\x00e\\x00r\\x00s\\x00,\\x00 \\x00t\\x00o\\x00o\\x00 \\x00m\\x00a\\x00n\\x00y\\x00 \\x00f\\x00i\\x00n\\x00g\\x00e\\x00r\\x00s\\x00,\\x00 \\x00l\\x00o\\x00n\\x00g\\x00 \\x00n\\x00e\\x00c\\x00k\\x00\\n\\x00S\\x00t\\x00e\\x00p\\x00s\\x00:\\x00 \\x003\\x000\\x00,\\x00
\\x00S\\x00a\\x00m\\x00p\\x00l\\x00e\\x00r\\x00:\\x00 \\x00E\\x00u\\x00l\\x00e\\x00r\\x00 \\x00a\\x00,\\x00 \\x00C\\x00F\\x00G\\x00 \\x00s\\x00c\\x00a\\x00l\\x00e\\x00:\\x00 \\x007\\x00,\\x00 \\x00S\\x00e\\x00e\\x00d\\x00:\\x00 \\x003\\x001\\x005\\x001\\x007\\x007\\x009\\x001\\x004\\x008\\x00,\\x00 \\x00S\\x00i\\x00z\\x00e\\x00:\\x00
\\x006\\x001\\x002\\x00x\\x006\\x005\\x002\\x00,\\x00 \\x00M\\x00o\\x00d\\x00e\\x00l\\x00 \\x00h\\x00a\\x00s\\x00h\\x00:\\x00 \\x009\\x008\\x000\\x00c\\x00b\\x007\\x001\\x003\\x00a\\x00f\\x00,\\x00 \\x00M\\x00o\\x00d\\x00e\\x00l\\x00:\\x00 \\x00r\\x00e\\x00l\\x00i\\x00b\\x00e\\x00r\\x00a\\x00t\\x00e\\x00_\\x00v\\x001\\x000\\x00,\\x00
\\x00D\\x00e\\x00n\\x00o\\x00i\\x00s\\x00i\\x00n\\x00g\\x00 \\x00s\\x00t\\x00r\\x00e\\x00n\\x00g\\x00t\\x00h\\x00:\\x00 \\x001\\x00,\\x00 \\x00C\\x00l\\x00i\\x00p\\x00 \\x00s\\x00k\\x00i\\x00p\\x00:\\x00 \\x001\\x00,\\x00 \\x00V\\x00e\\x00r\\x00s\\x00i\\x00o\\x00n\\x00:\\x00 \\x000\\x008\\x009\\x001\\x00b\\x003\\x000\\x00,\\x00
\\x00P\\x00a\\x00r\\x00s\\x00e\\x00r\\x00:\\x00 \\x00F\\x00u\\x00l\\x00l\\x00 \\x00p\\x00a\\x00r\\x00s\\x00e\\x00r\\x00,\\x00 \\x00M\\x00a\\x00s\\x00k\\x00 \\x00b\\x00l\\x00u\\x00r\\x00:\\x00 \\x004\\x00,\\x00 \\x00C\\x00o\\x00n\\x00t\\x00r\\x00o\\x00l\\x00N\\x00e\\x00t\\x00:\\x00
\\x00\"\\x00p\\x00r\\x00e\\x00p\\x00r\\x00o\\x00c\\x00e\\x00s\\x00s\\x00o\\x00r\\x00:\\x00 \\x00n\\x00o\\x00n\\x00e\\x00,\\x00 \\x00m\\x00o\\x00d\\x00e\\x00l\\x00:\\x00 \\x00c\\x00o\\x00n\\x00t\\x00r\\x00o\\x00l\\x00_\\x00v\\x001\\x001\\x00e\\x00_\\x00s\\x00d\\x001\\x005\\x00_\\x00i\\x00p\\x002\\x00p\\x00
\\x00[\\x00c\\x004\\x00b\\x00b\\x004\\x006\\x005\\x00c\\x00]\\x00,\\x00 \\x00w\\x00e\\x00i\\x00g\\x00h\\x00t\\x00:\\x00 \\x001\\x00,\\x00 \\x00s\\x00t\\x00a\\x00r\\x00t\\x00i\\x00n\\x00g\\x00/\\x00e\\x00n\\x00d\\x00i\\x00n\\x00g\\x00:\\x00 \\x00(\\x000\\x00,\\x00 \\x000\\x00.\\x006\\x002\\x00)\\x00,\\x00
\\x00r\\x00e\\x00s\\x00i\\x00z\\x00e\\x00 \\x00m\\x00o\\x00d\\x00e\\x00:\\x00 \\x00C\\x00r\\x00o\\x00p\\x00 \\x00a\\x00n\\x00d\\x00 \\x00R\\x00e\\x00s\\x00i\\x00z\\x00e\\x00,\\x00 \\x00p\\x00i\\x00x\\x00e\\x00l\\x00 \\x00p\\x00e\\x00r\\x00f\\x00e\\x00c\\x00t\\x00:\\x00 \\x00T\\x00r\\x00u\\x00e\\x00,\\x00
\\x00c\\x00o\\x00n\\x00t\\x00r\\x00o\\x00l\\x00 \\x00m\\x00o\\x00d\\x00e\\x00:\\x00 \\x00B\\x00a\\x00l\\x00a\\x00n\\x00c\\x00e\\x00d\\x00,\\x00 \\x00p\\x00r\\x00e\\x00p\\x00r\\x00o\\x00c\\x00e\\x00s\\x00s\\x00o\\x00r\\x00 \\x00p\\x00a\\x00r\\x00a\\x00m\\x00s\\x00:\\x00 \\x00(\\x005\\x001\\x002\\x00,\\x00 \\x006\\x001\\x00,\\x00
\\x004\\x00)\\x00\"'",
  "dpi": "(72, 72)",
  "postprocessing": "Postprocess upscale by: 1, Postprocess upscaler: 4x_Valar_v1, GFPGAN visibility: 1",
  "extras": "Postprocess upscale by: 1, Postprocess upscaler: 4x_Valar_v1, GFPGAN visibility: 1"
}
VitaliyAT commented 1 year ago

that image really does have corrupt exif header and i cannot ignore it as error happens within gradio before app has any chance to do something. how was that image generated?

it was generated buy SD by itself.

VitaliyAT commented 1 year ago

Is it possible create some exif fixer builded in Vlad Diffusion? It's very popular problem - but no correct answer finded. Nobody think about problem inside picture as you. All suggest change something in scripts.

Or, like an idea, is it possible that it's not a bug , but it's some new format of EXIF that not supported in input (but generated in output)?

vladmandic commented 1 year ago

i may create a metadata editor in the future, but thats not a short term item.

how was this image generated exactly? and when (using which version)? was it using sdnext or a1111?