Spaces:
Sleeping
Sleeping
from fastapi import FastAPI, HTTPException | |
from fastapi.responses import JSONResponse | |
from pydantic import BaseModel | |
from PIL import Image | |
from io import BytesIO | |
import base64 | |
from typing import List | |
from handler import FaceFakePipelineImage | |
app = FastAPI() | |
class ImagesRequest(BaseModel): | |
images: List[str] | |
def read_root(): | |
return {"Hello": "World!"} | |
def submit(request: ImagesRequest): | |
try: | |
deform = FaceFakePipelineImage() | |
pred = deform(request) | |
except Exception as e: | |
error_response = { | |
"ok": False, | |
"message": f"Encountered a problem while analyzing image: {e}" | |
} | |
return JSONResponse(content=error_response, status_code=500) | |
return pred |