Spaces:
Paused
Paused
| 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) | |
| def read_root(): | |
| return {"Hello": "World!"} | |
| 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 | |