File size: 1,164 Bytes
a31ce15
9e7100a
35203cd
7bde0d2
ec94335
8e1216a
7bde0d2
da6c3e3
a31ce15
f6511a9
 
 
 
 
 
 
 
 
 
04de8b3
b35746e
c81cf2a
 
987de3d
ec94335
57ecf45
94c3608
cfe1092
 
fd4da82
443069c
d4b1d89
04de8b3
 
7bde0d2
3cf8dc5
68f9cb7
9e7100a
3cf8dc5
443069c
04de8b3
68f9cb7
9e7100a
3cf8dc5
68f9cb7
3cf8dc5
 
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
48
import streamlit as st
from  PIL import Image
from io import BytesIO
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np

model = tf.keras.models.load_model('modelo.h5')

labels = ['T-shirt/top',
 'Trouser',
 'Pullover',
 'Dress',
 'Coat',
 'Sandal',
 'Shirt',
 'Sneaker',
 'Bag',
 'Ankle boot']

file = st.file_uploader("Por favor suba una imagen de una prenda de ropa (jpg, png, jpeg)", type=['jpg','png','jpeg'])
if file is not None:
    bytes_data = file.read()
    x = np.array(Image.open(BytesIO(bytes_data)).convert('L'))
    x = x / 255.00
    x  = np.expand_dims(x, axis=-1)
    x  = tf.image.resize(x, [80, 80])
    x = np.repeat(x[:, :, np.newaxis], 3, axis=2)
    x = np.squeeze(x)
    x  = np.expand_dims(x, axis=0)
    prediction = model.predict(x)
    index = np.argmax(prediction[0])
    label = labels[index]
    text = f"<p style='text-align: center;'>{label}</p>"
    col1, col2, col3 = st.columns(3)
    with col1:
        st.write("")
    
    with col2:
        image = Image.open(file)
        st.markdown(text,unsafe_allow_html=True)
        st.image(image,width=300)  
    
    with col3:
        st.write("")