Spaces:
Runtime error
Runtime error
Martin Tomov
commited on
@spaces.GPU yolo_utils.py
Browse files- yolo_utils.py +4 -3
yolo_utils.py
CHANGED
|
@@ -3,16 +3,17 @@ import torch
|
|
| 3 |
import numpy as np
|
| 4 |
import cv2
|
| 5 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 6 |
|
| 7 |
REPO_ID = "idml/Yolov8_InsectDetect"
|
| 8 |
FILENAME = "insectYolo.pt"
|
| 9 |
|
| 10 |
-
|
| 11 |
# Ensure you have the model file
|
| 12 |
model = YOLO(hf_hub_download(repo_id=REPO_ID, filename=FILENAME))
|
|
|
|
|
|
|
| 13 |
def yolo_processimage(image):
|
| 14 |
results = model(source=image,
|
| 15 |
-
|
| 16 |
rgb_image = cv2.cvtColor(results[0].plot(), cv2.COLOR_BGR2RGB)
|
| 17 |
return rgb_image
|
| 18 |
-
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
import cv2
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
+
import spaces
|
| 7 |
|
| 8 |
REPO_ID = "idml/Yolov8_InsectDetect"
|
| 9 |
FILENAME = "insectYolo.pt"
|
| 10 |
|
|
|
|
| 11 |
# Ensure you have the model file
|
| 12 |
model = YOLO(hf_hub_download(repo_id=REPO_ID, filename=FILENAME))
|
| 13 |
+
|
| 14 |
+
@spaces.GPU
|
| 15 |
def yolo_processimage(image):
|
| 16 |
results = model(source=image,
|
| 17 |
+
conf=0.2, device='cpu')
|
| 18 |
rgb_image = cv2.cvtColor(results[0].plot(), cv2.COLOR_BGR2RGB)
|
| 19 |
return rgb_image
|
|
|