Brayan commited on
Commit
d56bbcd
·
1 Parent(s): 8489608

Se sube archivo clasificar

Browse files
Files changed (1) hide show
  1. clasificar.py +27 -0
clasificar.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Librerias para cargar imagenes
2
+ import numpy as np
3
+ from keras.preprocessing.image import load_img, img_to_array
4
+ from keras.models import load_model
5
+
6
+ dim = 200
7
+ modelo = './modelo/modelo.h5'
8
+ pesos = './modelo/pesos.h5'
9
+ cnn = load_model(modelo)
10
+ cnn.load_weights(pesos)
11
+
12
+ def clasificar(file):
13
+ x = load_img(file, target_size=(dim, dim), color_mode = "grayscale")
14
+ x = img_to_array(x)
15
+ x = np.expand_dims(x, axis=0)
16
+ arreglo = cnn.predict(x)
17
+ resultado = arreglo[0]
18
+ respuesta = np.argmax(resultado)
19
+
20
+ if respuesta==0:
21
+ print('NORMAL')
22
+ else:
23
+ print('TUMOR CEREBRAL')
24
+
25
+ return respuesta
26
+
27
+ clasificar('./data/test/Brain_Tumor/Cancer(2417).jpg')