-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: box_inference_allTestImages 3type_box_detection #22
- Loading branch information
MCG
committed
Nov 16, 2024
1 parent
4fd9ef1
commit 705899c
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |