P-FFP / api_main.py
mrneuralnet's picture
Initial commit
c0f8b72
raw
history blame contribute delete
805 Bytes
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]
@app.get("/")
def read_root():
return {"Hello": "World!"}
@app.post("/face-forgery/")
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