Spaces:
Sleeping
Sleeping
Download Models_Conversion/base_model_yolo.py from junaid17/DamageLensAI: direct link, hf CLI and curl.
- Browser
- Download file 664 Bytes
-
https://huggingface.co/spaces/junaid17/DamageLensAI/resolve/main/Models_Conversion/base_model_yolo.py
- Command line
-
hf download hf://spaces/junaid17/DamageLensAI/Models_Conversion/base_model_yolo.py
-
curl -L -o base_model_yolo.py https://huggingface.co/spaces/junaid17/DamageLensAI/resolve/main/Models_Conversion/base_model_yolo.py
664 Bytes
| import os | |
| from ultralytics import YOLO | |
| from huggingface_hub import hf_hub_download | |
| def load_yolo_model_from_hf( | |
| repo_id: str = "junaid17/Yolo_Model", | |
| filename: str = "damage_detector.pt", | |
| hf_token: str = None, | |
| ) -> YOLO: | |
| """ | |
| Downloads and loads a trained Ultralytics YOLO model from Hugging Face Hub. | |
| """ | |
| print(f"Downloading YOLO checkpoint '{filename}' from Hugging Face repo '{repo_id}'...") | |
| checkpoint_path = hf_hub_download( | |
| repo_id=repo_id, | |
| filename=filename, | |
| token=hf_token | |
| ) | |
| model = YOLO(checkpoint_path) | |
| print("✅ YOLO model loaded successfully.") | |
| return model |