fix: add error output for unsupported images (#2537)
* Raise Error on bad decode * Move task arg pop to try block * fix: prevent empty task from getting queued --------- Co-authored-by: Manuel Schmid <dev@mash1t.de>
This commit is contained in:
parent
4a44be36fd
commit
55e23a9374
@ -17,7 +17,7 @@ from gradio_client.documentation import document, set_documentation_group
|
|||||||
from gradio_client.serializing import ImgSerializable
|
from gradio_client.serializing import ImgSerializable
|
||||||
from PIL import Image as _Image # using _ to minimize namespace pollution
|
from PIL import Image as _Image # using _ to minimize namespace pollution
|
||||||
|
|
||||||
from gradio import processing_utils, utils
|
from gradio import processing_utils, utils, Error
|
||||||
from gradio.components.base import IOComponent, _Keywords, Block
|
from gradio.components.base import IOComponent, _Keywords, Block
|
||||||
from gradio.deprecation import warn_style_method_deprecation
|
from gradio.deprecation import warn_style_method_deprecation
|
||||||
from gradio.events import (
|
from gradio.events import (
|
||||||
@ -275,7 +275,10 @@ class Image(
|
|||||||
x, mask = x["image"], x["mask"]
|
x, mask = x["image"], x["mask"]
|
||||||
|
|
||||||
assert isinstance(x, str)
|
assert isinstance(x, str)
|
||||||
im = processing_utils.decode_base64_to_image(x)
|
try:
|
||||||
|
im = processing_utils.decode_base64_to_image(x)
|
||||||
|
except PIL.UnidentifiedImageError:
|
||||||
|
raise Error("Unsupported image type in input")
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("ignore")
|
warnings.simplefilter("ignore")
|
||||||
im = im.convert(self.image_mode)
|
im = im.convert(self.image_mode)
|
||||||
|
6
webui.py
6
webui.py
@ -29,12 +29,16 @@ def get_task(*args):
|
|||||||
|
|
||||||
return worker.AsyncTask(args=args)
|
return worker.AsyncTask(args=args)
|
||||||
|
|
||||||
def generate_clicked(task):
|
def generate_clicked(task: worker.AsyncTask):
|
||||||
import ldm_patched.modules.model_management as model_management
|
import ldm_patched.modules.model_management as model_management
|
||||||
|
|
||||||
with model_management.interrupt_processing_mutex:
|
with model_management.interrupt_processing_mutex:
|
||||||
model_management.interrupt_processing = False
|
model_management.interrupt_processing = False
|
||||||
# outputs=[progress_html, progress_window, progress_gallery, gallery]
|
# outputs=[progress_html, progress_window, progress_gallery, gallery]
|
||||||
|
|
||||||
|
if len(task.args) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
execution_start_time = time.perf_counter()
|
execution_start_time = time.perf_counter()
|
||||||
finished = False
|
finished = False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user