Spaces:
Running
Running
Update fluxai.py
Browse files
fluxai.py
CHANGED
@@ -13,7 +13,7 @@ from models import *
|
|
13 |
class FluxAI(BaseModel):
|
14 |
user_id: int
|
15 |
args: str
|
16 |
-
auto_enhancer: bool
|
17 |
|
18 |
router = APIRouter()
|
19 |
|
@@ -65,16 +65,16 @@ async def fluxai_image(payload: FluxAI):
|
|
65 |
)
|
66 |
|
67 |
if payload.enhancer:
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
return StreamingResponse(enhanced_image_bytes, media_type="image/jpeg")
|
79 |
else:
|
80 |
return StreamingResponse(io.BytesIO(image_bytes), media_type="image/jpeg")
|
|
|
13 |
class FluxAI(BaseModel):
|
14 |
user_id: int
|
15 |
args: str
|
16 |
+
auto_enhancer: bool = False
|
17 |
|
18 |
router = APIRouter()
|
19 |
|
|
|
65 |
)
|
66 |
|
67 |
if payload.enhancer:
|
68 |
+
with Image.open(io.BytesIO(image_bytes)) as image:
|
69 |
+
enhancer = ImageEnhance.Sharpness(image)
|
70 |
+
image = enhancer.enhance(1.5)
|
71 |
+
enhancer = ImageEnhance.Contrast(image)
|
72 |
+
image = enhancer.enhance(1.2)
|
73 |
+
enhancer = ImageEnhance.Color(image)
|
74 |
+
image = enhancer.enhance(1.1)
|
75 |
+
enhanced_image_bytes = io.BytesIO()
|
76 |
+
image.save(enhanced_image_bytes, format="JPEG", quality=95)
|
77 |
+
enhanced_image_bytes.seek(0)
|
78 |
return StreamingResponse(enhanced_image_bytes, media_type="image/jpeg")
|
79 |
else:
|
80 |
return StreamingResponse(io.BytesIO(image_bytes), media_type="image/jpeg")
|