Spaces:
Running
Running
| from pathlib import Path | |
| from ultralytics import YOLO | |
| YOLO_DIR = Path(__file__).resolve().parents[1] / 'models' / 'yolo' | |
| YOLO_DIR.mkdir(parents=True, exist_ok=True) | |
| for name in ['yolov8n', 'yolov8s']: | |
| model = YOLO(f'{name}.pt') | |
| source = Path(getattr(model, 'ckpt_path', '') or '') | |
| target = YOLO_DIR / f'{name}.pt' | |
| if source.exists() and not target.exists(): | |
| target.write_bytes(source.read_bytes()) | |
| print(f'Ready: {target}') | |