Download tools/models_handler.py from WalidAlHassan/Planned-DA: direct link, hf CLI and curl.
- Browser
- Download file 512 Bytes
-
https://huggingface.co/WalidAlHassan/Planned-DA/resolve/main/tools/models_handler.py
- Command line
-
hf download hf://WalidAlHassan/Planned-DA/tools/models_handler.py
-
curl -L -o models_handler.py https://huggingface.co/WalidAlHassan/Planned-DA/resolve/main/tools/models_handler.py
512 Bytes
| import torch | |
| from ultralytics import YOLO | |
| class Models: | |
| def __init__(self,device=None): | |
| self.device = 'cpu' if device=='cpu' else device if device else ('cuda' if torch.cuda.is_available() else 'cpu') | |
| self.daModel = YOLO("AI_Models/DA.pt").to(self.device) | |
| self.st_orientation = YOLO("AI_Models/st_orientation.pt").to(self.device) | |
| self.exclusivity_model = YOLO("AI_Models/exclusivity.pt").to(self.device) | |
| if 'cuda' in self.device: | |
| torch.cuda.empty_cache() |