Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,7 +54,7 @@ def generate_animation(image, audio, guidance_scale, steps, progress=gr.Progress
|
|
| 54 |
raise ValueError("μ΄λ―Έμ§μ μ€λμ€λ₯Ό λͺ¨λ μ
λ‘λνμΈμ.")
|
| 55 |
|
| 56 |
progress(0.05, desc="νμΌ μ€λΉ")
|
| 57 |
-
client = Client(API_URL)
|
| 58 |
|
| 59 |
progress(0.15, desc="μλ² νΈμΆ μ€β¦ (μ λΆ μμ κ°λ₯)")
|
| 60 |
result = client.predict(
|
|
@@ -66,15 +66,42 @@ def generate_animation(image, audio, guidance_scale, steps, progress=gr.Progress
|
|
| 66 |
)
|
| 67 |
|
| 68 |
progress(0.95, desc="κ²°κ³Ό μ 리")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
if isinstance(result, (list, tuple)) and len(result) >= 2:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
else:
|
| 74 |
raise RuntimeError(f"μμμΉ λͺ»ν λ°ν νμ: {type(result)}")
|
| 75 |
|
| 76 |
except Exception as e:
|
| 77 |
logs.append(f"[{datetime.now().strftime('%H:%M:%S')}] μ€λ₯: {e}")
|
|
|
|
| 78 |
return None, None, "\n".join(logs)
|
| 79 |
|
| 80 |
# βββββββββββββββββββββββ UI μ μ ββββββββββββββββββββββ #
|
|
@@ -114,4 +141,4 @@ if __name__ == "__main__":
|
|
| 114 |
server_name="0.0.0.0",
|
| 115 |
server_port=7860,
|
| 116 |
show_api=False
|
| 117 |
-
)
|
|
|
|
| 54 |
raise ValueError("μ΄λ―Έμ§μ μ€λμ€λ₯Ό λͺ¨λ μ
λ‘λνμΈμ.")
|
| 55 |
|
| 56 |
progress(0.05, desc="νμΌ μ€λΉ")
|
| 57 |
+
client = Client(API_URL)
|
| 58 |
|
| 59 |
progress(0.15, desc="μλ² νΈμΆ μ€β¦ (μ λΆ μμ κ°λ₯)")
|
| 60 |
result = client.predict(
|
|
|
|
| 66 |
)
|
| 67 |
|
| 68 |
progress(0.95, desc="κ²°κ³Ό μ 리")
|
| 69 |
+
|
| 70 |
+
# κ²°κ³Ό μ²λ¦¬ - dict νν μ²λ¦¬ μΆκ°
|
| 71 |
+
def extract_video_path(obj):
|
| 72 |
+
"""λΉλμ€ κ°μ²΄μμ κ²½λ‘ μΆμΆ"""
|
| 73 |
+
if isinstance(obj, str):
|
| 74 |
+
return obj
|
| 75 |
+
elif isinstance(obj, dict):
|
| 76 |
+
# Gradioμ FileData dict μ²λ¦¬
|
| 77 |
+
if 'path' in obj:
|
| 78 |
+
return obj['path']
|
| 79 |
+
elif 'url' in obj:
|
| 80 |
+
return obj['url']
|
| 81 |
+
elif 'name' in obj:
|
| 82 |
+
return obj['name']
|
| 83 |
+
else:
|
| 84 |
+
log.warning(f"Unexpected dict structure: {obj.keys()}")
|
| 85 |
+
return None
|
| 86 |
+
else:
|
| 87 |
+
log.warning(f"Unexpected type: {type(obj)}")
|
| 88 |
+
return None
|
| 89 |
+
|
| 90 |
if isinstance(result, (list, tuple)) and len(result) >= 2:
|
| 91 |
+
anim_path = extract_video_path(result[0])
|
| 92 |
+
comp_path = extract_video_path(result[1])
|
| 93 |
+
|
| 94 |
+
if anim_path and comp_path:
|
| 95 |
+
logs.append(f"[{datetime.now().strftime('%H:%M:%S')}] μ±κ³΅")
|
| 96 |
+
return anim_path, comp_path, "\n".join(logs)
|
| 97 |
+
else:
|
| 98 |
+
raise RuntimeError(f"λΉλμ€ κ²½λ‘ μΆμΆ μ€ν¨: {result}")
|
| 99 |
else:
|
| 100 |
raise RuntimeError(f"μμμΉ λͺ»ν λ°ν νμ: {type(result)}")
|
| 101 |
|
| 102 |
except Exception as e:
|
| 103 |
logs.append(f"[{datetime.now().strftime('%H:%M:%S')}] μ€λ₯: {e}")
|
| 104 |
+
log.error(f"Animation generation error: {e}", exc_info=True)
|
| 105 |
return None, None, "\n".join(logs)
|
| 106 |
|
| 107 |
# βββββββββββββββββββββββ UI μ μ ββββββββββββββββββββββ #
|
|
|
|
| 141 |
server_name="0.0.0.0",
|
| 142 |
server_port=7860,
|
| 143 |
show_api=False
|
| 144 |
+
)
|