Download app.py from Junior16/T3: direct link, hf CLI and curl.
- Browser
- Download file 700 Bytes
-
https://huggingface.co/spaces/Junior16/T3/resolve/main/app.py
- Command line
-
hf download hf://spaces/Junior16/T3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Junior16/T3/resolve/main/app.py
700 Bytes
| import cv2 | |
| from fastapi import FastAPI, File, UploadFile | |
| import numpy as np | |
| from PIL import Image | |
| import io | |
| app = FastAPI() | |
| async def detect_disease(file: UploadFile = File(...)): | |
| # Leer imagen cargada | |
| image_bytes = await file.read() | |
| image = Image.open(io.BytesIO(image_bytes)) | |
| img_np = np.array(image) | |
| # Convertir a escala de grises y aplicar análisis de bordes | |
| gray = cv2.cvtColor(img_np, cv2.COLOR_RGB2GRAY) | |
| edges = cv2.Canny(gray, 100, 200) | |
| # Analizar características básicas (esto es un ejemplo) | |
| disease_detected = "Enfermedad detectada" if np.mean(edges) > 50 else "Saludable" | |
| return {"diagnosis": disease_detected} | |