Spaces:
Sleeping
Sleeping
Download app.py from Beasto/VehicleDetection: direct link, hf CLI and curl.
- Browser
- Download file 569 Bytes
-
https://huggingface.co/spaces/Beasto/VehicleDetection/resolve/main/app.py
- Command line
-
hf download hf://spaces/Beasto/VehicleDetection/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Beasto/VehicleDetection/resolve/main/app.py
569 Bytes
| from PIL import Image,ImageDraw,ImageFont | |
| import numpy as np | |
| from ultralytics import YOLO | |
| import streamlit as st | |
| model = YOLO('VehicleDetection.pt') | |
| img = st.file_uploader('Choose an Image') | |
| if img is not None: | |
| img = Image.open(img).resize((640,640)).convert('RGB') | |
| results = model(img) | |
| for result in results: | |
| for i in range(len(result.boxes.cls)): | |
| boxes = result.boxes.xyxy[i] | |
| draw = ImageDraw.Draw(img) | |
| draw.rectangle([boxes[0], boxes[1], boxes[2], boxes[3]], outline="black", width=5) | |
| st.image(img,'Detected') |