thankfulcarp commited on
Commit
b6b20fb
Β·
1 Parent(s): afd898a

fps fix and frame fix

Browse files
Files changed (2) hide show
  1. app.py +7 -8
  2. requirements.txt +1 -0
app.py CHANGED
@@ -20,11 +20,6 @@ I2V_BASE_MODEL_ID = "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers" # Used for VAE/encode
20
  I2V_FUSIONX_REPO_ID = "vrgamedevgirl84/Wan14BT2VFusioniX"
21
  I2V_FUSIONX_FILENAME = "Wan14Bi2vFusioniX.safetensors"
22
 
23
- # --- T2V (Text-to-Video) Configuration ---
24
- T2V_BASE_MODEL_ID = "Wan-AI/Wan2.1-T2V-14B-Diffusers"
25
- T2V_LORA_REPO_ID = "vrgamedevgirl84/Wan14BT2VFusioniX"
26
- T2V_LORA_FILENAME = "FusionX_LoRa/Wan2.1_T2V_14B_FusionX_LoRA.safetensors"
27
-
28
  # --- Load Pipelines ---
29
  print("πŸš€ Loading I2V pipeline from single file...")
30
  i2v_pipe = None
@@ -43,7 +38,7 @@ try:
43
 
44
  # Load the main transformer from the repo and filename
45
  i2v_transformer = WanTransformer3DModel.from_single_file(
46
- "https://huggingface.co/vrgamedevgirl84/Wan14BT2VFusioniX/blob/main/Wan14Bi2vFusioniX_fp16.safetensors",
47
  torch_dtype=torch.bfloat16
48
  )
49
 
@@ -74,7 +69,7 @@ SLIDER_MIN_H, SLIDER_MAX_H = 128, 1024
74
  SLIDER_MIN_W, SLIDER_MAX_W = 128, 1024
75
  MAX_SEED = np.iinfo(np.int32).max
76
 
77
- FIXED_FPS = 24
78
  T2V_FIXED_FPS = 16
79
  MIN_FRAMES_MODEL = 8
80
  MAX_FRAMES_MODEL = 81
@@ -149,7 +144,11 @@ def generate_i2v_video(input_image, prompt, height, width,
149
 
150
  target_h = max(MOD_VALUE, (int(height) // MOD_VALUE) * MOD_VALUE)
151
  target_w = max(MOD_VALUE, (int(width) // MOD_VALUE) * MOD_VALUE)
152
- num_frames = np.clip(int(round(duration_seconds * FIXED_FPS)), MIN_FRAMES_MODEL, MAX_FRAMES_MODEL)
 
 
 
 
153
  current_seed = random.randint(0, MAX_SEED) if randomize_seed else int(seed)
154
  resized_image = input_image.resize((target_w, target_h))
155
  enhanced_prompt = f"{prompt}, cinematic quality, smooth motion, detailed animation, dynamic lighting"
 
20
  I2V_FUSIONX_REPO_ID = "vrgamedevgirl84/Wan14BT2VFusioniX"
21
  I2V_FUSIONX_FILENAME = "Wan14Bi2vFusioniX.safetensors"
22
 
 
 
 
 
 
23
  # --- Load Pipelines ---
24
  print("πŸš€ Loading I2V pipeline from single file...")
25
  i2v_pipe = None
 
38
 
39
  # Load the main transformer from the repo and filename
40
  i2v_transformer = WanTransformer3DModel.from_single_file(
41
+ "https://huggingface.co/vrgamedevgirl84/Wan14BT2VFusioniX/blob/main/Wan14Bi2vFusioniX.safetensors",
42
  torch_dtype=torch.bfloat16
43
  )
44
 
 
69
  SLIDER_MIN_W, SLIDER_MAX_W = 128, 1024
70
  MAX_SEED = np.iinfo(np.int32).max
71
 
72
+ FIXED_FPS = 16
73
  T2V_FIXED_FPS = 16
74
  MIN_FRAMES_MODEL = 8
75
  MAX_FRAMES_MODEL = 81
 
144
 
145
  target_h = max(MOD_VALUE, (int(height) // MOD_VALUE) * MOD_VALUE)
146
  target_w = max(MOD_VALUE, (int(width) // MOD_VALUE) * MOD_VALUE)
147
+
148
+ # Calculate and adjust num_frames to be compatible with video codecs
149
+ target_frames = int(round(duration_seconds * FIXED_FPS))
150
+ adjusted_frames = 4 * round((target_frames - 1) / 4) + 1
151
+ num_frames = int(np.clip(adjusted_frames, MIN_FRAMES_MODEL, MAX_FRAMES_MODEL))
152
  current_seed = random.randint(0, MAX_SEED) if randomize_seed else int(seed)
153
  resized_image = input_image.resize((target_w, target_h))
154
  enhanced_prompt = f"{prompt}, cinematic quality, smooth motion, detailed animation, dynamic lighting"
requirements.txt CHANGED
@@ -5,5 +5,6 @@ safetensors
5
  sentencepiece
6
  peft
7
  ftfy
 
8
  imageio-ffmpeg
9
  opencv-python
 
5
  sentencepiece
6
  peft
7
  ftfy
8
+ imageio
9
  imageio-ffmpeg
10
  opencv-python