Skip to content

Commit

Permalink
feat: box_inference_allTestImages 3type_box_detection #22
Browse files Browse the repository at this point in the history
  • Loading branch information
MCG committed Nov 16, 2024
1 parent 4fd9ef1 commit 705899c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions box_detect/yolov11_inference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
from ultralytics import YOLO

# Load the YOLO model
model = YOLO("/data/ephemeral/home/MCG/runs/detect/train/weights/best.pt")

# Define the root directory containing the DCM folder
root_dir = "/data/ephemeral/home/MCG/data/test/DCM"

# Iterate through each patient folder in the DCM directory
for patient_id in os.listdir(root_dir):
patient_dir = os.path.join(root_dir, patient_id)
if os.path.isdir(patient_dir):
# Process each image in the patient's folder
for image_file in os.listdir(patient_dir):
if image_file.endswith(".png"): # Check if it's a PNG image
image_path = os.path.join(patient_dir, image_file)
print(f"Running inference on: {image_path}")
# Run inference and save results
model.predict(image_path, save=True, imgsz=2048, conf=0.5,max_det=3,augment=True)

0 comments on commit 705899c

Please sign in to comment.