Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -76,13 +76,19 @@ async def predict_fingerprint_api(file: UploadFile = File(...)):
|
|
76 |
contents = await file.read()
|
77 |
image = Image.open(BytesIO(contents)).convert('L')
|
78 |
image = np.asarray(image)
|
|
|
|
|
79 |
image = image.reshape(256, 256, 1)
|
80 |
-
print(f"
|
|
|
81 |
representative_data = representativo(image)
|
|
|
82 |
representative_data = representative_data.reshape(1, -1)
|
83 |
|
84 |
w = som.winner(representative_data)
|
|
|
85 |
prediction = MM[w]
|
|
|
86 |
|
87 |
return {"prediction": prediction}
|
88 |
except Exception as e:
|
|
|
76 |
contents = await file.read()
|
77 |
image = Image.open(BytesIO(contents)).convert('L')
|
78 |
image = np.asarray(image)
|
79 |
+
if image.shape != (256, 256):
|
80 |
+
raise ValueError("La imagen debe ser de tama帽o 256x256.")
|
81 |
image = image.reshape(256, 256, 1)
|
82 |
+
print(f"Imagen convertida a matriz: {image.shape}")
|
83 |
+
|
84 |
representative_data = representativo(image)
|
85 |
+
print(f"Datos representativos de la imagen: {representative_data.shape}")
|
86 |
representative_data = representative_data.reshape(1, -1)
|
87 |
|
88 |
w = som.winner(representative_data)
|
89 |
+
print(f"脥ndice ganador del SOM: {w}")
|
90 |
prediction = MM[w]
|
91 |
+
print(f"Predicci贸n: {prediction}")
|
92 |
|
93 |
return {"prediction": prediction}
|
94 |
except Exception as e:
|