Download app.py from iamsharmanish/Object_Detection_Project_SEM6: direct link, hf CLI and curl.
- Browser
- Download file 684 Bytes
-
https://huggingface.co/spaces/iamsharmanish/Object_Detection_Project_SEM6/resolve/main/app.py
- Command line
-
hf download hf://spaces/iamsharmanish/Object_Detection_Project_SEM6/app.py
-
curl -L -o app.py https://huggingface.co/spaces/iamsharmanish/Object_Detection_Project_SEM6/resolve/main/app.py
684 Bytes
| import streamlit as st | |
| from ultralytics import YOLO | |
| import cv2 | |
| from PIL import Image | |
| import numpy as np | |
| model = YOLO('yolov8n.pt') | |
| st.title("Object Detection using YOLOv8") | |
| uploaded_file = st.file_uploader("Choose an image...", type=['jpg', 'png']) | |
| if uploaded_file is not None: | |
| image = Image.open(uploaded_file) | |
| st.image(image, caption='Uploaded Image.', use_column_width=True) | |
| if st.button('Detect Objects'): | |
| image_np = np.array(image) | |
| results = model.predict(source=image_np, save=False) | |
| for r in results: | |
| im_array = r.plot() # Draw bounding boxes | |
| st.image(im_array, caption='Detection Output', use_column_width=True) | |