Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,12 @@ from huggingface_hub import hf_hub_download
|
|
3 |
import os
|
4 |
import cv2 # Import OpenCV
|
5 |
|
6 |
-
# Function to download models from Hugging Face
|
7 |
def download_models(model_id):
|
8 |
# Check if the model file exists locally
|
9 |
-
local_model_path = "./
|
10 |
if not os.path.exists(local_model_path):
|
11 |
# Download the model from Hugging Face if it doesn't exist locally
|
12 |
-
hf_hub_download(
|
13 |
return local_model_path
|
14 |
|
15 |
|
@@ -20,7 +19,7 @@ def yolov9_inference(img):
|
|
20 |
:return: Output image with detections.
|
21 |
"""
|
22 |
# Load the model
|
23 |
-
model_path = download_models("
|
24 |
# Assuming you're using a YOLOv9 model from Ultralytics, you would typically use their library to load the model
|
25 |
model = cv2.dnn.readNetFromDarknet(model_path)
|
26 |
# Perform inference
|
@@ -34,7 +33,7 @@ def yolov9_inference(img):
|
|
34 |
def app():
|
35 |
return gr.Interface(
|
36 |
fn=yolov9_inference,
|
37 |
-
inputs=
|
38 |
outputs="image",
|
39 |
title="YOLOv9 Inference",
|
40 |
description="Perform object detection using the YOLOv9 model.",
|
|
|
3 |
import os
|
4 |
import cv2 # Import OpenCV
|
5 |
|
|
|
6 |
def download_models(model_id):
|
7 |
# Check if the model file exists locally
|
8 |
+
local_model_path = "./gelan-c-seg.pt"
|
9 |
if not os.path.exists(local_model_path):
|
10 |
# Download the model from Hugging Face if it doesn't exist locally
|
11 |
+
hf_hub_download(model_id, filename="gelan-c-seg.pt", local_dir="./")
|
12 |
return local_model_path
|
13 |
|
14 |
|
|
|
19 |
:return: Output image with detections.
|
20 |
"""
|
21 |
# Load the model
|
22 |
+
model_path = download_models("merve/yolov9")
|
23 |
# Assuming you're using a YOLOv9 model from Ultralytics, you would typically use their library to load the model
|
24 |
model = cv2.dnn.readNetFromDarknet(model_path)
|
25 |
# Perform inference
|
|
|
33 |
def app():
|
34 |
return gr.Interface(
|
35 |
fn=yolov9_inference,
|
36 |
+
inputs=gr.inputs.Image(type="file", label="Image"),
|
37 |
outputs="image",
|
38 |
title="YOLOv9 Inference",
|
39 |
description="Perform object detection using the YOLOv9 model.",
|