From f0eafa5332b6abfaa70ebc235e4276f59e244fb3 Mon Sep 17 00:00:00 2001 From: David Kotnik Date: Mon, 29 Dec 2025 09:08:17 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20overnight=20generator=20bu?= =?UTF-8?q?g=20-=20properly=20import=20generate=5Fassets=5Ffull=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/generate_full_overnight.py | 46 +++++++++++------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/scripts/generate_full_overnight.py b/scripts/generate_full_overnight.py index 661a53649..2b9e0c5d7 100755 --- a/scripts/generate_full_overnight.py +++ b/scripts/generate_full_overnight.py @@ -7,7 +7,6 @@ Z avtomatskim Git commitom in progress trackingom import os import sys -import json import time import uuid import requests @@ -37,10 +36,8 @@ def log(msg): line = f"[{ts}] {msg}" print(line) sys.stdout.flush() - - # Also write to progress log with open(PROGRESS_LOG, 'a') as f: - f.write(line + "\\n") + f.write(line + "\n") def git_commit(file_path, category, name): try: @@ -51,18 +48,15 @@ def git_commit(file_path, category, name): except: return False -# Load FULL registry from existing script +# Load FULL registry safely sys.path.insert(0, str(REPO_DIR / "scripts")) -exec(open(REPO_DIR / "scripts/generate_assets_full.py").read().replace('if __name__', 'if False')) - -# Get all assets EXCEPT NPCs -ALL_ASSETS = generate_registry() +import generate_assets_full +ALL_ASSETS = generate_assets_full.generate_registry() FILTERED_ASSETS = [a for a in ALL_ASSETS if a['cat'] != 'npcs'] def create_workflow(prompt_text, output_name, size=512): seed = int(time.time() * 1000) % 2147483647 full_prompt = f"{STYLE}, {prompt_text}" - return { "1": {"class_type": "CheckpointLoaderSimple", "inputs": {"ckpt_name": "dreamshaper_8.safetensors"}}, "2": {"class_type": "EmptyLatentImage", "inputs": {"width": size, "height": size, "batch_size": 1}}, @@ -91,7 +85,7 @@ def queue_prompt(workflow): def wait_completion(prompt_id, timeout=120): start = time.time() - while time.time() - start < timeout: + while time.time() < start + timeout: try: r = requests.get(f"{COMFYUI_URL}/history/{prompt_id}", timeout=5) if prompt_id in r.json() and r.json()[prompt_id].get("outputs"): @@ -120,11 +114,10 @@ def download_and_process(prompt_id, output_path): def main(): log("="*70) - log("πŸŒ™ NOČNA GENERACIJA - FULL Asset Set") + log("πŸŒ™ DAYTIME GENERATION - FULL Asset Set") log(" BREZ NPCs in glavnih karakterjev") log("="*70) - # Check ComfyUI try: r = requests.get(f"{COMFYUI_URL}/system_stats", timeout=5) log(f"βœ… ComfyUI v{r.json()['system']['comfyui_version']}") @@ -132,21 +125,19 @@ def main(): log("❌ ComfyUI not running!") return - log(f"\\nπŸ“Š Registry Statistics:") + log(f"\nπŸ“Š Registry Statistics:") log(f" Total assets: {len(ALL_ASSETS)}") log(f" NPCs (excluded): {len([a for a in ALL_ASSETS if a['cat'] == 'npcs'])}") log(f" FILTERED (to generate): {len(FILTERED_ASSETS)}") - # Count existing existing = sum(1 for a in FILTERED_ASSETS if (OUTPUT_DIR / a['cat'] / a['file']).exists()) to_generate = len(FILTERED_ASSETS) - existing - log(f"\\nπŸ“ File Status:") + log(f"\nπŸ“ File Status:") log(f" Already exist: {existing}") log(f" To generate: {to_generate}") - # Category breakdown - log(f"\\nπŸ“¦ By Category:") + log(f"\nπŸ“¦ By Category:") cats = {} for a in FILTERED_ASSETS: cats[a['cat']] = cats.get(a['cat'], 0) + 1 @@ -155,11 +146,11 @@ def main(): log(f" {cat:20s}: {count:4d} total ({existing_cat} exist, {count-existing_cat} to gen)") if to_generate == 0: - log("\\nβœ… All assets already generated!") + log("\nβœ… All assets already generated!") return - log(f"\\nπŸš€ Starting generation of {to_generate} assets...") - log(f" ETA: ~{to_generate * 20 / 3600:.1f} hours\\n") + log(f"\nπŸš€ Starting generation of {to_generate} assets...") + log(f" ETA: ~{to_generate * 20 / 3600:.1f} hours\n") success, skip, fail = 0, 0, 0 start_time = time.time() @@ -175,37 +166,34 @@ def main(): log(f"[{i}/{len(FILTERED_ASSETS)}] 🎨 {asset['cat']}/{asset['file'][:40]}") - # Boss size larger size = 768 if asset['cat'] == 'bosses' else 512 wf = create_workflow(asset['prompt'], asset['file'].replace('.png', ''), size) pid = queue_prompt(wf) if pid and wait_completion(pid) and download_and_process(pid, path): - log(f" βœ… Done | Auto-committed") + log(f" βœ… Done") git_commit(path, asset['cat'], asset['file']) success += 1 else: log(f" ❌ FAILED") fail += 1 - # Progress update every 10 if i % 10 == 0: elapsed = time.time() - start_time per_asset = elapsed / (success + fail) if (success + fail) > 0 else 20 remaining = per_asset * (to_generate - success - fail) - log(f"\\nπŸ“Š [{i}/{len(FILTERED_ASSETS)}] βœ…{success} ⏭️ {skip} ❌{fail}") - log(f" ⏱️ Elapsed: {elapsed/60:.1f}m | ETA: {remaining/60:.1f}m\\n") + log(f"\nπŸ“Š [{i}/{len(FILTERED_ASSETS)}] βœ…{success} ⏭️ {skip} ❌{fail}") + log(f" ⏱️ Elapsed: {elapsed/60:.1f}m | ETA: {remaining/60:.1f}m\n") elapsed = time.time() - start_time - log("\\n" + "="*70) - log("πŸŒ™ NOČNA GENERACIJA COMPLETE!") + log("\n" + "="*70) + log("🎨 GENERATION COMPLETE!") log(f" βœ… Success: {success}") log(f" ⏭️ Skipped: {skip}") log(f" ❌ Failed: {fail}") log(f" ⏱️ Total time: {elapsed/3600:.1f} hours") log(f" πŸ“ Output: {OUTPUT_DIR}") log("="*70) - log("\\nπŸ’€ Lahko greste spat - vse je avtomatsko!") if __name__ == "__main__": main()