seawolf2357 commited on
Commit
41fb2d4
·
verified ·
1 Parent(s): f00f427

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -15
app.py CHANGED
@@ -14,7 +14,6 @@ import numpy as np
14
  from PIL import Image
15
  import random
16
  import gc
17
- from optimization import optimize_pipeline_
18
 
19
 
20
  # =========================================================
@@ -41,12 +40,14 @@ MAX_DURATION = round(MAX_FRAMES_MODEL/FIXED_FPS, 1)
41
  # =========================================================
42
  # MODEL LOADING
43
  # =========================================================
 
44
  vae = AutoencoderKLWan.from_pretrained(
45
  "Wan-AI/Wan2.2-T2V-A14B-Diffusers",
46
  subfolder="vae",
47
  torch_dtype=torch.float32
48
  )
49
 
 
50
  pipe = WanPipeline.from_pretrained(
51
  MODEL_ID,
52
  transformer=WanTransformer3DModel.from_pretrained(
@@ -65,18 +66,13 @@ pipe = WanPipeline.from_pretrained(
65
  torch_dtype=torch.bfloat16,
66
  ).to('cuda')
67
 
 
68
  for i in range(3):
69
  gc.collect()
70
  torch.cuda.synchronize()
71
  torch.cuda.empty_cache()
72
 
73
- optimize_pipeline_(
74
- pipe,
75
- prompt='prompt',
76
- height=LANDSCAPE_HEIGHT,
77
- width=LANDSCAPE_WIDTH,
78
- num_frames=MAX_FRAMES_MODEL,
79
- )
80
 
81
  # =========================================================
82
  # DEFAULT PROMPTS
@@ -96,10 +92,6 @@ Rules:
96
  4. Keep the enhanced prompt concise but detailed (max 150 words)
97
  5. Maintain the original intent of the user's prompt
98
  6. Output ONLY the enhanced prompt, nothing else
99
-
100
- Example:
101
- User: "A cat playing"
102
- Enhanced: "A fluffy orange tabby cat playfully batting at a dangling yarn ball, soft afternoon sunlight streaming through a window creating warm golden highlights on its fur, smooth tracking shot following the cat's graceful movements, shallow depth of field with bokeh background, cozy living room setting with warm ambient lighting"
103
  """
104
 
105
 
@@ -180,8 +172,8 @@ def generate_video(
180
  output_frames_list = pipe(
181
  prompt=final_prompt,
182
  negative_prompt=negative_prompt,
183
- height=480,
184
- width=832,
185
  num_frames=num_frames,
186
  guidance_scale=float(guidance_scale),
187
  guidance_scale_2=float(guidance_scale_2),
@@ -202,7 +194,7 @@ def generate_video(
202
  • Duration: {actual_duration:.2f} seconds
203
  • Total Frames: {num_frames}
204
  • FPS: {FIXED_FPS}
205
- • Resolution: 832 x 480
206
  {'=' * 50}
207
  ⚙️ Generation Settings:
208
  • Guidance Scale: {guidance_scale} / {guidance_scale_2}
 
14
  from PIL import Image
15
  import random
16
  import gc
 
17
 
18
 
19
  # =========================================================
 
40
  # =========================================================
41
  # MODEL LOADING
42
  # =========================================================
43
+ print("Loading VAE...")
44
  vae = AutoencoderKLWan.from_pretrained(
45
  "Wan-AI/Wan2.2-T2V-A14B-Diffusers",
46
  subfolder="vae",
47
  torch_dtype=torch.float32
48
  )
49
 
50
+ print("Loading pipeline...")
51
  pipe = WanPipeline.from_pretrained(
52
  MODEL_ID,
53
  transformer=WanTransformer3DModel.from_pretrained(
 
66
  torch_dtype=torch.bfloat16,
67
  ).to('cuda')
68
 
69
+ # Memory cleanup
70
  for i in range(3):
71
  gc.collect()
72
  torch.cuda.synchronize()
73
  torch.cuda.empty_cache()
74
 
75
+ print("Pipeline loaded successfully!")
 
 
 
 
 
 
76
 
77
  # =========================================================
78
  # DEFAULT PROMPTS
 
92
  4. Keep the enhanced prompt concise but detailed (max 150 words)
93
  5. Maintain the original intent of the user's prompt
94
  6. Output ONLY the enhanced prompt, nothing else
 
 
 
 
95
  """
96
 
97
 
 
172
  output_frames_list = pipe(
173
  prompt=final_prompt,
174
  negative_prompt=negative_prompt,
175
+ height=LANDSCAPE_HEIGHT,
176
+ width=LANDSCAPE_WIDTH,
177
  num_frames=num_frames,
178
  guidance_scale=float(guidance_scale),
179
  guidance_scale_2=float(guidance_scale_2),
 
194
  • Duration: {actual_duration:.2f} seconds
195
  • Total Frames: {num_frames}
196
  • FPS: {FIXED_FPS}
197
+ • Resolution: {LANDSCAPE_WIDTH} x {LANDSCAPE_HEIGHT}
198
  {'=' * 50}
199
  ⚙️ Generation Settings:
200
  • Guidance Scale: {guidance_scale} / {guidance_scale_2}