Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,6 @@ model = pipeline("image-classification", model="0x70DA/down-syndrome-classifier"
|
|
12 |
detector = dlib.get_frontal_face_detector()
|
13 |
|
14 |
# Define the prediction function
|
15 |
-
@st.experimental_memo
|
16 |
def predict(image):
|
17 |
img = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) # Convert PIL Image to NumPy array
|
18 |
faces = detector(img)
|
@@ -41,25 +40,3 @@ if uploaded_image is not None:
|
|
41 |
st.write("Classification Results:")
|
42 |
for label, score in result.items():
|
43 |
st.write(f"{label}: {score:.4f}")
|
44 |
-
|
45 |
-
# Endpoint to handle POST requests
|
46 |
-
@st.experimental_memo
|
47 |
-
def classify_from_post_request(image_data):
|
48 |
-
image = Image.open(image_data)
|
49 |
-
result = predict(image)
|
50 |
-
return result
|
51 |
-
|
52 |
-
# Main entry point for handling POST requests
|
53 |
-
if st._is_running_with_streamlit:
|
54 |
-
import streamlit as st
|
55 |
-
import io
|
56 |
-
|
57 |
-
st.title("Streamlit App with POST Request Support")
|
58 |
-
|
59 |
-
uploaded_image = st.file_uploader("Upload an image for classification", type=["jpg", "jpeg", "png"])
|
60 |
-
|
61 |
-
if uploaded_image is not None:
|
62 |
-
result = classify_from_post_request(uploaded_image)
|
63 |
-
st.write("Classification Results:")
|
64 |
-
for label, score in result.items():
|
65 |
-
st.write(f"{label}: {score:.4f}")
|
|
|
12 |
detector = dlib.get_frontal_face_detector()
|
13 |
|
14 |
# Define the prediction function
|
|
|
15 |
def predict(image):
|
16 |
img = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) # Convert PIL Image to NumPy array
|
17 |
faces = detector(img)
|
|
|
40 |
st.write("Classification Results:")
|
41 |
for label, score in result.items():
|
42 |
st.write(f"{label}: {score:.4f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|