Spaces:
Running
Running
Update fluxai.py
Browse files
fluxai.py
CHANGED
@@ -10,7 +10,7 @@ from pydantic import BaseModel
|
|
10 |
from pymongo import MongoClient
|
11 |
from models import *
|
12 |
from huggingface_hub import InferenceClient
|
13 |
-
from fastapi import UploadFile
|
14 |
from fastapi.responses import JSONResponse
|
15 |
import uuid
|
16 |
from RyuzakiLib import GeminiLatest
|
@@ -90,7 +90,10 @@ async def mistralai_(payload: MistralAI):
|
|
90 |
)
|
91 |
|
92 |
@router.post("/akeno/fluxai", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
93 |
-
async def fluxai_image(
|
|
|
|
|
|
|
94 |
if deduct_tokens_gpt(payload.user_id, amount=20):
|
95 |
try:
|
96 |
image_bytes = await schellwithflux(payload.args)
|
@@ -110,7 +113,10 @@ async def fluxai_image(payload: FluxAI, file: UploadFile):
|
|
110 |
enhanced_image_bytes = io.BytesIO()
|
111 |
image.save(enhanced_image_bytes, format="JPEG", quality=95)
|
112 |
enhanced_image_bytes.seek(0)
|
113 |
-
|
|
|
|
|
|
|
114 |
unique_filename = f"{uuid.uuid4().hex}.{ext}"
|
115 |
file_path = os.path.join("uploads", unique_filename)
|
116 |
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
|
|
10 |
from pymongo import MongoClient
|
11 |
from models import *
|
12 |
from huggingface_hub import InferenceClient
|
13 |
+
from fastapi import UploadFile, File
|
14 |
from fastapi.responses import JSONResponse
|
15 |
import uuid
|
16 |
from RyuzakiLib import GeminiLatest
|
|
|
90 |
)
|
91 |
|
92 |
@router.post("/akeno/fluxai", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
93 |
+
async def fluxai_image(
|
94 |
+
payload: FluxAI = Depends(),
|
95 |
+
file: UploadFile = File(None)
|
96 |
+
):
|
97 |
if deduct_tokens_gpt(payload.user_id, amount=20):
|
98 |
try:
|
99 |
image_bytes = await schellwithflux(payload.args)
|
|
|
113 |
enhanced_image_bytes = io.BytesIO()
|
114 |
image.save(enhanced_image_bytes, format="JPEG", quality=95)
|
115 |
enhanced_image_bytes.seek(0)
|
116 |
+
if file:
|
117 |
+
ext = file.filename.split(".")[-1]
|
118 |
+
else:
|
119 |
+
ext = "jpg"
|
120 |
unique_filename = f"{uuid.uuid4().hex}.{ext}"
|
121 |
file_path = os.path.join("uploads", unique_filename)
|
122 |
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|