Spaces:
Sleeping
Sleeping
Actualiza app.py con la adición de threshold
Browse files
app.py
CHANGED
@@ -5,13 +5,15 @@ import gradio as gr
|
|
5 |
from ultralytics import YOLO
|
6 |
|
7 |
|
8 |
-
def predict(path:str):
|
9 |
-
model = YOLO("yolo11s.yaml")
|
10 |
model = YOLO("best.pt")
|
11 |
imagen = cv2.imread(path)
|
12 |
results = model.predict(source=path)
|
13 |
|
14 |
for r in results:
|
|
|
|
|
|
|
15 |
return r.plot()
|
16 |
|
17 |
|
|
|
5 |
from ultralytics import YOLO
|
6 |
|
7 |
|
8 |
+
def predict(path:str, threshold: float = 0.6):
|
|
|
9 |
model = YOLO("best.pt")
|
10 |
imagen = cv2.imread(path)
|
11 |
results = model.predict(source=path)
|
12 |
|
13 |
for r in results:
|
14 |
+
# Mantener solo las cajas con una probabilidad mayor al umbral
|
15 |
+
boxes = [box for box in r.boxes if box.conf > threshold]
|
16 |
+
r.boxes = boxes # Actualizar las cajas filtradas
|
17 |
return r.plot()
|
18 |
|
19 |
|