lisonallen commited on
Commit
8336ddb
·
1 Parent(s): 1082c60

Limit video length to maximum 5 seconds

Browse files
Files changed (2) hide show
  1. README.md +27 -5
  2. app.py +10 -7
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: FramePack图像到视频生成
3
  emoji: 🎬
4
  colorFrom: indigo
5
  colorTo: purple
@@ -10,23 +10,45 @@ pinned: false
10
  license: mit
11
  ---
12
 
13
- # FramePack
14
 
15
- FramePack是一个图像到视频生成工具,利用扩散模型将静态图像转换为动态视频。
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  ## 特点
18
 
19
  - 使用单张图片生成流畅的动作视频
20
  - 基于HunyuanVideo和FramePack架构
21
  - 支持低显存GPU(最低6GB)运行
22
- - 可以生成最长120秒的视频
23
  - 使用TeaCache技术加速生成过程
24
 
25
  ## 使用方法
26
 
27
  1. 上传一张人物图像
28
  2. 输入描述所需动作的提示词
29
- 3. 设置所需视频长度(秒)
30
  4. 点击"开始生成"按钮
31
  5. 等待视频生成(生成过程是渐进式的,会不断扩展视频长度)
32
 
 
1
  ---
2
+ title: FramePack图像到视频生成(5秒限制版)
3
  emoji: 🎬
4
  colorFrom: indigo
5
  colorTo: purple
 
10
  license: mit
11
  ---
12
 
13
+ # FramePack - Image to Video Generation
14
 
15
+ This is a modified version of the FramePack model with a 5-second maximum video length limit.
16
+
17
+ ## Features
18
+
19
+ - Generate realistic videos from still images
20
+ - Simple and intuitive interface
21
+ - Bilingual support (English/Chinese)
22
+ - Maximum video length of 5 seconds to ensure quick generation times
23
+
24
+ ## Usage
25
+
26
+ 1. Upload an image
27
+ 2. Enter a prompt describing the desired motion
28
+ 3. Adjust parameters if needed (seed, video length, etc.)
29
+ 4. Click "Generate" and wait for the result
30
+
31
+ ## Technical Details
32
+
33
+ This application uses the HunyuanVideo transformer model for image-to-video generation. The model has been optimized to work efficiently with videos up to 5 seconds in length.
34
+
35
+ ## Credits
36
+
37
+ Based on the original FramePack model by lllyasviel.
38
 
39
  ## 特点
40
 
41
  - 使用单张图片生成流畅的动作视频
42
  - 基于HunyuanVideo和FramePack架构
43
  - 支持低显存GPU(最低6GB)运行
44
+ - 可以生成最长5秒的视频
45
  - 使用TeaCache技术加速生成过程
46
 
47
  ## 使用方法
48
 
49
  1. 上传一张人物图像
50
  2. 输入描述所需动作的提示词
51
+ 3. 设置所需视频长度(最大5秒)
52
  4. 点击"开始生成"按钮
53
  5. 等待视频生成(生成过程是渐进式的,会不断扩展视频长度)
54
 
