Spaces:
Sleeping
Sleeping
Updated pipeline to address the cases where no face is detected
Browse files
app.py
CHANGED
@@ -76,9 +76,12 @@ if img_file_buffer is not None:
|
|
76 |
# To read image file buffer as a PIL Image:
|
77 |
img = Image.open(img_file_buffer)
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
76 |
# To read image file buffer as a PIL Image:
|
77 |
img = Image.open(img_file_buffer)
|
78 |
|
79 |
+
detected_face = mtcnn2(img)
|
80 |
+
if detected_face is None:
|
81 |
+
st.write("No Face Detected")
|
82 |
+
else:
|
83 |
+
detected_face = Image.fromarray(detected_face.numpy().transpose(1, 2, 0).astype(np.uint8))
|
84 |
+
st.image(detected_face, caption="Detected Face")
|
85 |
+
embeddings = extract_features(img)
|
86 |
+
bmi = round(lr.predict([embeddings])[0], 2) - 4
|
87 |
+
st.write(f"Your BMI is {bmi}")
|