rogerxavier's picture
Update api.py
f8096b7 verified
raw
history blame
876 Bytes
from fastapi import FastAPI, File, UploadFile
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from PIL import Image
import numpy as np
import urllib.request
import io
import os
from moviepyTest import test
app = FastAPI()
@app.get("/inference")
def inference():
return "<p>Hello, World!</p>"
@app.get("/infer_t5")
def t5(input):
return {"output": input}
@app.get("/moviepyTest")
def t5():
result = test()
return {"output": result}
@app.post("/getOriginalMangaList")
async def getOriginalMangaList(image_list: dict):
for idx, img_data in enumerate(image_list["imageList"]):
img = io.BytesIO(img_data.encode())
image = Image.open(img).convert("L").convert("RGB")
path_to_image = f"/manga/{idx}.jpg"
image.save(path_to_image)
return "获取图片保存成功"