Spaces:
Build error
Build error
created obj detction code 1.1
Browse files- pages/Object_Detection.py +34 -0
- pages/deep.py.txt +0 -0
pages/Object_Detection.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import cv2
|
| 4 |
+
import numpy as np
|
| 5 |
+
import cvlib as cv
|
| 6 |
+
from cvlib.object_detection import draw_bbox
|
| 7 |
+
|
| 8 |
+
# Streamlit UI
|
| 9 |
+
st.title("Object Detection with YOLO")
|
| 10 |
+
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "png", "jpeg"])
|
| 11 |
+
|
| 12 |
+
if uploaded_image is not None:
|
| 13 |
+
image = Image.open(uploaded_image)
|
| 14 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 15 |
+
|
| 16 |
+
if st.button("Detect Objects"):
|
| 17 |
+
st.write("Detecting objects...")
|
| 18 |
+
|
| 19 |
+
# Convert the uploaded image to a NumPy array
|
| 20 |
+
image_np = np.array(image)
|
| 21 |
+
|
| 22 |
+
# Use YOLOv3 for object detection
|
| 23 |
+
bbox, label, conf = cv.detect_common_objects(image_np)
|
| 24 |
+
|
| 25 |
+
# Draw bounding boxes on the image
|
| 26 |
+
output_image = draw_bbox(image_np, bbox, label, conf)
|
| 27 |
+
|
| 28 |
+
# Convert the NumPy array back to an image
|
| 29 |
+
output_image = Image.fromarray(output_image)
|
| 30 |
+
|
| 31 |
+
# Display the image with bounding boxes
|
| 32 |
+
st.image(output_image, caption="Objects Detected", use_column_width=True)
|
| 33 |
+
|
| 34 |
+
st.text("Upload an image and click the 'Detect Objects' button to see object detection results using YOLO.")
|
pages/deep.py.txt
DELETED
|
File without changes
|