dagloop5 commited on
Commit
ad9a360
·
verified ·
1 Parent(s): 972c160

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -3
app.py CHANGED
@@ -175,6 +175,39 @@ pipeline = TI2VidTwoStagesHQPipeline(
175
  print("Pipeline initialized successfully!")
176
  print("=" * 80)
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  # =============================================================================
179
  # Helper Functions
180
  # =============================================================================
@@ -310,10 +343,10 @@ def get_duration(
310
  base += 15
311
 
312
  # More frames means more processing
313
- if num_frames > 81:
 
 
314
  base += 10
315
-
316
- return min(base, 90)
317
 
318
 
319
  @spaces.GPU(duration=get_duration)
 
175
  print("Pipeline initialized successfully!")
176
  print("=" * 80)
177
 
178
+ # =============================================================================
179
+ # ZeroGPU Tensor Preloading
180
+ # =============================================================================
181
+ # ZeroGPU needs all tensors to be loaded BEFORE the Space starts.
182
+ # We trigger model loading here so ZeroGPU can pack them into shared GPU memory.
183
+
184
+ print("Preloading all models for ZeroGPU tensor packing...")
185
+ print("This may take a few minutes...")
186
+
187
+ # Access all pipeline components to force tensor loading
188
+ # These are accessed but stored as lambda closures so ZeroGPU packs them
189
+ _transformer = pipeline.stage_1.transformer
190
+ _video_encoder = pipeline.prompt_encoder.video_encoder
191
+ _video_decoder = pipeline.video_decoder
192
+ _audio_decoder = pipeline.audio_decoder
193
+ _spatial_upsampler = pipeline.upsampler
194
+
195
+ # Trigger actual loading by calling them once
196
+ # This forces tensors into memory so ZeroGPU can pack them
197
+ print(" Loading transformer...")
198
+ _transformer()
199
+ print(" Loading video encoder...")
200
+ _video_encoder()
201
+ print(" Loading video decoder...")
202
+ _video_decoder()
203
+ print(" Loading audio decoder...")
204
+ _audio_decoder()
205
+ print(" Loading spatial upsampler...")
206
+ _spatial_upsampler()
207
+
208
+ print("All models preloaded for ZeroGPU tensor packing!")
209
+ print("=" * 80)
210
+
211
  # =============================================================================
212
  # Helper Functions
213
  # =============================================================================
 
343
  base += 15
344
 
345
  # More frames means more processing
346
+ # Calculate num_frames inside get_duration since it's no longer a parameter
347
+ frames_from_duration = int(duration * DEFAULT_FRAME_RATE)
348
+ if frames_from_duration > 81:
349
  base += 10
 
 
350
 
351
 
352
  @spaces.GPU(duration=get_duration)