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