🧪 Forge Grid: LoRa x Sampler x Scheduler script
下载文件 (1)
关于此版本
⚙️ Core Logic
🛑 Integrated state.interrupt()
Stop button now halts generation predictably in both XY Grid and Batch Grid modes.
Added
if state.interrupted:checks with graceful early exits usingsafe_processed().Handles all nested loops to prevent Forge from hanging during interruption.
🧩 Grid Layout Logging
Added console info before generation:
🧩 XY Grid layout → rows=..., cols=..., samplers=..., schedulers=..., weights=...Helps visualize grid setup and total iteration count.
↕️ LoRA Weight Orientation Fix
When LoRA Label Position =
⬅️ Leftor➡️ Right,
→ LoRA weights are now ordered bottom (min) → top (max),
matching intuitive Y-axis behavior.Implemented by reversing the
current_weightslist before XY Grid generation.
🎨 Prompt / LoRA Handling
🧠 Rewritten apply_params()
LoRA is skipped entirely when
weight == 0.0.
→ No LoRA tag or trigger word is added to the prompt.Prevents duplicate trigger words or
<lora:...>tags.Cleans redundant commas/spaces, keeping prompt formatting consistent.
New prompt assembly order:
[main prompt], <lora:name:weight>, triggerMetadata no longer contains stray “, , , , ,”.
🧩 XY Grid
✅ Improved generation loop
Proper row/column indexing for vertical vs. horizontal orientation.
Ensures every generated cell is saved when
save_cells=True.Compatible with all label positions (
Top,Bottom,Left,Right).
🧾 Enhanced logging
Each iteration now prints detailed progress:
🔄[7/36] Sampler='Euler a', Scheduler='Automatic', LoRA='Apone3d', Weight=0.50, Seed=...Uniform logging style between XY and Batch grids.
🧩 Batch Grid
⚙️ Refined control flow
Added
state.interrupt()safety checks to every nested loop.Clean exit with clear logs:
🛑 Generation manually stopped by user.LoRA weight = 0.0 now behaves identically to XY Grid —
no LoRA, no trigger applied.
🧩 Grid validation & saving
Improved
validate_cells_for_grid()output:🚫 Grid validation issues: ❌ Cell [1,2] is None ...Prevents saving empty or invalid grids.
Saved cell filenames now include all relevant parameters:
LoRA_W0.50_S-Euler_SchAutomatic_1_2.webp
💬 Logging & UX
Consistent emoji-coded messages:
🏁 start • 🔄 progress • 💾 save • 🛑 interrupt • ✅ done • ❌ errorAll
print()calls useflush=True→ immediate terminal output.Added
gc.collect()after grid creation for better memory cleanup.
🧰 Internal Improvements
Removed redundant
build_grid_labels()calls.Simplified nested loop logic and unified naming (
sampler_label,scheduler_label).Standardized
get_cell_indices()parameters andorientationhandling.Minor refactors for clarity and alignment with Forge UI behavior.
🧾 Summary
🛑 Stop Handling: Integrated state.interrupt()→ Predictable halts
↕️ Vertical LoRA: Reversed weights → Bottom=min - Top=max
🧠 Prompt Logic: Rebuilt apply_params()→ Clean, deduplicated prompts
🧩 XY Grid: Added layout logging → Clear grid overview
🧱 Batch Grid: Unified LoRA & trigger logic → Consistent output
💬 Logging: Emoji + flush → Readable, real-time feedback
🧹 Memory: Added gc.collect() → No residual memory buildup






