Spaces:
Build error
Build error
Download app.py from phucbienvan/face_analyze: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/phucbienvan/face_analyze/resolve/main/app.py
- Command line
-
hf download hf://spaces/phucbienvan/face_analyze/app.py
-
curl -L -o app.py https://huggingface.co/spaces/phucbienvan/face_analyze/resolve/main/app.py
1.38 kB
| import sys | |
| import os | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| import uvicorn | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app.schemas.request_response import ImageRequest, SkinAnalysisResponse | |
| from app.services.analysis_service import analyze_skin_from_url | |
| # Rename the variable to avoid confusion with the module name | |
| application = FastAPI( | |
| title="Skin Analyzer API", | |
| description="API for analyzing skin conditions from facial images", | |
| version="1.0.0" | |
| ) | |
| application.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| async def root(): | |
| return {"message": "Welcome to Skin Analyzer API"} | |
| async def analyze_skin(request: ImageRequest): | |
| """ | |
| Analyze skin conditions from an image URL | |
| """ | |
| try: | |
| return await analyze_skin_from_url(request.image_url) | |
| except Exception as e: | |
| import logging | |
| logging.error(f"Error processing request: {e}") | |
| from fastapi import HTTPException | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| if __name__ == "__main__": | |
| # Update the reference to use the new variable name | |
| uvicorn.run("app.main:app", host="0.0.0.0", port=7860) |