Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,16 +13,13 @@ def download_models(model_id):
|
|
13 |
return local_model_path
|
14 |
|
15 |
|
16 |
-
def yolov9_inference(
|
17 |
"""
|
18 |
Perform inference on an image using the YOLOv9 model.
|
19 |
|
20 |
-
:param
|
21 |
:return: Output image with detections.
|
22 |
"""
|
23 |
-
# Load the image from the file path
|
24 |
-
image = cv2.imread(img_path) # Use OpenCV to read the image
|
25 |
-
|
26 |
# Load the model
|
27 |
model_path = download_models("gelan-c-seg.pt")
|
28 |
model = cv2.dnn.readNetFromDarknet(model_path)
|
@@ -30,14 +27,15 @@ def yolov9_inference(img_path):
|
|
30 |
# Perform inference
|
31 |
# (Add your inference code here)
|
32 |
|
33 |
-
#
|
34 |
-
output_image =
|
35 |
|
36 |
return output_image
|
37 |
|
|
|
38 |
def app():
|
39 |
return gr.Interface(
|
40 |
-
yolov9_inference,
|
41 |
inputs=gr.inputs.Image(type="pil", label="Upload Image"),
|
42 |
outputs="image",
|
43 |
title="YOLOv9 Inference",
|
@@ -48,4 +46,3 @@ def app():
|
|
48 |
|
49 |
gradio_app = app()
|
50 |
gradio_app.launch(debug=True)
|
51 |
-
|
|
|
13 |
return local_model_path
|
14 |
|
15 |
|
16 |
+
def yolov9_inference(img):
|
17 |
"""
|
18 |
Perform inference on an image using the YOLOv9 model.
|
19 |
|
20 |
+
:param img: Input image.
|
21 |
:return: Output image with detections.
|
22 |
"""
|
|
|
|
|
|
|
23 |
# Load the model
|
24 |
model_path = download_models("gelan-c-seg.pt")
|
25 |
model = cv2.dnn.readNetFromDarknet(model_path)
|
|
|
27 |
# Perform inference
|
28 |
# (Add your inference code here)
|
29 |
|
30 |
+
# Placeholder for the output image
|
31 |
+
output_image = img
|
32 |
|
33 |
return output_image
|
34 |
|
35 |
+
|
36 |
def app():
|
37 |
return gr.Interface(
|
38 |
+
fn=yolov9_inference,
|
39 |
inputs=gr.inputs.Image(type="pil", label="Upload Image"),
|
40 |
outputs="image",
|
41 |
title="YOLOv9 Inference",
|
|
|
46 |
|
47 |
gradio_app = app()
|
48 |
gradio_app.launch(debug=True)
|
|