dagloop5 commited on
Commit
e2e429c
·
verified ·
1 Parent(s): 777a622

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -29
app.py CHANGED
@@ -180,36 +180,69 @@ print("=" * 80)
180
  # =============================================================================
181
  print("Preloading all models for ZeroGPU tensor packing...")
182
  print("This may take a few minutes...")
183
- print(" Running dummy inference to load all model weights...")
184
-
185
- # Create a dummy inference call to force ALL models to load at startup
186
- # This triggers lazy loading for all components without needing internal attribute names
187
- try:
188
- _ = pipeline(
189
- prompt="init",
190
- negative_prompt="",
191
- seed=0,
192
- height=256,
193
- width=256,
194
- num_frames=9, # 8*1+1 = minimum frames
195
- frame_rate=DEFAULT_FRAME_RATE,
196
- num_inference_steps=1, # Single step for dummy init
197
- video_guider_params=MultiModalGuiderParams(
198
- cfg_scale=1.0, stg_scale=0.0, rescale_scale=0.0,
199
- modality_scale=0.0, skip_step=0, stg_blocks=[]
200
- ),
201
- audio_guider_params=MultiModalGuiderParams(
202
- cfg_scale=1.0, stg_scale=0.0, rescale_scale=0.0,
203
- modality_scale=0.0, skip_step=0, stg_blocks=[]
204
- ),
205
- images=[],
206
- enhance_prompt=False,
207
- )
208
- print("All models preloaded for ZeroGPU tensor packing!")
209
- except Exception as e:
210
- print(f"Warning: Dummy inference preload failed (will retry during generation): {e}")
211
- print("Continuing startup...")
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  print("=" * 80)
214
 
215
  # =============================================================================
 
180
  # =============================================================================
181
  print("Preloading all models for ZeroGPU tensor packing...")
182
  print("This may take a few minutes...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
+ # Inspect available attributes on key components
185
+ print(" Inspecting DiffusionStage attributes...")
186
+ stage_attrs = [a for a in dir(pipeline.stage_1) if not a.startswith('__')]
187
+ print(f" DiffusionStage attributes: {stage_attrs}")
188
+
189
+ # For DiffusionStage, the transformer is accessed via _transformer_ctx
190
+ # but we need to trigger actual loading by accessing the context
191
+ if hasattr(pipeline.stage_1, '_transformer_ctx'):
192
+ print(" Loading stage 1 transformer via _transformer_ctx...")
193
+ ctx = pipeline.stage_1._transformer_ctx
194
+ if hasattr(ctx, '__enter__'):
195
+ ctx.__enter__() # Force context entry to load transformer
196
+
197
+ if hasattr(pipeline.stage_2, '_transformer_ctx'):
198
+ print(" Loading stage 2 transformer via _transformer_ctx...")
199
+ ctx = pipeline.stage_2._transformer_ctx
200
+ if hasattr(ctx, '__enter__'):
201
+ ctx.__enter__()
202
+
203
+ # Inspect PromptEncoder attributes
204
+ print(" Inspecting PromptEncoder attributes...")
205
+ pe_attrs = [a for a in dir(pipeline.prompt_encoder) if not a.startswith('__')]
206
+ print(f" PromptEncoder attributes: {pe_attrs}")
207
+
208
+ # Try common names for video encoder in PromptEncoder
209
+ for attr_name in ['video_encoder', '_video_encoder', 'enc', 'encoder', '_enc']:
210
+ if hasattr(pipeline.prompt_encoder, attr_name):
211
+ print(f" Loading video encoder via .{attr_name}...")
212
+ _ = getattr(pipeline.prompt_encoder, attr_name)
213
+ break
214
+
215
+ # Inspect and load VideoDecoder
216
+ print(" Inspecting VideoDecoder attributes...")
217
+ vd_attrs = [a for a in dir(pipeline.video_decoder) if not a.startswith('__')]
218
+ print(f" VideoDecoder attributes: {vd_attrs}")
219
+ for attr_name in ['model', 'decoder', '_model']:
220
+ if hasattr(pipeline.video_decoder, attr_name):
221
+ print(f" Loading video decoder via .{attr_name}...")
222
+ _ = getattr(pipeline.video_decoder, attr_name)
223
+ break
224
+
225
+ # Inspect and load AudioDecoder
226
+ print(" Inspecting AudioDecoder attributes...")
227
+ ad_attrs = [a for a in dir(pipeline.audio_decoder) if not a.startswith('__')]
228
+ print(f" AudioDecoder attributes: {ad_attrs}")
229
+ for attr_name in ['model', 'decoder', '_model']:
230
+ if hasattr(pipeline.audio_decoder, attr_name):
231
+ print(f" Loading audio decoder via .{attr_name}...")
232
+ _ = getattr(pipeline.audio_decoder, attr_name)
233
+ break
234
+
235
+ # Inspect and load VideoUpsampler
236
+ print(" Inspecting VideoUpsampler attributes...")
237
+ up_attrs = [a for a in dir(pipeline.upsampler) if not a.startswith('__')]
238
+ print(f" VideoUpsampler attributes: {up_attrs}")
239
+ for attr_name in ['model', 'upsampler', '_model']:
240
+ if hasattr(pipeline.upsampler, attr_name):
241
+ print(f" Loading spatial upsampler via .{attr_name}...")
242
+ _ = getattr(pipeline.upsampler, attr_name)
243
+ break
244
+
245
+ print("All models preloaded for ZeroGPU tensor packing!")
246
  print("=" * 80)
247
 
248
  # =============================================================================