sejalkishan commited on
Commit
25d9b8c
Β·
verified Β·
1 Parent(s): 6f6b568

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -14,6 +14,8 @@ pipe = CogVideoXPipeline.from_pretrained(
14
  )
15
  pipe.enable_model_cpu_offload() # auto move submodules between CPU/GPU
16
  pipe.vae.enable_slicing() # slice VAE for extra VRAM savings
 
 
17
 
18
  # ────────────────────────────────────────────────────────────
19
  # 2. Resolution parsing & sanitization
@@ -60,8 +62,15 @@ def generate_video(
60
 
61
  # 3.4 Export to MP4 (H.264) with chosen FPS
62
  video_path = export_to_video(resized_frames, "generated.mp4", fps=fps)
 
 
 
 
 
63
  return video_path
64
 
 
 
65
  # ────────────────────────────────────────────────────────────
66
  # 4. Build the Gradio interface with interactive controls
67
  # ────────────────────────────────────────────────────────────
 
14
  )
15
  pipe.enable_model_cpu_offload() # auto move submodules between CPU/GPU
16
  pipe.vae.enable_slicing() # slice VAE for extra VRAM savings
17
+ pipe.enable_attention_slicing()
18
+ pipe.enable_unet_slicing()
19
 
20
  # ────────────────────────────────────────────────────────────
21
  # 2. Resolution parsing & sanitization
 
62
 
63
  # 3.4 Export to MP4 (H.264) with chosen FPS
64
  video_path = export_to_video(resized_frames, "generated.mp4", fps=fps)
65
+
66
+ import torch
67
+ torch.cuda.empty_cache()
68
+ pipe.to("cpu")
69
+
70
  return video_path
71
 
72
+
73
+
74
  # ────────────────────────────────────────────────────────────
75
  # 4. Build the Gradio interface with interactive controls
76
  # ────────────────────────────────────────────────────────────