File size: 788 Bytes
5e0a271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os

from ultralytics import YOLO
import glob
# Load your trained segmentation model
model = YOLO('runs/segment/train/weights/last.pt')
IN_DIR = "/home/quentin/repos/yolov11-segmentation_earth-worm/data/yolo_split/images/val"
# Predict on an image, replace with your image path or URL

files = sorted(glob.glob(f"{IN_DIR}/*.jpg"))
for f in files:

    results = model(f)
# Save results, this includes saving masks
    os.makedirs("results/", exist_ok=True)
    results[0].save(f"results/result_{os.path.basename(f)}")
#
# for f in sorted(glob.glob(f"{IN_DIR}/2024-10-08/*.jpg")):
#     results = model(f)
#     # Save results, this includes saving masks
#     os.makedirs("results/2024-10-08", exist_ok=True)
#     results[0].save(f"results/2024-10-08/result_{os.path.basename(f)}")