Spaces:
Paused
Paused
File size: 975 Bytes
fba2ed6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from fastapi import FastAPI,UploadFile
import shutil
from fastapi.responses import HTMLResponse
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
import app as predictor
from PIL import Image, ImageFilter
app = FastAPI()
app.mount("/view", StaticFiles(directory="view", html=True), name="view")
app.mount("/public", StaticFiles(directory="public", html=True), name="public")
@app.get("/")
def index() -> FileResponse:
return FileResponse(path="./view/index.html", media_type="text/html")
@app.post("/prediction/")
async def predict(targetImage: UploadFile):
path = f'public/{targetImage.filename}'# api/filesディレクトリを作成しておく
with open(path, 'wb+') as buffer:
shutil.copyfileobj(targetImage.file, buffer)
im = Image.open(path)
# todo quality指定できるようにする
depth_image, mesh_path = predictor.predict(im, 3)
print(mesh_path)
return {
"path":"public",
"name":mesh_path
}
|