|
import streamlit as st |
|
from PIL import Image |
|
import pandas as pd |
|
from transformers import pipeline |
|
|
|
|
|
object_detection = pipeline("sentiment-analysis", model="chayanee/Detected_img") |
|
try: |
|
|
|
object_detection = pipeline("object-detection") |
|
|
|
|
|
st.title("Object Detection") |
|
|
|
|
|
uploaded_image = st.file_uploader("Upload an image for Detection", type=["jpg", "jpeg", "png"]) |
|
|
|
|
|
if st.button("Detection"): |
|
|
|
if uploaded_image: |
|
|
|
image = Image.open(uploaded_image) |
|
st.image(image, caption="Uploaded Image", use_column_width=True) |
|
|
|
|
|
results = object_detection(image) |
|
|
|
|
|
st.subheader("Detected Objects:") |
|
for result in results: |
|
label = result["label"] |
|
confidence = result["score"] |
|
box = result["box"] |
|
st.write(f"Detected {label} with confidence {confidence:.3f} at location {box}") |
|
|
|
except Exception as e: |
|
st.error(f"An error occurred: {e}") |
|
|