Spaces:
Sleeping
Sleeping
Update package in req.txt
Browse files
app.py
CHANGED
@@ -15,10 +15,10 @@ from facenet_pytorch import MTCNN
|
|
15 |
model_file_path = 'models/bmi.h5'
|
16 |
model = tf.keras.models.load_model(model_file_path)
|
17 |
|
18 |
-
mtcnn2 = MTCNN(
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
# Preprocess the images for VGG16
|
24 |
def preprocess_image(img_path):
|
@@ -38,13 +38,13 @@ def main():
|
|
38 |
|
39 |
if img_file_buffer is not None:
|
40 |
# To read image file buffer as a PIL Image:
|
41 |
-
img = Image.open(img_file_buffer)
|
42 |
|
43 |
-
detected_image = Image.fromarray(mtcnn2(img).numpy().transpose(1, 2, 0).astype(np.uint8))
|
44 |
-
st.image(detected_image, caption="Detected Face")
|
45 |
|
46 |
embeddings = preprocess_image(img_file_buffer)
|
47 |
-
bmi =
|
48 |
st.write(f"Your BMI is {bmi}")
|
49 |
|
50 |
if __name__ == '__main__':
|
|
|
15 |
model_file_path = 'models/bmi.h5'
|
16 |
model = tf.keras.models.load_model(model_file_path)
|
17 |
|
18 |
+
# mtcnn2 = MTCNN(
|
19 |
+
# image_size=160, margin=40, min_face_size=20,
|
20 |
+
# thresholds=[0.6, 0.7, 0.7], factor=0.709, post_process=False
|
21 |
+
# )
|
22 |
|
23 |
# Preprocess the images for VGG16
|
24 |
def preprocess_image(img_path):
|
|
|
38 |
|
39 |
if img_file_buffer is not None:
|
40 |
# To read image file buffer as a PIL Image:
|
41 |
+
# img = Image.open(img_file_buffer)
|
42 |
|
43 |
+
# detected_image = Image.fromarray(mtcnn2(img).numpy().transpose(1, 2, 0).astype(np.uint8))
|
44 |
+
# st.image(detected_image, caption="Detected Face")
|
45 |
|
46 |
embeddings = preprocess_image(img_file_buffer)
|
47 |
+
bmi = model.predict(embeddings)
|
48 |
st.write(f"Your BMI is {bmi}")
|
49 |
|
50 |
if __name__ == '__main__':
|