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.27k stars 377 forks source link

[Issue]: Can't upscale via API #2797

Closed aaronsantiago closed 5 months ago

aaronsantiago commented 5 months ago

Issue Description

I can upscale just fine via the web UI but making a web request gives a cryptic error that I couldn't quite understand the source enough to isolate. Here's the JSON that I am sending to the extra-single-image endpoint:

{
  "resize_mode": 0,
  "upscaling_resize": 4,
  "upscaler_1": "ESRGAN 4x Ultrasharp",
  "image":  (base64)
}

I've been able to use the upscaler successfully for other requests--I think this endpoint specifically is broken.

Version Platform Description

16:30:13-981856 INFO Starting SD.Next 16:30:13-983494 INFO Logger: file="/home/sensorium/workspace/automatic/sdnext.log" level=INFO size=279396 mode=append 16:30:13-984100 INFO Python 3.9.18 on Linux 16:30:13-991560 INFO Version: app=sd.next updated=2024-02-02 hash=fcf00bd8 url=https://github.com/vladmandic/automatic/tree/dev 16:30:14-153641 INFO Latest published version: 9bf08c5493925b6ddb3451f6a6e00460ca92aedd 2024-01-30T14:29:51Z 16:30:14-165668 INFO Platform: arch=x86_64 cpu=x86_64 system=Linux release=6.5.0-15-generic python=3.9.18 16:30:14-171581 INFO nVidia CUDA toolkit detected: nvidia-smi present 16:30:14-190128 INFO Extensions: disabled=[] 16:30:14-193895 INFO Extensions: enabled=['stable-diffusion-webui-rembg', 'sd-webui-agent-scheduler', 'sd-extension-chainner', 'Lora', 'stable-diffusion-webui-images-browser', 'sd-extension-system-info', 'sd-webui-controlnet'] extensions-builtin 16:30:14-197194 INFO Extensions: enabled=['stable-diffusion-webui-depthmap-script', 'asymmetric-tiling-sd-webui'] extensions 16:30:14-199310 INFO Startup: quick launch 16:30:14-200364 INFO Verifying requirements 16:30:14-212916 INFO Verifying packages 16:30:14-215216 INFO Extensions: disabled=[] 16:30:14-216522 INFO Extensions: enabled=['stable-diffusion-webui-rembg', 'sd-webui-agent-scheduler', 'sd-extension-chainner', 'Lora', 'stable-diffusion-webui-images-browser', 'sd-extension-system-info', 'sd-webui-controlnet'] extensions-builtin 16:30:14-218011 INFO Extensions: enabled=['stable-diffusion-webui-depthmap-script', 'asymmetric-tiling-sd-webui'] extensions 16:30:14-220535 INFO Extension preload: {'extensions-builtin': 0.0, 'extensions': 0.0} 16:30:14-221612 INFO Command line args: ['--listen', '--docs', '--cors-origins', '', '--insecure'] insecure=True listen=True docs=True cors_origins= 16:30:16-062857 INFO Load packages: torch=2.2.0+cu121 diffusers=0.25.1 gradio=3.43.2 16:30:16-301163 INFO Engine: backend=Backend.ORIGINAL compute=cuda device=cuda attention="Scaled-Dot-Product" mode=no_grad 16:30:16-326502 INFO Device: device=NVIDIA GeForce RTX 4090 n=1 arch=sm_90 cap=(8, 9) cuda=12.1 cudnn=8902 driver=535.154.05 16:30:16-786873 INFO Available VAEs: path="models/VAE" items=0 16:30:16-787808 INFO Disabled extensions: [] 16:30:16-788740 INFO Available models: path="models/Stable-diffusion" items=2 time=0.00 16:30:16-881301 INFO LoRA networks: available=0 folders=2 16:30:17-003950 INFO Extension: script='extensions-builtin/sd-webui-agent-scheduler/scripts/task_scheduler.py' Using sqlite file: extensions-builtin/sd-webui-agent-scheduler/task_scheduler.sqlite3 16:30:17-158368 INFO Extension: script='extensions-builtin/sd-webui-controlnet/scripts/api.py' ControlNet preprocessor location: /home/sensorium/workspace/automatic/extensions-builtin/sd-webui-controlnet/annotator/ downloads 16:30:17-165544 INFO Extension: script='extensions-builtin/sd-webui-controlnet/scripts/controlnet.py' Warning: ControlNet failed to load SGM - will use LDM instead. 16:30:17-170126 INFO Extension: script='extensions-builtin/sd-webui-controlnet/scripts/hook.py' Warning: ControlNet failed to load SGM - will use LDM instead. 16:30:17-523470 INFO Extension: script='extensions/stable-diffusion-webui-depthmap-script/scripts/depthmap.py' The standalone mode is not on par with the stable-diffusion-webui mode. 16:30:17-524445 INFO Extension: script='extensions/stable-diffusion-webui-depthmap-script/scripts/depthmap.py' Some features may be missing or work differently. Please report bugs. 16:30:17-537074 INFO Extensions init time: 0.67 sd-webui-agent-scheduler=0.11 sd-webui-controlnet=0.17 stable-diffusion-webui-images-browser=0.10 stable-diffusion-webui-depthmap-script=0.26 16:30:17-545095 INFO Load UI theme: name="black-teal" style=Auto base=sdnext.css 16:30:18-751232 INFO Local URL: http://localhost:7860/ 16:30:18-751873 INFO API Docs: http://localhost:7860/docs 16:30:18-752312 INFO API ReDocs: http://localhost:7860/redocs

