Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -18,10 +18,10 @@ def predict_and_draw(input_image):
|
|
18 |
#input_image=ImageToCV(input_image)
|
19 |
|
20 |
instructions = model.predict(input_image)
|
21 |
-
img = cv2.imread(input_image
|
22 |
img = cv2.resize(img, (IMAGE_SIZE, IMAGE_SIZE))
|
23 |
# 創建一個新的白色圖像
|
24 |
-
image = np.zeros((IMAGE_SIZE, IMAGE_SIZE), dtype=np.uint8)
|
25 |
|
26 |
# 執行每條繪圖指令
|
27 |
for instruction in instructions:
|
@@ -30,13 +30,13 @@ def predict_and_draw(input_image):
|
|
30 |
import traceback
|
31 |
traceback.print_exc()
|
32 |
#image=CVtoImage(image)
|
33 |
-
return img, image, "\n".join(instructions)
|
34 |
|
35 |
|
36 |
iface = gr.Interface(
|
37 |
fn=predict_and_draw,
|
38 |
inputs=gr.Image(type="filepath"),
|
39 |
-
outputs=[ gr.Image(
|
40 |
title="Image to Drawing Instructions",
|
41 |
description="Upload an image, and the model will predict drawing instructions based on it."
|
42 |
)
|
|
|
18 |
#input_image=ImageToCV(input_image)
|
19 |
|
20 |
instructions = model.predict(input_image)
|
21 |
+
img = cv2.imread(input_image)
|
22 |
img = cv2.resize(img, (IMAGE_SIZE, IMAGE_SIZE))
|
23 |
# 創建一個新的白色圖像
|
24 |
+
image = np.zeros((IMAGE_SIZE, IMAGE_SIZE, 3), dtype=np.uint8)
|
25 |
|
26 |
# 執行每條繪圖指令
|
27 |
for instruction in instructions:
|
|
|
30 |
import traceback
|
31 |
traceback.print_exc()
|
32 |
#image=CVtoImage(image)
|
33 |
+
return CVtoImage(img), CVtoImage(image), "\n".join(instructions)
|
34 |
|
35 |
|
36 |
iface = gr.Interface(
|
37 |
fn=predict_and_draw,
|
38 |
inputs=gr.Image(type="filepath"),
|
39 |
+
outputs=[ gr.Image(label="Input Image"), gr.Image(label="Output Image"), gr.Textbox(label="Generated Instructions" ,show_copy_button=True)],
|
40 |
title="Image to Drawing Instructions",
|
41 |
description="Upload an image, and the model will predict drawing instructions based on it."
|
42 |
)
|