Spaces:
Sleeping
Sleeping
huh
Browse files
app.py
CHANGED
@@ -42,14 +42,13 @@ with gr.Blocks() as demo:
|
|
42 |
# parameter name is also shown as parameter name in API #
|
43 |
# Note: parameter type has to be manually handled when called from API #
|
44 |
# ==================================================================== #
|
45 |
-
def proc_image(
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
image = Image.open(BytesIO(base64.b64decode(image)))
|
53 |
else:
|
54 |
raise ValueError("Unsupported Image Type")
|
55 |
|
@@ -77,7 +76,7 @@ with gr.Blocks() as demo:
|
|
77 |
value=None,
|
78 |
image_mode="RGB",
|
79 |
sources="upload",
|
80 |
-
type="
|
81 |
label="Input",
|
82 |
show_label=True,
|
83 |
show_download_button=False,
|
@@ -166,6 +165,8 @@ with gr.Blocks() as demo:
|
|
166 |
show_progress="hidden",
|
167 |
show_api=True,
|
168 |
api_name="resizeImage",
|
|
|
|
|
169 |
)
|
170 |
|
171 |
demo.launch(show_error=True)
|
|
|
42 |
# parameter name is also shown as parameter name in API #
|
43 |
# Note: parameter type has to be manually handled when called from API #
|
44 |
# ==================================================================== #
|
45 |
+
def proc_image(image: str, width: int, height: int) -> list[str, Image.Image]:
|
46 |
+
|
47 |
+
if isinstance(image, str):
|
48 |
+
if os.path.isfile(image):
|
49 |
+
image = Image.open(image)
|
50 |
+
else:
|
51 |
+
image = Image.open(BytesIO(base64.b64decode(image)))
|
|
|
52 |
else:
|
53 |
raise ValueError("Unsupported Image Type")
|
54 |
|
|
|
76 |
value=None,
|
77 |
image_mode="RGB",
|
78 |
sources="upload",
|
79 |
+
type="filepath",
|
80 |
label="Input",
|
81 |
show_label=True,
|
82 |
show_download_button=False,
|
|
|
165 |
show_progress="hidden",
|
166 |
show_api=True,
|
167 |
api_name="resizeImage",
|
168 |
+
preprocess=False,
|
169 |
+
postprocess=False,
|
170 |
)
|
171 |
|
172 |
demo.launch(show_error=True)
|