oKen38461 commited on
Commit
146df9e
·
1 Parent(s): 0a00365

app.pyのサンプルファイルのディレクトリを絶対パスに解決し、`gr.Examples`の存在チェックを追加しました。

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -5,8 +5,8 @@ import shutil
5
  from pathlib import Path
6
  from model_manager import ModelManager
7
 
8
- # サンプルファイルのディレクトリを定義
9
- EXAMPLES_DIR = Path(__file__).parent / "example"
10
 
11
  # インポートエラーのデバッグ情報を表示
12
  try:
@@ -123,15 +123,19 @@ with gr.Blocks(title="DittoTalkingHead") as demo:
123
  )
124
 
125
  # サンプル
126
- gr.Examples(
127
- examples=[
128
- [str(EXAMPLES_DIR / "audio.wav"), str(EXAMPLES_DIR / "image.png")]
129
- ],
130
- inputs=[audio_input, image_input],
131
- outputs=[video_output, status_output],
132
- fn=process_talking_head,
133
- cache_examples=True
134
- )
 
 
 
 
135
 
136
  # イベントハンドラ
137
  generate_btn.click(
 
5
  from pathlib import Path
6
  from model_manager import ModelManager
7
 
8
+ # サンプルファイルのディレクトリを定義(絶対パスに解決)
9
+ EXAMPLES_DIR = (Path(__file__).parent / "example").resolve()
10
 
11
  # インポートエラーのデバッグ情報を表示
12
  try:
 
123
  )
124
 
125
  # サンプル
126
+ example_audio = EXAMPLES_DIR / "audio.wav"
127
+ example_image = EXAMPLES_DIR / "image.png"
128
+
129
+ if example_audio.exists() and example_image.exists():
130
+ gr.Examples(
131
+ examples=[
132
+ [str(example_audio), str(example_image)]
133
+ ],
134
+ inputs=[audio_input, image_input],
135
+ outputs=[video_output, status_output],
136
+ fn=process_talking_head,
137
+ cache_examples=True
138
+ )
139
 
140
  # イベントハンドラ
141
  generate_btn.click(