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)