DawnC commited on
Commit
4bc6ab0
·
verified ·
1 Parent(s): 2974931

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import sys
2
  import traceback
3
  import warnings
@@ -20,6 +21,27 @@ def launch_final_blend_sceneweaver(share: bool = True, debug: bool = False):
20
  ui = UIManager()
21
  print("✅ UIManager instance created successfully")
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  # Launch UI
24
  print("🚀 Launching interface...")
25
  interface = ui.launch(share=share, debug=debug)
@@ -78,4 +100,4 @@ def main():
78
  raise
79
 
80
  if __name__ == "__main__":
81
- main()
 
1
+ import os
2
  import sys
3
  import traceback
4
  import warnings
 
21
  ui = UIManager()
22
  print("✅ UIManager instance created successfully")
23
 
24
+ # Pre-load inpainting pipeline on Hugging Face Spaces
25
+ # This ensures first request doesn't timeout due to model loading
26
+ if os.getenv('SPACE_ID'):
27
+ print("\n🔧 Detected Hugging Face Spaces environment")
28
+ print("⏳ Pre-loading inpainting pipeline to avoid first-request timeout...")
29
+ try:
30
+ success = ui.sceneweaver.switch_to_inpainting_mode(
31
+ conditioning_type='canny',
32
+ progress_callback=lambda msg, pct: print(f" [{pct:3d}%] {msg}")
33
+ )
34
+ if success:
35
+ print("✅ Inpainting pipeline pre-loaded successfully!")
36
+ print(" All requests will now complete within 300s limit")
37
+ else:
38
+ print("⚠️ Pre-load failed, will load on first request")
39
+ print(" (First inpainting request may timeout)")
40
+ except Exception as e:
41
+ print(f"⚠️ Pre-load warning: {e}")
42
+ print(" Continuing anyway - will load on demand")
43
+ print()
44
+
45
  # Launch UI
46
  print("🚀 Launching interface...")
47
  interface = ui.launch(share=share, debug=debug)
 
100
  raise
101
 
102
  if __name__ == "__main__":
103
+ main()