Spaces:
Running
Running
Update fluxai.py
Browse files
fluxai.py
CHANGED
@@ -90,10 +90,7 @@ 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 |
-
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,16 +110,12 @@ async def fluxai_image(
|
|
113 |
enhanced_image_bytes = io.BytesIO()
|
114 |
image.save(enhanced_image_bytes, format="JPEG", quality=95)
|
115 |
enhanced_image_bytes.seek(0)
|
116 |
-
|
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)
|
123 |
with open(file_path, "wb") as f:
|
124 |
f.write(enhanced_image_bytes.getvalue())
|
125 |
-
example_test = "Accurately identify the baked good in the image and provide an appropriate
|
126 |
x = GeminiLatest(api_keys=GOOGLE_API_KEY)
|
127 |
response = x.get_response_image(example_test, file_path)
|
128 |
url = f"https://randydev-ryuzaki-api.hf.space/{file_path}"
|
@@ -132,7 +125,7 @@ async def fluxai_image(
|
|
132 |
)
|
133 |
else:
|
134 |
return StreamingResponse(io.BytesIO(image_bytes), media_type="image/jpeg")
|
135 |
-
|
136 |
except Exception as e:
|
137 |
return SuccessResponse(
|
138 |
status="False",
|
|
|
90 |
)
|
91 |
|
92 |
@router.post("/akeno/fluxai", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
93 |
+
async def fluxai_image(payload: FluxAI):
|
|
|
|
|
|
|
94 |
if deduct_tokens_gpt(payload.user_id, amount=20):
|
95 |
try:
|
96 |
image_bytes = await schellwithflux(payload.args)
|
|
|
110 |
enhanced_image_bytes = io.BytesIO()
|
111 |
image.save(enhanced_image_bytes, format="JPEG", quality=95)
|
112 |
enhanced_image_bytes.seek(0)
|
113 |
+
unique_filename = f"{uuid.uuid4().hex}.jpg"
|
|
|
|
|
|
|
|
|
114 |
file_path = os.path.join("uploads", unique_filename)
|
115 |
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
116 |
with open(file_path, "wb") as f:
|
117 |
f.write(enhanced_image_bytes.getvalue())
|
118 |
+
example_test = "Accurately identify the baked good in the image and provide an appropriate recipe consistent with your analysis."
|
119 |
x = GeminiLatest(api_keys=GOOGLE_API_KEY)
|
120 |
response = x.get_response_image(example_test, file_path)
|
121 |
url = f"https://randydev-ryuzaki-api.hf.space/{file_path}"
|
|
|
125 |
)
|
126 |
else:
|
127 |
return StreamingResponse(io.BytesIO(image_bytes), media_type="image/jpeg")
|
128 |
+
|
129 |
except Exception as e:
|
130 |
return SuccessResponse(
|
131 |
status="False",
|