Spaces:
Runtime error
Runtime error
File size: 1,158 Bytes
3065c83 800bc06 44c8a81 3065c83 800bc06 44c8a81 800bc06 44c8a81 800bc06 44c8a81 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import streamlit as st
from transformers import pipeline
from PIL import Image
import cv2
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
# Set the title and text color to dark green
st.title('R3SELL', color='darkgreen')
# Create a file input option for uploading an image
file_name = st.file_uploader("Upload an image file (JPEG, PNG, etc.)")
# Create an option to access the camera/webcam
if st.button("Take an image from camera"):
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
if ret:
cv2.imwrite('webcam_image.jpg', frame)
file_name = 'webcam_image.jpg'
# Add a text bar to add a title
image_title = st.text_input("Image Title", value="Specificity is nice!")
# Add a text bar to add a description
image_description = st.text_input("Image Description", value="(Optional)")
if file_name is not None:
col1, col2 = st.columns(2)
image = Image.open(file_name)
col1.image(image, use_column_width=True)
predictions = pipeline(image)
col2.header("Probabilities")
for p in predictions:
col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
|