Spaces:
Sleeping
Sleeping
Update modeles/detect_notAllowedObjects.py
Browse files
modeles/detect_notAllowedObjects.py
CHANGED
|
@@ -3,9 +3,18 @@ import cv2
|
|
| 3 |
from ultralytics import YOLO
|
| 4 |
|
| 5 |
#Ici, nous devons détecter si un/plusieurs objets suspect met en danger le document envoyé par l'utilisateur à son contact
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def detect_objects_in_folder(folder_path):
|
| 8 |
-
model =
|
| 9 |
conf_threshold = 0.4 #on configure notre seuil de confiance à 0.4 donc si le modèle est sur à 40% que l'objet est tel objet alors la detection est validée
|
| 10 |
|
| 11 |
# Objets interdits selon les classes COCO (Common Objects in Context)
|
|
|
|
| 3 |
from ultralytics import YOLO
|
| 4 |
|
| 5 |
#Ici, nous devons détecter si un/plusieurs objets suspect met en danger le document envoyé par l'utilisateur à son contact
|
| 6 |
+
def get_model():
|
| 7 |
+
global model
|
| 8 |
+
if model is None:
|
| 9 |
+
# On force le chargement à partir du dossier local
|
| 10 |
+
print("On force le chargement à partir du dossier local")
|
| 11 |
+
model_path = os.path.join(os.path.dirname(__file__), "../yolov8n.pt")
|
| 12 |
+
print("On charge le model")
|
| 13 |
+
model = YOLO(model_path)
|
| 14 |
+
return model
|
| 15 |
|
| 16 |
def detect_objects_in_folder(folder_path):
|
| 17 |
+
model = get_model() # on charge notre modèle YOLO
|
| 18 |
conf_threshold = 0.4 #on configure notre seuil de confiance à 0.4 donc si le modèle est sur à 40% que l'objet est tel objet alors la detection est validée
|
| 19 |
|
| 20 |
# Objets interdits selon les classes COCO (Common Objects in Context)
|