Spaces:
Runtime error
Runtime error
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) |