rahul7star commited on
Commit
c74f8b8
·
verified ·
1 Parent(s): 0541caa

Update app_lora1.py

Browse files
Files changed (1) hide show
  1. app_lora1.py +12 -22
app_lora1.py CHANGED
@@ -163,32 +163,20 @@ def get_pipeline(script_name):
163
  return PIPELINES[script_name]
164
 
165
  log(f"🔧 Building pipeline from {script_name}")
166
- code = SCRIPT_CODE[script_name]
167
 
168
- # --- Extract lines after from_pretrained for logging ---
169
- pipe_lines = []
170
- found_pretrained = False
171
- for line in code.splitlines():
172
- stripped = line.strip()
173
- if not found_pretrained and stripped.startswith("pipe = ZImagePipeline.from_pretrained"):
174
- found_pretrained = True
175
- pipe_lines.append(line)
176
- elif found_pretrained:
177
- # Capture subsequent pipe method calls (like layerwise casting)
178
- if stripped.startswith("pipe.") or stripped == "":
179
- pipe_lines.append(line)
180
- else:
181
- break
182
 
183
- # Log each line
184
- for line in pipe_lines:
185
- if line.strip():
186
- log(f"• {line.strip()}")
 
187
 
188
- # --- Execute the full script ---
189
- namespace = {"torch": torch, "ZImagePipeline": ZImagePipeline}
190
  try:
191
- exec(code, namespace)
192
  except Exception as e:
193
  log(f"❌ Script failed: {script_name}")
194
  raise RuntimeError(f"Pipeline build failed for {script_name}") from e
@@ -201,8 +189,10 @@ def get_pipeline(script_name):
201
 
202
  PIPELINES[script_name] = namespace["pipe"]
203
  log(f"✅ Pipeline ready: {script_name}")
 
204
  return PIPELINES[script_name]
205
 
 
206
  def get_pipeline_fallback(script_name):
207
  if script_name in PIPELINES:
208
  return PIPELINES[script_name]
 
163
  return PIPELINES[script_name]
164
 
165
  log(f"🔧 Building pipeline from {script_name}")
 
166
 
167
+ # --- Log full .py file ---
168
+ log("=== SCRIPT CONTENT START ===")
169
+ log(SCRIPT_CODE[script_name])
170
+ log("=== SCRIPT CONTENT END ===")
 
 
 
 
 
 
 
 
 
 
171
 
172
+ namespace = {
173
+ "__file__": script_name,
174
+ "__name__": "__main__",
175
+ "torch": torch,
176
+ }
177
 
 
 
178
  try:
179
+ exec(SCRIPT_CODE[script_name], namespace)
180
  except Exception as e:
181
  log(f"❌ Script failed: {script_name}")
182
  raise RuntimeError(f"Pipeline build failed for {script_name}") from e
 
189
 
190
  PIPELINES[script_name] = namespace["pipe"]
191
  log(f"✅ Pipeline ready: {script_name}")
192
+
193
  return PIPELINES[script_name]
194
 
195
+
196
  def get_pipeline_fallback(script_name):
197
  if script_name in PIPELINES:
198
  return PIPELINES[script_name]