matthewkram commited on
Commit
c3e485a
·
verified ·
1 Parent(s): c237aac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -14
app.py CHANGED
@@ -12,7 +12,7 @@ import cv2
12
  import subprocess
13
  import tempfile
14
 
15
- # Папки для файлов (создаются автоматически)
16
  IMG_DIR = './img'
17
  VIDEO_DIR = './video'
18
  OUTPUT_DIR = './output'
@@ -32,11 +32,15 @@ class WanAnimateApp:
32
 
33
  def get_img_files(self):
34
  """Список файлов в папке img"""
35
- return [f for f in os.listdir(IMG_DIR) if f.lower().endswith(('.png', '.jpg', '.jpeg'))]
 
 
36
 
37
  def get_video_files(self):
38
  """Список файлов в папке video"""
39
- return [f for f in os.listdir(VIDEO_DIR) if f.lower().endswith(('.mp4', '.avi', '.mov'))]
 
 
40
 
41
  def load_img_from_dropdown(self, selected_file):
42
  """Загружает выбранное фото в ref_img"""
@@ -62,7 +66,7 @@ class WanAnimateApp:
62
  model,
63
  ):
64
  if ref_img_path is None or video_path is None:
65
- return None, "Выберите или загрузите оба файла."
66
 
67
  try:
68
  # Local processing
@@ -139,28 +143,70 @@ def start_app():
139
 
140
  gr.HTML("""
141
  <details>
142
- <summary>‼️Usage (использование)</summary>
143
- Wan-Animate поддерживает два режима:
144
  <ul>
145
- <li>Move Mode: анимирует персонажа в изображении движениями из видео</li>
146
- <li>Mix Mode: заменяет персонажа в видео на персонажа из изображения</li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  </ul>
148
- Ограничения: Видео <200MB, 2–30s, 200–2048 res; Изображение <5MB, 200–4096 res.
149
- Quality: wan-pro (25fps, 720p), wan-std (15fps, 720p).
150
  </details>
151
  """)
152
 
153
  with gr.Row():
154
  with gr.Column():
 
 
 
 
 
 
155
  ref_img = gr.Image(
156
- label="Reference Image (загрузи фото)",
157
  type="filepath",
158
- sources=["upload"],
 
 
 
 
 
 
 
 
 
 
 
 
159
  )
160
-
161
  video = gr.Video(
162
- label="Template Video (загрузи видео)",
163
  sources=["upload"],
 
 
 
 
 
 
164
  )
165
 
166
  with gr.Row():
 
12
  import subprocess
13
  import tempfile
14
 
15
+ # Папки (создаются автоматически)
16
  IMG_DIR = './img'
17
  VIDEO_DIR = './video'
18
  OUTPUT_DIR = './output'
 
32
 
33
  def get_img_files(self):
34
  """Список файлов в папке img"""
35
+ if os.path.exists(IMG_DIR):
36
+ return [f for f in os.listdir(IMG_DIR) if f.lower().endswith(('.png', '.jpg', '.jpeg'))]
37
+ return []
38
 
39
  def get_video_files(self):
40
  """Список файлов в папке video"""
41
+ if os.path.exists(VIDEO_DIR):
42
+ return [f for f in os.listdir(VIDEO_DIR) if f.lower().endswith(('.mp4', '.avi', '.mov'))]
43
+ return []
44
 
45
  def load_img_from_dropdown(self, selected_file):
46
  """Загружает выбранное фото в ref_img"""
 
66
  model,
67
  ):
68
  if ref_img_path is None or video_path is None:
69
+ return None, "Выберите файл из списка или загрузите новый."
70
 
71
  try:
72
  # Local processing
 
143
 
144
  gr.HTML("""
145
  <details>
146
+ <summary>‼️Usage (использования)</summary>
147
+ Wan-Animate supports two modes:
148
  <ul>
149
+ <li>Move Mode: animate the character in input image with movements from the input video</li>
150
+ <li>Mix Mode: replace the character in input video with the character in input image</li>
151
+ </ul>
152
+ Wan-Animate supports two modes:
153
+ <ul>
154
+ <li>Move Mode: Use the movements extracted from the input video to drive the character in the input image</li>
155
+ <li>Mix Mode: Use the character in the input image to replace the character in the input video</li>
156
+ </ul>
157
+ Currently, the following restrictions apply to inputs:
158
+ <ul>
159
+ <li>Video file size: Less than 200MB</li>
160
+ <li>Video resolution: The shorter side must be greater than 200, and the longer side must be less than 2048</li>
161
+ <li>Video duration: 2s to 30s</li>
162
+ <li>Video aspect ratio: 1:3 to 3:1</li>
163
+ <li>Video formats: mp4, avi, mov</li>
164
+ <li>Image file size: Less than 5MB</li>
165
+ <li>Image resolution: The shorter side must be greater than 200, and the longer side must be less than 4096</li>
166
+ <li>Image formats: jpg, png, jpeg, webp, bmp</li>
167
+ </ul>
168
+ Current, the inference quality has two variants. You can use our open-source code for more flexible configuration.
169
+ <ul>
170
+ <li>wan-pro: 25fps, 720p</li>
171
+ <li>wan-std: 15fps, 720p</li>
172
  </ul>
 
 
173
  </details>
174
  """)
175
 
176
  with gr.Row():
177
  with gr.Column():
178
+ # Dropdown for img
179
+ img_dropdown = gr.Dropdown(
180
+ label="Select Image from img folder (выбери фото)",
181
+ choices=app.get_img_files(),
182
+ value=None,
183
+ )
184
  ref_img = gr.Image(
185
+ label="Reference Image (изображение)",
186
  type="filepath",
187
+ value=None,
188
+ )
189
+ img_dropdown.change(
190
+ fn=app.load_img_from_dropdown,
191
+ inputs=[img_dropdown],
192
+ outputs=[ref_img],
193
+ )
194
+
195
+ # Dropdown for video
196
+ video_dropdown = gr.Dropdown(
197
+ label="Select Video from video folder (выбери видео)",
198
+ choices=app.get_video_files(),
199
+ value=None,
200
  )
 
201
  video = gr.Video(
202
+ label="Template Video (шаблонное видео)",
203
  sources=["upload"],
204
+ value=None,
205
+ )
206
+ video_dropdown.change(
207
+ fn=app.load_video_from_dropdown,
208
+ inputs=[video_dropdown],
209
+ outputs=[video],
210
  )
211
 
212
  with gr.Row():