Mikeztrada commited on
Commit
35a942b
·
verified ·
1 Parent(s): e91a706

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -15,10 +15,11 @@ def preprocesar_imagen(image):
15
  image = image.convert('L')
16
  image = image.resize((28, 28), Image.NEAREST)
17
  arr = np.array(image) / 255.0
18
- arr_bin = (arr < 0.5).astype(np.float32) # Binariza: 0 o 1 en float32
19
  arr_bin_4d = arr_bin.reshape(1, 28, 28, 1)
20
- # Para mostrar, devolvemos el arreglo 2D 0-1
21
- return arr_bin_4d, arr_bin
 
22
 
23
  def predict(image):
24
  try:
 
15
  image = image.convert('L')
16
  image = image.resize((28, 28), Image.NEAREST)
17
  arr = np.array(image) / 255.0
18
+ arr_bin = (arr < 0.5).astype(np.float32) # Binariza: 1 es trazo
19
  arr_bin_4d = arr_bin.reshape(1, 28, 28, 1)
20
+ # Para mostrar, invertimos la imagen para que sea negra el trazo (0) y blanco el fondo (1)
21
+ img_para_mostrar = 1 - arr_bin
22
+ return arr_bin_4d, img_para_mostrar
23
 
24
  def predict(image):
25
  try: