Spaces:
Running
Running
Update app_lora1.py
Browse files- 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 |
-
# ---
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 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 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
| 187 |
|
| 188 |
-
# --- Execute the full script ---
|
| 189 |
-
namespace = {"torch": torch, "ZImagePipeline": ZImagePipeline}
|
| 190 |
try:
|
| 191 |
-
exec(
|
| 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]
|