Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,10 @@ import io
|
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
|
|
| 10 |
app.add_middleware(
|
| 11 |
CORSMiddleware,
|
| 12 |
-
allow_origins=["*"],
|
| 13 |
allow_methods=["*"],
|
| 14 |
allow_headers=["*"],
|
| 15 |
)
|
|
@@ -21,10 +22,11 @@ interpreter.allocate_tensors()
|
|
| 21 |
input_details = interpreter.get_input_details()
|
| 22 |
output_details = interpreter.get_output_details()
|
| 23 |
|
| 24 |
-
# Cargar etiquetas
|
| 25 |
with open("labels_mobilenet_quant_v1_224.txt", "r") as f:
|
| 26 |
labels = f.read().splitlines()
|
| 27 |
|
|
|
|
| 28 |
@app.post("/predict/")
|
| 29 |
async def predict(file: UploadFile = File(...)):
|
| 30 |
img_bytes = await file.read()
|
|
|
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
| 10 |
+
# Configurar CORS para permitir solicitudes desde cualquier origen
|
| 11 |
app.add_middleware(
|
| 12 |
CORSMiddleware,
|
| 13 |
+
allow_origins=["*"], # Puedes restringir esto a tus dominios si lo prefieres
|
| 14 |
allow_methods=["*"],
|
| 15 |
allow_headers=["*"],
|
| 16 |
)
|
|
|
|
| 22 |
input_details = interpreter.get_input_details()
|
| 23 |
output_details = interpreter.get_output_details()
|
| 24 |
|
| 25 |
+
# Cargar etiquetas (aseg煤rate de que este archivo est茅 en el mismo directorio que el c贸digo)
|
| 26 |
with open("labels_mobilenet_quant_v1_224.txt", "r") as f:
|
| 27 |
labels = f.read().splitlines()
|
| 28 |
|
| 29 |
+
# Endpoint para predecir la clase de la imagen
|
| 30 |
@app.post("/predict/")
|
| 31 |
async def predict(file: UploadFile = File(...)):
|
| 32 |
img_bytes = await file.read()
|