kmnis commited on
Commit
23380c2
1 Parent(s): dd7ee52

Updated pipeline to address the cases where no face is detected

Browse files
Files changed (1) hide show
  1. app.py +9 -6
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
- detected_image = Image.fromarray(mtcnn2(img).numpy().transpose(1, 2, 0).astype(np.uint8))
80
- st.image(detected_image, caption="Detected Face")
81
-
82
- embeddings = extract_features(img)
83
- bmi = round(lr.predict([embeddings])[0], 2) - 4
84
- st.write(f"Your BMI is {bmi}")
 
 
 
 
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}")