Y a t'il moyen de contourner l'erreur matériel sans installé les paquets proprio ?
[W829 11:01:36.846841501 NNPACK.cpp:56] Could not initialize NNPACK! Reason: Unsupported hardware.
[W829 11:01:36.848640565 NNPACK.cpp:56] Could not initialize NNPACK! Reason: Unsupported hardware.
[W829 11:01:36.874412321 NNPACK.cpp:56] Could not initialize NNPACK! Reason: Unsupported hardware.
[W829 11:01:36.881654744 NNPACK.cpp:56] Could not initialize NNPACK! Reason: Unsupported hardware.
image 1/1 /run/media/philippe/Seagate Expansion Drive/2020-08-06_06-36-45_000 (2021-01-21T20_13_36.564) (2022-05-23T14_46_30.554).jpeg: 384x640 1 bird, 1235.9ms
Speed: 5.0ms preprocess, 1235.9ms inference, 3.5ms postprocess per image at shape (1, 3, 384, 640)
import os
import cv2
from ultralytics import YOLO
# --- Configuration des dossiers ---
input_folder = "images/"
output_folder = "images_avec_ecureuils/"
os.makedirs(output_folder, exist_ok=True)
# --- Chargement du modèle (YOLOv5 ou YOLOv8 selon ton installation) ---
model = YOLO("
yolov5s.pt") # ou "
yolov8n.pt" si tu utilises la V8
# Seuil minimal de confiance pour la détection
CONFIDENCE_THRESHOLD = 0.3
# --- Boucle de traitement ---
for filename in os.listdir(input_folder):
if not filename.lower().endswith((".jpg", ".jpeg", ".png")):
continue
path_in = os.path.join(input_folder, filename)
img = cv2.imread(path_in)
results = model(path_in)[0] # on ne garde que le premier résultat
# Vérifier chaque boîte détectée
for box in results.boxes:
cls_id, conf = int(box.cls[0]), float(box.conf[0])
label = model.names[cls_id].lower()
# Si c'est un écureuil et que la confiance est suffisante
if "squirrel" in label and conf >= CONFIDENCE_THRESHOLD:
x1, y1, x2, y2 = map(int, box.xyxy[0])
# Option 1 : simplement copier l'image entière
cv2.imwrite(os.path.join(output_folder, filename), img)
# Option 2 : recadrer uniquement l'écureuil
# squirrel_crop = img[y1:y2, x1:x2]
# cv2.imwrite(os.path.join(output_folder, "crop_" + filename), squirrel_crop)
# Option 3 : dessiner la boîte et sauvegarder
# annotated = img.copy()
# cv2.rectangle(annotated, (x1,y1), (x2,y2), (0,255,0), 2)
# cv2.putText(annotated, f"{label} {conf:.2f}", (x1,y1-10),
# cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 1)
# cv2.imwrite(os.path.join(output_folder, "boxed_" + filename), annotated)
break # on sort dès qu'on a trouvé un écureuil