Upload 4 files
Browse files- best.pt +3 -0
- utils.py +63 -0
- yolo11n.pt +3 -0
- yolov8n.pt +3 -0
best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62596eb4d8997efeade31373897bb8e97b3fff841c226149551a6a1dd2cb7534
|
| 3 |
+
size 6228003
|
utils.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import shutil
|
| 3 |
+
from pycocotools.coco import COCO
|
| 4 |
+
from tqdm import tqdm
|
| 5 |
+
|
| 6 |
+
def prepare_coco_three_classes(coco_json_path, images_dir, output_dir, split):
|
| 7 |
+
# Cibles :bagages
|
| 8 |
+
target_classes = ['suitcase', "backpack", "handbag"]
|
| 9 |
+
|
| 10 |
+
# Initialisation COCO
|
| 11 |
+
coco = COCO(coco_json_path)
|
| 12 |
+
|
| 13 |
+
# Récupérer les IDs de catégories pour les classes ciblées
|
| 14 |
+
class_id_map = {}
|
| 15 |
+
for idx, class_name in enumerate(target_classes):
|
| 16 |
+
cat_ids = coco.getCatIds(catNms=[class_name])
|
| 17 |
+
if cat_ids:
|
| 18 |
+
class_id_map[cat_ids[0]] = idx
|
| 19 |
+
|
| 20 |
+
print(f"Classes sélectionnées (COCO id → YOLO id) : {class_id_map}")
|
| 21 |
+
|
| 22 |
+
# Récupérer tous les IDs d’images contenant au moins une des classes cibles
|
| 23 |
+
img_ids = set()
|
| 24 |
+
for cat_id in class_id_map.keys():
|
| 25 |
+
img_ids.update(coco.getImgIds(catIds=[cat_id]))
|
| 26 |
+
|
| 27 |
+
imgs = coco.loadImgs(list(img_ids))
|
| 28 |
+
|
| 29 |
+
# Créer les dossiers de sortie
|
| 30 |
+
output_images = os.path.join(output_dir, "images", split)
|
| 31 |
+
output_labels = os.path.join(output_dir, "labels", split)
|
| 32 |
+
os.makedirs(output_images, exist_ok=True)
|
| 33 |
+
os.makedirs(output_labels, exist_ok=True)
|
| 34 |
+
|
| 35 |
+
for img in tqdm(imgs, desc=f"Processing {split}"):
|
| 36 |
+
img_path = os.path.join(images_dir, img["file_name"])
|
| 37 |
+
if not os.path.exists(img_path):
|
| 38 |
+
continue # Éviter les erreurs si l’image n’est pas là
|
| 39 |
+
|
| 40 |
+
shutil.copy(img_path, os.path.join(output_images, img["file_name"]))
|
| 41 |
+
|
| 42 |
+
# Récupérer les annotations pour les catégories cibles
|
| 43 |
+
ann_ids = coco.getAnnIds(imgIds=img['id'], catIds=list(class_id_map.keys()))
|
| 44 |
+
anns = coco.loadAnns(ann_ids)
|
| 45 |
+
|
| 46 |
+
label_path = os.path.join(output_labels, img["file_name"].replace(".jpg", ".txt"))
|
| 47 |
+
with open(label_path, "w") as f:
|
| 48 |
+
for ann in anns:
|
| 49 |
+
if ann.get("iscrowd", 0):
|
| 50 |
+
continue # On évite les annotations crowd
|
| 51 |
+
|
| 52 |
+
cat_id = ann["category_id"]
|
| 53 |
+
yolo_class_id = class_id_map[cat_id]
|
| 54 |
+
|
| 55 |
+
x, y, w, h = ann["bbox"]
|
| 56 |
+
cx = x + w / 2
|
| 57 |
+
cy = y + h / 2
|
| 58 |
+
cx /= img["width"]
|
| 59 |
+
cy /= img["height"]
|
| 60 |
+
w /= img["width"]
|
| 61 |
+
h /= img["height"]
|
| 62 |
+
|
| 63 |
+
f.write(f"{yolo_class_id} {cx:.6f} {cy:.6f} {w:.6f} {h:.6f}\n")
|
yolo11n.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0ebbc80d4a7680d14987a577cd21342b65ecfd94632bd9a8da63ae6417644ee1
|
| 3 |
+
size 5613764
|
yolov8n.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f59b3d833e2ff32e194b5bb8e08d211dc7c5bdf144b90d2c8412c47ccfc83b36
|
| 3 |
+
size 6549796
|