File size: 959 Bytes
9734859
 
 
 
 
 
 
8892546
9734859
 
a0b12ab
9734859
 
 
 
 
 
 
 
e95977f
dd82563
9734859
dd82563
 
9734859
dd82563
 
 
9734859
 
dd82563
9734859
 
 
dd82563
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
import streamlit as st
import tensorflow as tf
import keras
import numpy as np
from PIL import Image

# Load the model
model = tf.keras.models.load_model("modelo_celeba_50e.h5", compile=False)

# Create a title
st.title("Clasificador de rostros")

# Add a button to upload an image
uploaded_image = st.file_uploader("Cargar imagen")

# If an image is uploaded, process it
if uploaded_image is not None:

    # Convert the uploaded file to a PIL Image object
    image = Image.open(uploaded_image).convert('RGB')
    image = image.resize((178, 218))

    # Display the uploaded image
    st.image(image, caption="Imagen cargada", use_column_width=True)

    # Convert the PIL Image object to a NumPy array
    image_array = np.array(image) / 255.0
    image_array = np.expand_dims(image_array, axis=0)

    # Make a prediction
    prediction = model.predict(image_array)

    # Display the prediction
    st.write("La predicción es:")
    st.write(prediction)