Spaces:
Paused
Paused
File size: 1,250 Bytes
3450e6b 668c84b 3450e6b |
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 32 33 34 35 36 37 38 39 40 41 42 43 |
from typing import Annotated
from fastapi import FastAPI, File, HTTPException
from fastapi.responses import StreamingResponse
from starlette.middleware.cors import CORSMiddleware
from opengl import image_enhance
from utils.dto import ToneUpData
from utils.s3 import get_image_from_s3
app = FastAPI()
cors_options = {
"allow_methods": ["*"],
"allow_headers": ["*"],
"allow_credentials": True,
"allow_origins": [
"https://www.photio.io",
"https://dev.photio.io",
"http://localhost:3000",
"http://localhost",
"http://172.30.1.10:3000",
],
}
app.add_middleware(CORSMiddleware, **cors_options)
@app.get("/")
def read_root():
return {"Hello": "World!"}
@app.post("/tone-up")
async def tone_up(items:ToneUpData):
try:
image = get_image_from_s3(items.image_id)
out_image = image_enhance(image,items.exposure,items.saturation,items.contrast,items.brightness,items.gamma,items.shadows,items.highlights,items.whites,items.blacks,items.clarity,items.temperature,items.sharpness)
# csv_to_r2(output_image,image_id)
return {"result": out_image}
except RuntimeError as e:
raise HTTPException(status_code=422, detail=f"error occur: {e}") from e
|