Nekochu commited on
Commit
19a7c6b
·
1 Parent(s): 284342e

fix: eager model load at startup (lazy load causes SSE timeout)

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -85,7 +85,9 @@ def _load_generator():
85
  return generator
86
 
87
 
88
- GENERATOR = None
 
 
89
 
90
 
91
  def generate(image):
@@ -101,10 +103,6 @@ def generate(image):
101
  from PIL import Image
102
  from torchvision.transforms import functional as F
103
 
104
- global GENERATOR
105
- if GENERATOR is None:
106
- GENERATOR = _load_generator()
107
-
108
  if image is None:
109
  raise gr.Error("Please upload an image.")
110
 
 
85
  return generator
86
 
87
 
88
+ print("[init] Loading model at startup (not lazy)...")
89
+ GENERATOR = _load_generator()
90
+ print("[init] Model ready, starting Gradio...")
91
 
92
 
93
  def generate(image):
 
103
  from PIL import Image
104
  from torchvision.transforms import functional as F
105
 
 
 
 
 
106
  if image is None:
107
  raise gr.Error("Please upload an image.")
108