|
|
|
import os, glob
|
|
from ultralytics import YOLO
|
|
|
|
|
|
yolo_model = YOLO("runs/detect/leukemia-yolo-model/weights/best.pt")
|
|
|
|
def detect_cells_yolo(image_path, output_dir='static/marked/predict'):
|
|
|
|
os.makedirs(output_dir, exist_ok=True)
|
|
|
|
|
|
yolo_model.predict(source=image_path, save=True, project='static/marked', name='predict', exist_ok=True)
|
|
|
|
|
|
list_of_files = glob.glob(os.path.join(output_dir, '*.jpg'))
|
|
if not list_of_files:
|
|
return None
|
|
latest_file = max(list_of_files, key=os.path.getctime)
|
|
return os.path.relpath(latest_file, 'static')
|
|
|