ginipick commited on
Commit
e0dc7aa
Β·
verified Β·
1 Parent(s): 4495cd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -5
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) # ← timeout 인자 μ‚­μ œ
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
- anim, comp = result[0], result[1]
71
- logs.append(f"[{datetime.now().strftime('%H:%M:%S')}] 성곡")
72
- return anim, comp, "\n".join(logs)
 
 
 
 
 
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
+ )