Spaces:
Runtime error
Runtime error
Download detectObjects.py from krishanwalia30/ExtractObjectsFromImages: direct link, hf CLI and curl.
- Browser
- Download file 389 Bytes
-
https://huggingface.co/spaces/krishanwalia30/ExtractObjectsFromImages/resolve/main/detectObjects.py
- Command line
-
hf download hf://spaces/krishanwalia30/ExtractObjectsFromImages/detectObjects.py
-
curl -L -o detectObjects.py https://huggingface.co/spaces/krishanwalia30/ExtractObjectsFromImages/resolve/main/detectObjects.py
389 Bytes
| import ultralytics | |
| from ultralytics import YOLO | |
| model = YOLO('yolov8n.pt') | |
| def detected_objects(filename:str): | |
| results = model.predict(source=filename, conf=0.25) | |
| categories = results[0].names | |
| dc = [] | |
| for i in range(len(results[0])): | |
| cat = results[0].boxes[i].cls | |
| dc.append(categories[int(cat)]) | |
| print(dc) | |
| return results, dc | |