rahul7star commited on
Commit
8b15bc1
·
verified ·
1 Parent(s): 37700b8

Update app_lora1.py

Browse files
Files changed (1) hide show
  1. app_lora1.py +30 -2
app_lora1.py CHANGED
@@ -91,6 +91,7 @@ def register_scripts(selected_scripts):
91
  # =========================================================
92
  # GPU-ONLY PIPELINE BUILDER (CRITICAL)
93
  # =========================================================
 
94
  @spaces.GPU
95
  def get_pipeline(script_name):
96
  if script_name in PIPELINES:
@@ -99,12 +100,38 @@ def get_pipeline(script_name):
99
  log(f"🔧 Building pipeline from {script_name}")
100
 
101
  namespace = {
 
 
 
 
102
  "torch": torch,
 
 
103
  "DiffusionPipeline": DiffusionPipeline,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
 
106
- # Execute script logic (this WILL touch CUDA)
107
- exec(SCRIPT_CODE[script_name], namespace)
 
 
 
108
 
109
  if "pipe" not in namespace:
110
  raise RuntimeError(f"{script_name} did not define `pipe`")
@@ -115,6 +142,7 @@ def get_pipeline(script_name):
115
  return PIPELINES[script_name]
116
 
117
 
 
118
  # =========================================================
119
  # IMAGE GENERATION (LOGIC UNCHANGED)
120
  # =========================================================
 
91
  # =========================================================
92
  # GPU-ONLY PIPELINE BUILDER (CRITICAL)
93
  # =========================================================
94
+
95
  @spaces.GPU
96
  def get_pipeline(script_name):
97
  if script_name in PIPELINES:
 
100
  log(f"🔧 Building pipeline from {script_name}")
101
 
102
  namespace = {
103
+ "__file__": script_name,
104
+ "__name__": "__main__",
105
+
106
+ # Core
107
  "torch": torch,
108
+
109
+ # Diffusers
110
  "DiffusionPipeline": DiffusionPipeline,
111
+
112
+ # Z-Image specific (imported lazily)
113
+ "ZImagePipeline": __import__(
114
+ "diffusers.pipelines.z_image.pipeline_z_image",
115
+ fromlist=["ZImagePipeline"],
116
+ ).ZImagePipeline,
117
+
118
+ "ZImageTransformer2DModel": __import__(
119
+ "diffusers.models.transformers.z_image_transformer_2d",
120
+ fromlist=["ZImageTransformer2DModel"],
121
+ ).ZImageTransformer2DModel,
122
+
123
+ # Quantization helpers
124
+ "GGUFQuantizationConfig": __import__(
125
+ "diffusers.quantizers.gguf",
126
+ fromlist=["GGUFQuantizationConfig"],
127
+ ).GGUFQuantizationConfig,
128
  }
129
 
130
+ try:
131
+ exec(SCRIPT_CODE[script_name], namespace)
132
+ except Exception as e:
133
+ log(f"❌ Script failed: {script_name}")
134
+ raise RuntimeError(f"Pipeline build failed for {script_name}") from e
135
 
136
  if "pipe" not in namespace:
137
  raise RuntimeError(f"{script_name} did not define `pipe`")
 
142
  return PIPELINES[script_name]
143
 
144
 
145
+
146
  # =========================================================
147
  # IMAGE GENERATION (LOGIC UNCHANGED)
148
  # =========================================================