Spaces:
Runtime error
Runtime error
| 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)}%") | |