Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
| 3 |
import spaces
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
def attempt_download_from_hub(repo_id, hf_token=None):
|
| 8 |
# https://github.com/fcakyon/yolov5-pip/blob/main/yolov5/utils/downloads.py
|
|
@@ -22,7 +21,6 @@ def attempt_download_from_hub(repo_id, hf_token=None):
|
|
| 22 |
except (RepositoryNotFoundError, HFValidationError):
|
| 23 |
return None
|
| 24 |
|
| 25 |
-
|
| 26 |
@spaces.GPU(duration=200)
|
| 27 |
def LeYOLO_inference(image, model_id, image_size, conf_threshold, iou_threshold):
|
| 28 |
MODEL_PATH = attempt_download_from_hub(model_id)
|
|
@@ -32,7 +30,6 @@ def LeYOLO_inference(image, model_id, image_size, conf_threshold, iou_threshold)
|
|
| 32 |
annotated_image = cv2.cvtColor(annotated_image, cv2.COLOR_RGB2BGR)
|
| 33 |
return annotated_image
|
| 34 |
|
| 35 |
-
|
| 36 |
def app():
|
| 37 |
with gr.Blocks():
|
| 38 |
with gr.Row():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from ultralytics import YOLO
|
| 3 |
import spaces
|
| 4 |
+
import cv2
|
|
|
|
| 5 |
|
| 6 |
def attempt_download_from_hub(repo_id, hf_token=None):
|
| 7 |
# https://github.com/fcakyon/yolov5-pip/blob/main/yolov5/utils/downloads.py
|
|
|
|
| 21 |
except (RepositoryNotFoundError, HFValidationError):
|
| 22 |
return None
|
| 23 |
|
|
|
|
| 24 |
@spaces.GPU(duration=200)
|
| 25 |
def LeYOLO_inference(image, model_id, image_size, conf_threshold, iou_threshold):
|
| 26 |
MODEL_PATH = attempt_download_from_hub(model_id)
|
|
|
|
| 30 |
annotated_image = cv2.cvtColor(annotated_image, cv2.COLOR_RGB2BGR)
|
| 31 |
return annotated_image
|
| 32 |
|
|
|
|
| 33 |
def app():
|
| 34 |
with gr.Blocks():
|
| 35 |
with gr.Row():
|