File size: 1,045 Bytes
ab1b805
88ed4f4
 
 
134dced
 
1d5202b
 
88ed4f4
 
 
 
 
 
 
 
 
 
0688dd1
88ed4f4
 
0688dd1
1cd3e97
 
 
88ed4f4
 
1d5202b
88ed4f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab1b805
88ed4f4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import streamlit as st
import numpy as np
import tensorflow as tf
from PIL import Image
import os

# 👇 HIER PLAATSEN (boven load_model)
MODEL_PATH = "/app/src/facial_keypoints_resnet.h5"

st.set_page_config(
    page_title="Facial Keypoints Detection",
    layout="centered"
)

@st.cache_resource
def load_model():
    return tf.keras.models.load_model(
        MODEL_PATH,
        compile=False  # 🔥 BELANGRIJK
    )


st.title("Facial Keypoints Detection")
st.write("Upload a face image and the model will predict facial keypoints.")

model = load_model()


uploaded_file = st.file_uploader(
    "Upload an image",
    type=["jpg", "png", "jpeg"]
)

if uploaded_file is not None:
    image = Image.open(uploaded_file).convert("L")
    image = image.resize((96, 96))

    st.image(image, caption="Uploaded image", width=250)

    img_array = np.array(image).reshape(1, 96, 96, 1) / 255.0
    preds = model.predict(img_array)[0]

    keypoints = preds.reshape(-1, 2)

    st.subheader("Predicted Keypoints (x, y)")
    st.write(keypoints)