Spaces:
Sleeping
Sleeping
chips
commited on
Commit
·
0352de5
1
Parent(s):
6e499b6
added a lot of functions
Browse files
app.py
CHANGED
|
@@ -14,6 +14,49 @@ def greet_json():
|
|
| 14 |
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Endpoints related to making more stills versions from image
|
| 18 |
|
| 19 |
@app.get("/versionStatus")
|
|
@@ -26,6 +69,7 @@ async def versionResult(request_id: str):
|
|
| 26 |
result = await fal_client.result_async("fal-ai/instant-character", request_id)
|
| 27 |
return(result)
|
| 28 |
|
|
|
|
| 29 |
@app.post("/makeVersions")
|
| 30 |
async def make_versions(image: UploadFile = File(...)):
|
| 31 |
# Read image data
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
+
# Function related to virtual outfit try on
|
| 18 |
+
|
| 19 |
+
#figure out how to deal with front vs back images of garments
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def combine_garment_images(Upper_garment: UploadFile = File(...), Lower_garment: UploadFile = File(...):
|
| 23 |
+
|
| 24 |
+
return("something")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# Endpoints related to virtual outfit try on
|
| 28 |
+
# HOW DO WE DICESERN FRONT VS BACK IMAGES OF GARMENTS?
|
| 29 |
+
|
| 30 |
+
@app.post("/styleTalent")
|
| 31 |
+
def style_talent(talent_image: UploadFile = File(...), garment_image: UploadFile = File(...)):
|
| 32 |
+
#Save the uploaded talent image tempoarily
|
| 33 |
+
image_bytes = await image.read()
|
| 34 |
+
file_path = f"/tmp/{talent_image.filename}"
|
| 35 |
+
with open(file_path, "wb") as f:
|
| 36 |
+
f.write(talent_image_bytes)
|
| 37 |
+
|
| 38 |
+
#Upload the file to FAL
|
| 39 |
+
talent_image_url = fal_client.upload_file(file_path)
|
| 40 |
+
|
| 41 |
+
#Save the uploaded garment image tempoarily
|
| 42 |
+
image_bytes = await image.read()
|
| 43 |
+
file_path = f"/tmp/{garment_image.filename}"
|
| 44 |
+
with open(file_path, "wb") as f:
|
| 45 |
+
f.write(garment_image_bytes)
|
| 46 |
+
|
| 47 |
+
#Upload the file to FAL
|
| 48 |
+
garment_image_url = fal_client.upload_file(file_path)
|
| 49 |
+
|
| 50 |
+
handler = fal_client.submit(
|
| 51 |
+
"fal-ai/kling/v1-5/kolors-virtual-try-on",
|
| 52 |
+
arguments={
|
| 53 |
+
"human_image_url": talent_image_url,
|
| 54 |
+
"garment_image_url": garment_image_url
|
| 55 |
+
},
|
| 56 |
+
)
|
| 57 |
+
request_id = handler.request_id
|
| 58 |
+
return(request_id)
|
| 59 |
+
|
| 60 |
# Endpoints related to making more stills versions from image
|
| 61 |
|
| 62 |
@app.get("/versionStatus")
|
|
|
|
| 69 |
result = await fal_client.result_async("fal-ai/instant-character", request_id)
|
| 70 |
return(result)
|
| 71 |
|
| 72 |
+
|
| 73 |
@app.post("/makeVersions")
|
| 74 |
async def make_versions(image: UploadFile = File(...)):
|
| 75 |
# Read image data
|