Spaces:
Build error
Build error
File size: 1,089 Bytes
c4b6bc5 6b86170 4903d2e 8807f10 c4b6bc5 99fc20a c4b6bc5 cd9379c c4b6bc5 cd9379c c4b6bc5 cd9379c c4b6bc5 cd9379c c4b6bc5 10dbd2e c4b6bc5 10dbd2e f0f563d cd9379c |
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 |
#Librerias para cargar imagenes
import numpy as np
import tensorflow as tf
from tensorflow.keras.preprocessing.image import load_img, img_to_array
from tensorflow.keras.models import load_model
from PIL import Image
import streamlit as st
dim = 200
modelo = './modelo.h5'
pesos = './pesos.h5'
cnn = load_model(modelo)
cnn.load_weights(pesos)
def clasificar(file):
x = load_img(file, target_size=(dim, dim), color_mode = "grayscale")
x = img_to_array(x)
x = np.expand_dims(x, axis=0)
arreglo = cnn.predict(x)
resultado = arreglo[0]
respuesta = np.argmax(resultado)
rta = ""
if respuesta==0:
rta = 'NORMAL'
else:
rta = 'TUMOR CEREBRAL'
return rta
st.title("CNN Clasificador de Casos de Cancer Cerebral")
uploaded_file = st.file_uploader("Sube una imagen...", type="jpg")
if uploaded_file is not None:
image = Image.open(uploaded_file)
st.image(image, caption='Uploaded Image.', use_column_width=True)
st.write("")
st.write("Clasificacion:")
label = clasificar("./test/"+uploaded_file.name) ##aqui va el llamado a la IA
st.write(label) |