Spaces:
Running
on
Zero
Running
on
Zero
fix a bug
Browse files
Rodin.py
CHANGED
@@ -111,7 +111,7 @@ def load_image(img_path):
|
|
111 |
try:
|
112 |
image = Image.open(img_path)
|
113 |
except PIL.UnidentifiedImageError as e:
|
114 |
-
raise gr.Error("
|
115 |
|
116 |
# 按比例缩小图像到长度为1024
|
117 |
width, height = image.size
|
@@ -142,6 +142,9 @@ class Generator:
|
|
142 |
self.processed_image = None
|
143 |
|
144 |
def preprocess(self, prompt, image_path, processed_image , task_uuid=""):
|
|
|
|
|
|
|
145 |
if processed_image and prompt and (not task_uuid):
|
146 |
log("INFO", "Using cached image and prompt...")
|
147 |
return prompt, processed_image
|
@@ -171,7 +174,7 @@ class Generator:
|
|
171 |
raise gr.Error("Error in image preprocessing, please try again.")
|
172 |
elif preprocess_response.get("statusCode") == 400:
|
173 |
if "InvalidFile.Content" in preprocess_response.get("message"):
|
174 |
-
raise gr.Error("
|
175 |
else:
|
176 |
log("ERROR", f"Error in image preprocessing: {preprocess_response}")
|
177 |
raise gr.Error("Busy connection, please try again later.")
|
|
|
111 |
try:
|
112 |
image = Image.open(img_path)
|
113 |
except PIL.UnidentifiedImageError as e:
|
114 |
+
raise gr.Error("Unsupported Image Format")
|
115 |
|
116 |
# 按比例缩小图像到长度为1024
|
117 |
width, height = image.size
|
|
|
142 |
self.processed_image = None
|
143 |
|
144 |
def preprocess(self, prompt, image_path, processed_image , task_uuid=""):
|
145 |
+
if image_path == None:
|
146 |
+
raise gr.Error("Please upload an image first")
|
147 |
+
|
148 |
if processed_image and prompt and (not task_uuid):
|
149 |
log("INFO", "Using cached image and prompt...")
|
150 |
return prompt, processed_image
|
|
|
174 |
raise gr.Error("Error in image preprocessing, please try again.")
|
175 |
elif preprocess_response.get("statusCode") == 400:
|
176 |
if "InvalidFile.Content" in preprocess_response.get("message"):
|
177 |
+
raise gr.Error("Unsupported Image Format")
|
178 |
else:
|
179 |
log("ERROR", f"Error in image preprocessing: {preprocess_response}")
|
180 |
raise gr.Error("Busy connection, please try again later.")
|
app.py
CHANGED
@@ -108,7 +108,7 @@ def clear_task(task_input=None):
|
|
108 |
[cache_task_uuid, block_prompt, block_prompt_hint, fake3d]
|
109 |
"""
|
110 |
log("INFO", "Clearing task...")
|
111 |
-
return "", "", [], "assets/white_image.png"
|
112 |
|
113 |
def clear_task_id():
|
114 |
return ""
|
@@ -177,7 +177,7 @@ with gr.Blocks() as demo:
|
|
177 |
examples=example,
|
178 |
fn=clear_task,
|
179 |
inputs=[block_image],
|
180 |
-
outputs=[cache_task_uuid, block_prompt, block_prompt_hint, fake3d],
|
181 |
run_on_click=True,
|
182 |
cache_examples=True,
|
183 |
label="Examples"
|
|
|
108 |
[cache_task_uuid, block_prompt, block_prompt_hint, fake3d]
|
109 |
"""
|
110 |
log("INFO", "Clearing task...")
|
111 |
+
return "", "", "", [], "assets/white_image.png"
|
112 |
|
113 |
def clear_task_id():
|
114 |
return ""
|
|
|
177 |
examples=example,
|
178 |
fn=clear_task,
|
179 |
inputs=[block_image],
|
180 |
+
outputs=[cache_image_base64, cache_task_uuid, block_prompt, block_prompt_hint, fake3d],
|
181 |
run_on_click=True,
|
182 |
cache_examples=True,
|
183 |
label="Examples"
|