Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ from fastapi import FastAPI, File, UploadFile
|
|
| 2 |
import httpx
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from io import BytesIO
|
| 5 |
-
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
@@ -25,6 +25,16 @@ async def send_image(image: UploadFile = File(...)):
|
|
| 25 |
|
| 26 |
# Optional: prepare image payload for external API
|
| 27 |
files = {"file": (image.filename, BytesIO(image_bytes), image.content_type)}
|
| 28 |
-
|
|
|
|
| 29 |
# Call external API
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import httpx
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from io import BytesIO
|
| 5 |
+
import fal_client
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
|
|
| 25 |
|
| 26 |
# Optional: prepare image payload for external API
|
| 27 |
files = {"file": (image.filename, BytesIO(image_bytes), image.content_type)}
|
| 28 |
+
with open(f"/tmp/{image.filename}", "wb") as f:
|
| 29 |
+
f.write(image_bytes)
|
| 30 |
# Call external API
|
| 31 |
+
handler = fal_client.submit(
|
| 32 |
+
"fal-ai/instant-character",
|
| 33 |
+
arguments={
|
| 34 |
+
"prompt": "Model posing",
|
| 35 |
+
"image_url": f"/tmp/{image.filename}"
|
| 36 |
+
},
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
request_id = handler.request_id
|
| 40 |
+
return(f"check request id: {request_id}")
|