Spaces:
Runtime error
Runtime error
Update gradio.app.py
Browse files- gradio.app.py +5 -28
gradio.app.py
CHANGED
|
@@ -2,32 +2,9 @@ import gradio as gr
|
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
executable_path = "./build/yolov5s-tt100k"
|
| 9 |
-
model_path = "./yolov5s_tt100k_opt_fp32.tmfile"
|
| 10 |
-
output_image_path = "yolov5s-tt100k.out.jpg"
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# Check if the output image was created
|
| 16 |
-
if os.path.exists(output_image_path):
|
| 17 |
-
return output_image_path
|
| 18 |
-
else:
|
| 19 |
-
raise FileNotFoundError("The output image was not found.")
|
| 20 |
-
|
| 21 |
-
# Create a Gradio interface
|
| 22 |
-
iface = gr.Interface(
|
| 23 |
-
fn=run_yolov5s_tt100k,
|
| 24 |
-
inputs=gr.components.Image(),
|
| 25 |
-
outputs=gr.components.Image(),
|
| 26 |
-
title="YOLOv5s-TT100K Object Detection",
|
| 27 |
-
description="Upload an image to run object detection using YOLOv5s-TT100K.",
|
| 28 |
-
flagging_dir="/tmp/flagged" # Set a writable directory for flagging
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
# Run the Gradio app
|
| 32 |
-
if __name__ == "__main__":
|
| 33 |
-
iface.launch()
|
|
|
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
def run_yolov5s(image_filepath):
|
| 6 |
+
result = subprocess.run(["./yolov5s-tt100k", "-m", "./yolov5s_tt100k_opt_fp32.tmfile", "-i", image_filepath], capture_output=True, text=True)
|
| 7 |
+
return "yolov5s-tt100k.out.jpg", result.stdout
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
iface = gr.Interface(fn=run_yolov5s, inputs=gr.Image(type="filepath"), outputs=[gr.Image(type="filepath"), gr.Textbox()])
|
| 10 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|