|
|
|
import numpy as np |
|
from keras.preprocessing.image import load_img, img_to_array |
|
from keras.models import load_model |
|
|
|
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) |
|
|
|
if respuesta==0: |
|
print('NORMAL') |
|
else: |
|
print('TUMOR CEREBRAL') |
|
|
|
return respuesta |
|
|
|
clasificar('./data/test/Brain_Tumor/Cancer(2417).jpg') |