Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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:
|
| 19 |
arr_bin_4d = arr_bin.reshape(1, 28, 28, 1)
|
| 20 |
-
# Para mostrar,
|
| 21 |
-
|
|
|
|
| 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:
|