Relevant log output

16:19:13-829593 ERROR    HTTP API: AttributeError
╭──────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────╮
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/anyio/streams/memory.py:97 in receiv │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/anyio/streams/memory.py:92 in receiv │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
WouldBlock

During handling of the above exception, another exception occurred:

╭──────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────╮
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/starlette/middleware/base.py:159 in  │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/anyio/streams/memory.py:112 in recei │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
EndOfStream

During handling of the above exception, another exception occurred:

╭──────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────╮
│ /home/sensorium/workspace/automatic/modules/api/middleware.py:41 in log_and_time                          │
│                                                                                                           │
│   40 │   │   │   ts = time.time()                                                                         │
│ ❱ 41 │   │   │   res: Response = await call_next(req)                                                     │
│   42 │   │   │   duration = str(round(time.time() - ts, 4))                                               │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/starlette/middleware/base.py:165 in  │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/starlette/middleware/base.py:151 in  │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/starlette/middleware/cors.py:83 in _ │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/venv/lib/python3.9/site-packages/starlette/middleware/gzip.py:24 in _ │
│                                                                                                           │
│ ❱ 260 │   │   │   result = postprocessing.run_extras(extras_mode=0, image_folder="", input_dir="", output │
│   261 │   │   return models.ResProcessImage(image=helpers.encode_pil_to_base64(result[0][0]), html_info=r │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/modules/postprocessing.py:122 in run_extras                           │
│                                                                                                           │
│   121 │                                                                                                   │
│ ❱ 122 │   return run_postprocessing(extras_mode, image, image_folder, input_dir, output_dir, show_extras_ │
│   123                                                                                                     │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/modules/postprocessing.py:93 in run_postprocessing                    │
│                                                                                                           │
│    92 │   │   image.close()                                                                               │
│ ❱  93 │   scripts.scripts_postproc.postprocess(processed_images, args)                                    │
│    94                                                                                                     │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/modules/scripts_postprocessing.py:134 in postprocess                  │
│                                                                                                           │
│   133 │   │   │   shared.log.debug(f'Postprocess: script={script.name} args={process_args}')              │
│ ❱ 134 │   │   │   script.postprocess(filenames, **process_args)                                           │
│   135                                                                                                     │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/scripts/postprocessing_video.py:44 in postprocess                     │
│                                                                                                           │
│   43 │   def postprocess(self, images, filename, video_type, duration, loop, pad, interpolate, scale, cha │
│ ❱ 44 │   │   filename = filename.strip()                                                                  │
│   45 │   │   if video_type == 'None' or len(filename) == 0 or images is None or len(images) < 2:          │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'strip'
│   259 │   │   with self.queue_lock:                                                                       │
│ ❱ 260 │   │   │   result = postprocessing.run_extras(extras_mode=0, image_folder="", input_dir="", output │
│   261 │   │   return models.ResProcessImage(image=helpers.encode_pil_to_base64(result[0][0]), html_info=r │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/modules/postprocessing.py:122 in run_extras                           │
│                                                                                                           │
│   121 │                                                                                                   │
│ ❱ 122 │   return run_postprocessing(extras_mode, image, image_folder, input_dir, output_dir, show_extras_ │
│   123                                                                                                     │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/modules/postprocessing.py:93 in run_postprocessing                    │
│                                                                                                           │
│    92 │   │   image.close()                                                                               │
│ ❱  93 │   scripts.scripts_postproc.postprocess(processed_images, args)                                    │
│    94                                                                                                     │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/modules/scripts_postprocessing.py:134 in postprocess                  │
│                                                                                                           │
│   133 │   │   │   shared.log.debug(f'Postprocess: script={script.name} args={process_args}')              │
│ ❱ 134 │   │   │   script.postprocess(filenames, **process_args)                                           │
│   135                                                                                                     │
│                                                                                                           │
│ /home/sensorium/workspace/automatic/scripts/postprocessing_video.py:44 in postprocess                     │
│                                                                                                           │
│   43 │   def postprocess(self, images, filename, video_type, duration, loop, pad, interpolate, scale, cha │
│ ❱ 44 │   │   filename = filename.strip()                                                                  │
│   45 │   │   if video_type == 'None' or len(filename) == 0 or images is None or len(images) < 2:          │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'strip'

Backend

Original

Branch

Dev

Model

Other

Acknowledgements

vladmandic commented 5 months ago

fixed in dev. i've also added cli/simple-upscale.py script that can be used for quick upscales/tests.