Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,11 +8,14 @@ model_path = MODEL_PATHS["YOLOv8n"]
|
|
| 8 |
model = YOLO(model_path)
|
| 9 |
|
| 10 |
# ---------- Detection Functions ----------
|
|
|
|
| 11 |
def detect_image_fn(image, confidence):
|
| 12 |
if image is None:
|
| 13 |
return None
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def detect_video_fn(video_file, confidence):
|
| 18 |
if video_file is None:
|
|
|
|
| 8 |
model = YOLO(model_path)
|
| 9 |
|
| 10 |
# ---------- Detection Functions ----------
|
| 11 |
+
|
| 12 |
def detect_image_fn(image, confidence):
|
| 13 |
if image is None:
|
| 14 |
return None
|
| 15 |
+
image_np = np.array(image) # Convert PIL to NumPy
|
| 16 |
+
results = model.predict(image_np, conf=confidence, verbose=False)
|
| 17 |
+
annotated = results[0].plot()
|
| 18 |
+
return annotated
|
| 19 |
|
| 20 |
def detect_video_fn(video_file, confidence):
|
| 21 |
if video_file is None:
|