Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import streamlit as st
|
3 |
+
import tensorflow as tf
|
4 |
+
import keras
|
5 |
+
import numpy as np
|
6 |
+
from PIL import Image
|
7 |
+
|
8 |
+
# Load the model
|
9 |
+
model = tf.keras.models.load_model("/content/modelo_celeba_50e.h5", compile=False)
|
10 |
+
|
11 |
+
# Create a title
|
12 |
+
st.title("Clasificador de imágenes de CelebA")
|
13 |
+
|
14 |
+
# Add a button to upload an image
|
15 |
+
uploaded_image = st.file_uploader("Cargar imagen")
|
16 |
+
|
17 |
+
# If an image is uploaded, process it
|
18 |
+
if uploaded_image is not None:
|
19 |
+
|
20 |
+
# Convert the uploaded file to a PIL Image object
|
21 |
+
image = Image.open('/content/Uriel_foto.png').convert('RGB')
|
22 |
+
image = image.resize((178,218))
|
23 |
+
|
24 |
+
# Convert the PIL Image object to a NumPy array
|
25 |
+
image = np.array(image)/255.0
|
26 |
+
|
27 |
+
image = np.expand_dims(image,axis=0)
|
28 |
+
|
29 |
+
# Make a prediction
|
30 |
+
prediction = model.predict(image)
|
31 |
+
|
32 |
+
# Display the prediction
|
33 |
+
st.write("La predicción es:")
|
34 |
+
st.write(prediction)
|