Spaces:
Sleeping
Sleeping
Alex Vega
commited on
Commit
路
dc26c43
1
Parent(s):
5e52f0c
up
Browse files
main.py
CHANGED
@@ -29,15 +29,7 @@ CLASS_NAMES = [
|
|
29 |
'del', 'nothing', 'space'
|
30 |
]
|
31 |
|
32 |
-
# --- Funciones de preprocesamiento (CORREGIDAS) ---
|
33 |
def preprocess_image(image: Image.Image) -> np.ndarray:
|
34 |
-
"""
|
35 |
-
Preprocesa la imagen para que sea compatible con el modelo.
|
36 |
-
- Cambia el tama帽o a 96x96 p铆xeles.
|
37 |
-
- La convierte a un array de NumPy.
|
38 |
-
- A帽ade una dimensi贸n de batch.
|
39 |
-
- NO normaliza, ya que el modelo tiene una capa de Rescaling.
|
40 |
-
"""
|
41 |
image = image.resize((96, 96))
|
42 |
image_array = np.array(image)
|
43 |
|
@@ -48,9 +40,6 @@ def preprocess_image(image: Image.Image) -> np.ndarray:
|
|
48 |
|
49 |
@app.post("/predict/", response_model=TranslationResponse)
|
50 |
async def predict(file: UploadFile = File(...)):
|
51 |
-
"""
|
52 |
-
Endpoint para predecir la letra del lenguaje de se帽as a partir de una imagen.
|
53 |
-
"""
|
54 |
contents = await file.read()
|
55 |
|
56 |
try:
|
@@ -70,4 +59,4 @@ async def predict(file: UploadFile = File(...)):
|
|
70 |
|
71 |
@app.get("/")
|
72 |
def read_root():
|
73 |
-
return {"message": "
|
|
|
29 |
'del', 'nothing', 'space'
|
30 |
]
|
31 |
|
|
|
32 |
def preprocess_image(image: Image.Image) -> np.ndarray:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
image = image.resize((96, 96))
|
34 |
image_array = np.array(image)
|
35 |
|
|
|
40 |
|
41 |
@app.post("/predict/", response_model=TranslationResponse)
|
42 |
async def predict(file: UploadFile = File(...)):
|
|
|
|
|
|
|
43 |
contents = await file.read()
|
44 |
|
45 |
try:
|
|
|
59 |
|
60 |
@app.get("/")
|
61 |
def read_root():
|
62 |
+
return {"message": "/predict/ para leer imagen."}
|