app.py CHANGED
@@ -23,7 +23,7 @@ translations = {
23
  "teacache_info": "Faster speed, but may result in slightly worse finger and hand generation.",
24
  "negative_prompt": "Negative Prompt",
25
  "seed": "Seed",
26
- "video_length": "Video Length (seconds)",
27
  "latent_window": "Latent Window Size",
28
  "steps": "Inference Steps",
29
  "steps_info": "Changing this value is not recommended.",
@@ -55,7 +55,7 @@ translations = {
55
  "teacache_info": "速度更快,但可能会使手指和手的生成效果稍差。",
56
  "negative_prompt": "负面提示词",
57
  "seed": "随机种子",
58
- "video_length": "视频长度(秒)",
59
  "latent_window": "潜在窗口大小",
60
  "steps": "推理步数",
61
  "steps_info": "不建议修改此值。",
@@ -420,6 +420,9 @@ def worker(input_image, prompt, n_prompt, seed, total_second_length, latent_wind
420
  global last_update_time
421
  last_update_time = time.time()
422
 
 
 
 
423
  # 获取模型
424
  try:
425
  models = get_models()
@@ -456,7 +459,7 @@ def worker(input_image, prompt, n_prompt, seed, total_second_length, latent_wind
456
  # 减小处理大小以加快CPU处理
457
  latent_window_size = min(latent_window_size, 5)
458
  steps = min(steps, 15) # 减少步数
459
- total_second_length = min(total_second_length, 2.0) # 限制视频长度
460
 
461
  total_latent_sections = (total_second_length * 30) / (latent_window_size * 4)
462
  total_latent_sections = int(max(round(total_latent_sections), 1))
@@ -1302,7 +1305,7 @@ with block:
1302
  "teacache_info": "Faster speed, but may result in slightly worse finger and hand generation.",
1303
  "negative_prompt": "Negative Prompt",
1304
  "seed": "Seed",
1305
- "video_length": "Video Length (seconds)",
1306
  "latent_window": "Latent Window Size",
1307
  "steps": "Inference Steps",
1308
  "steps_info": "Changing this value is not recommended.",
@@ -1334,7 +1337,7 @@ with block:
1334
  "teacache_info": "速度更快,但可能会使手指和手的生成效果稍差。",
1335
  "negative_prompt": "负面提示词",
1336
  "seed": "随机种子",
1337
- "video_length": "视频长度(秒)",
1338
  "latent_window": "潜在窗口大小",
1339
  "steps": "推理步数",
1340
  "steps_info": "不建议修改此值。",
@@ -1486,9 +1489,9 @@ with block:
1486
  # 添加slider-container类以便CSS触摸优化
1487
  with gr.Group(elem_classes="slider-container"):
1488
  total_second_length = gr.Slider(
1489
- label="Video Length (seconds) / 视频长度(秒)",
1490
  minimum=1,
1491
- maximum=120,
1492
  value=5,
1493
  step=0.1
1494
  )
 
23
  "teacache_info": "Faster speed, but may result in slightly worse finger and hand generation.",
24
  "negative_prompt": "Negative Prompt",
25
  "seed": "Seed",
26
+ "video_length": "Video Length (max 5 seconds)",
27
  "latent_window": "Latent Window Size",
28
  "steps": "Inference Steps",
29
  "steps_info": "Changing this value is not recommended.",
 
55
  "teacache_info": "速度更快,但可能会使手指和手的生成效果稍差。",
56
  "negative_prompt": "负面提示词",
57
  "seed": "随机种子",
58
+ "video_length": "视频长度(最大5秒)",
59
  "latent_window": "潜在窗口大小",
60
  "steps": "推理步数",
61
  "steps_info": "不建议修改此值。",
 
420
  global last_update_time
421
  last_update_time = time.time()
422
 
423
+ # 限制视频长度不超过5秒
424
+ total_second_length = min(total_second_length, 5.0)
425
+
426
  # 获取模型
427
  try:
428
  models = get_models()
 
459
  # 减小处理大小以加快CPU处理
460
  latent_window_size = min(latent_window_size, 5)
461
  steps = min(steps, 15) # 减少步数
462
+ total_second_length = min(total_second_length, 2.0) # CPU模式下进一步限制视频长度
463
 
464
  total_latent_sections = (total_second_length * 30) / (latent_window_size * 4)
465
  total_latent_sections = int(max(round(total_latent_sections), 1))
 
1305
  "teacache_info": "Faster speed, but may result in slightly worse finger and hand generation.",
1306
  "negative_prompt": "Negative Prompt",
1307
  "seed": "Seed",
1308
+ "video_length": "Video Length (max 5 seconds)",
1309
  "latent_window": "Latent Window Size",
1310
  "steps": "Inference Steps",
1311
  "steps_info": "Changing this value is not recommended.",
 
1337
  "teacache_info": "速度更快,但可能会使手指和手的生成效果稍差。",
1338
  "negative_prompt": "负面提示词",
1339
  "seed": "随机种子",
1340
+ "video_length": "视频长度(最大5秒)",
1341
  "latent_window": "潜在窗口大小",
1342
  "steps": "推理步数",
1343
  "steps_info": "不建议修改此值。",
 
1489
  # 添加slider-container类以便CSS触摸优化
1490
  with gr.Group(elem_classes="slider-container"):
1491
  total_second_length = gr.Slider(
1492
+ label="Video Length (max 5 seconds) / 视频长度(最大5秒)",
1493
  minimum=1,
1494
+ maximum=5,
1495
  value=5,
1496
  step=0.1
1497
  )