Spaces:
Sleeping
Sleeping
Commit ·
d48676a
1
Parent(s): e093b12
chore: Update app.py to save detection results as text files
Browse filesThe code changes in `app.py` modify the `inference` function to include the `--save_txt True` flag in the script command. This ensures that the detection results are saved as text files. This change improves the functionality of the application by providing additional output options for the detected GUI elements.
- app.py +15 -10
- img_to_html.py +0 -0
app.py
CHANGED
|
@@ -7,26 +7,31 @@ import os
|
|
| 7 |
|
| 8 |
def inference(img):
|
| 9 |
name_tag = uuid.uuid4()
|
| 10 |
-
script_command = f"python yolov9/detect_dual.py --source {img} --img 640 --device cpu --weights yolov9/runs/train/exp2/weights/best.pt --name {name_tag}"
|
| 11 |
-
os.system(script_command)
|
| 12 |
return f"yolov9/runs/detect/{name_tag}/{img.split('/')[-1]}"
|
| 13 |
|
|
|
|
| 14 |
title = "Sketch GUI Element Detection"
|
| 15 |
|
| 16 |
description = "This is a demo for detecting GUI elements in a sketch image. Upload a sketch image and the model will detect the GUI elements in the image."
|
| 17 |
|
| 18 |
-
img_input = gr.Image(
|
|
|
|
|
|
|
| 19 |
prediction_output = gr.Image(label="Output Image", width=640, height=640)
|
| 20 |
|
| 21 |
example_lst = [
|
| 22 |
["test_images/Shipping-1.png"],
|
| 23 |
]
|
| 24 |
|
| 25 |
-
demo = gr.Interface(
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
demo.launch(share=True)
|
|
|
|
| 7 |
|
| 8 |
def inference(img):
|
| 9 |
name_tag = uuid.uuid4()
|
| 10 |
+
script_command = f"python yolov9/detect_dual.py --source {img} --save_txt True --img 640 --device cpu --weights yolov9/runs/train/exp2/weights/best.pt --name {name_tag}"
|
| 11 |
+
os.system(script_command)
|
| 12 |
return f"yolov9/runs/detect/{name_tag}/{img.split('/')[-1]}"
|
| 13 |
|
| 14 |
+
|
| 15 |
title = "Sketch GUI Element Detection"
|
| 16 |
|
| 17 |
description = "This is a demo for detecting GUI elements in a sketch image. Upload a sketch image and the model will detect the GUI elements in the image."
|
| 18 |
|
| 19 |
+
img_input = gr.Image(
|
| 20 |
+
type="filepath", label="Upload a sketch image", width=300, height=300
|
| 21 |
+
)
|
| 22 |
prediction_output = gr.Image(label="Output Image", width=640, height=640)
|
| 23 |
|
| 24 |
example_lst = [
|
| 25 |
["test_images/Shipping-1.png"],
|
| 26 |
]
|
| 27 |
|
| 28 |
+
demo = gr.Interface(
|
| 29 |
+
fn=inference,
|
| 30 |
+
inputs=img_input,
|
| 31 |
+
outputs=prediction_output,
|
| 32 |
+
title=title,
|
| 33 |
+
description=description,
|
| 34 |
+
examples=example_lst,
|
| 35 |
+
)
|
| 36 |
|
| 37 |
+
demo.launch(share=True)
|
img_to_html.py
ADDED
|
File without changes
|