Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,15 +38,21 @@ def tryon_local(person_img, garment_img, seed, randomize_seed):
|
|
| 38 |
# -----------------------------
|
| 39 |
hunyuan_client = Client("tencent/Hunyuan3D-2.1")
|
| 40 |
|
|
|
|
|
|
|
|
|
|
| 41 |
def tryon_to_3d(person_img, garment_img, seed, randomize_seed):
|
| 42 |
-
# Run local simulation first
|
| 43 |
tryon_img, seed_used, tryon_info = tryon_local(person_img, garment_img, seed, randomize_seed)
|
| 44 |
if tryon_img is None:
|
| 45 |
return None, "Try-on failed"
|
| 46 |
|
| 47 |
try:
|
| 48 |
-
# Call the
|
| 49 |
-
result_3d = hunyuan_client.predict(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
return result_3d, tryon_info
|
| 51 |
except Exception as e:
|
| 52 |
return None, f"Hunyuan3D API error: {e}"
|
|
|
|
| 38 |
# -----------------------------
|
| 39 |
hunyuan_client = Client("tencent/Hunyuan3D-2.1")
|
| 40 |
|
| 41 |
+
# Pick the first available endpoint as default
|
| 42 |
+
fn_index_default = hunyuan_client.endpoints[0]["fn_index"] if hunyuan_client.endpoints else 0
|
| 43 |
+
|
| 44 |
def tryon_to_3d(person_img, garment_img, seed, randomize_seed):
|
|
|
|
| 45 |
tryon_img, seed_used, tryon_info = tryon_local(person_img, garment_img, seed, randomize_seed)
|
| 46 |
if tryon_img is None:
|
| 47 |
return None, "Try-on failed"
|
| 48 |
|
| 49 |
try:
|
| 50 |
+
# Call the first endpoint (fn_index_default) of the Hunyuan3D API
|
| 51 |
+
result_3d = hunyuan_client.predict(
|
| 52 |
+
person_img=person_img,
|
| 53 |
+
garment_img=garment_img,
|
| 54 |
+
fn_index=fn_index_default
|
| 55 |
+
)
|
| 56 |
return result_3d, tryon_info
|
| 57 |
except Exception as e:
|
| 58 |
return None, f"Hunyuan3D API error: {e}"
|