🐛 Fix overnight generator bug - properly import generate_assets_full module
This commit is contained in:
@@ -7,7 +7,6 @@ Z avtomatskim Git commitom in progress trackingom
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
import requests
|
import requests
|
||||||
@@ -37,10 +36,8 @@ def log(msg):
|
|||||||
line = f"[{ts}] {msg}"
|
line = f"[{ts}] {msg}"
|
||||||
print(line)
|
print(line)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
# Also write to progress log
|
|
||||||
with open(PROGRESS_LOG, 'a') as f:
|
with open(PROGRESS_LOG, 'a') as f:
|
||||||
f.write(line + "\\n")
|
f.write(line + "\n")
|
||||||
|
|
||||||
def git_commit(file_path, category, name):
|
def git_commit(file_path, category, name):
|
||||||
try:
|
try:
|
||||||
@@ -51,18 +48,15 @@ def git_commit(file_path, category, name):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Load FULL registry from existing script
|
# Load FULL registry safely
|
||||||
sys.path.insert(0, str(REPO_DIR / "scripts"))
|
sys.path.insert(0, str(REPO_DIR / "scripts"))
|
||||||
exec(open(REPO_DIR / "scripts/generate_assets_full.py").read().replace('if __name__', 'if False'))
|
import generate_assets_full
|
||||||
|
ALL_ASSETS = generate_assets_full.generate_registry()
|
||||||
# Get all assets EXCEPT NPCs
|
|
||||||
ALL_ASSETS = generate_registry()
|
|
||||||
FILTERED_ASSETS = [a for a in ALL_ASSETS if a['cat'] != 'npcs']
|
FILTERED_ASSETS = [a for a in ALL_ASSETS if a['cat'] != 'npcs']
|
||||||
|
|
||||||
def create_workflow(prompt_text, output_name, size=512):
|
def create_workflow(prompt_text, output_name, size=512):
|
||||||
seed = int(time.time() * 1000) % 2147483647
|
seed = int(time.time() * 1000) % 2147483647
|
||||||
full_prompt = f"{STYLE}, {prompt_text}"
|
full_prompt = f"{STYLE}, {prompt_text}"
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"1": {"class_type": "CheckpointLoaderSimple", "inputs": {"ckpt_name": "dreamshaper_8.safetensors"}},
|
"1": {"class_type": "CheckpointLoaderSimple", "inputs": {"ckpt_name": "dreamshaper_8.safetensors"}},
|
||||||
"2": {"class_type": "EmptyLatentImage", "inputs": {"width": size, "height": size, "batch_size": 1}},
|
"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):
|
def wait_completion(prompt_id, timeout=120):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
while time.time() - start < timeout:
|
while time.time() < start + timeout:
|
||||||
try:
|
try:
|
||||||
r = requests.get(f"{COMFYUI_URL}/history/{prompt_id}", timeout=5)
|
r = requests.get(f"{COMFYUI_URL}/history/{prompt_id}", timeout=5)
|
||||||
if prompt_id in r.json() and r.json()[prompt_id].get("outputs"):
|
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():
|
def main():
|
||||||
log("="*70)
|
log("="*70)
|
||||||
log("🌙 NOČNA GENERACIJA - FULL Asset Set")
|
log("🌙 DAYTIME GENERATION - FULL Asset Set")
|
||||||
log(" BREZ NPCs in glavnih karakterjev")
|
log(" BREZ NPCs in glavnih karakterjev")
|
||||||
log("="*70)
|
log("="*70)
|
||||||
|
|
||||||
# Check ComfyUI
|
|
||||||
try:
|
try:
|
||||||
r = requests.get(f"{COMFYUI_URL}/system_stats", timeout=5)
|
r = requests.get(f"{COMFYUI_URL}/system_stats", timeout=5)
|
||||||
log(f"✅ ComfyUI v{r.json()['system']['comfyui_version']}")
|
log(f"✅ ComfyUI v{r.json()['system']['comfyui_version']}")
|
||||||
@@ -132,21 +125,19 @@ def main():
|
|||||||
log("❌ ComfyUI not running!")
|
log("❌ ComfyUI not running!")
|
||||||
return
|
return
|
||||||
|
|
||||||
log(f"\\n📊 Registry Statistics:")
|
log(f"\n📊 Registry Statistics:")
|
||||||
log(f" Total assets: {len(ALL_ASSETS)}")
|
log(f" Total assets: {len(ALL_ASSETS)}")
|
||||||
log(f" NPCs (excluded): {len([a for a in ALL_ASSETS if a['cat'] == 'npcs'])}")
|
log(f" NPCs (excluded): {len([a for a in ALL_ASSETS if a['cat'] == 'npcs'])}")
|
||||||
log(f" FILTERED (to generate): {len(FILTERED_ASSETS)}")
|
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())
|
existing = sum(1 for a in FILTERED_ASSETS if (OUTPUT_DIR / a['cat'] / a['file']).exists())
|
||||||
to_generate = len(FILTERED_ASSETS) - existing
|
to_generate = len(FILTERED_ASSETS) - existing
|
||||||
|
|
||||||
log(f"\\n📁 File Status:")
|
log(f"\n📁 File Status:")
|
||||||
log(f" Already exist: {existing}")
|
log(f" Already exist: {existing}")
|
||||||
log(f" To generate: {to_generate}")
|
log(f" To generate: {to_generate}")
|
||||||
|
|
||||||
# Category breakdown
|
log(f"\n📦 By Category:")
|
||||||
log(f"\\n📦 By Category:")
|
|
||||||
cats = {}
|
cats = {}
|
||||||
for a in FILTERED_ASSETS:
|
for a in FILTERED_ASSETS:
|
||||||
cats[a['cat']] = cats.get(a['cat'], 0) + 1
|
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)")
|
log(f" {cat:20s}: {count:4d} total ({existing_cat} exist, {count-existing_cat} to gen)")
|
||||||
|
|
||||||
if to_generate == 0:
|
if to_generate == 0:
|
||||||
log("\\n✅ All assets already generated!")
|
log("\n✅ All assets already generated!")
|
||||||
return
|
return
|
||||||
|
|
||||||
log(f"\\n🚀 Starting generation of {to_generate} assets...")
|
log(f"\n🚀 Starting generation of {to_generate} assets...")
|
||||||
log(f" ETA: ~{to_generate * 20 / 3600:.1f} hours\\n")
|
log(f" ETA: ~{to_generate * 20 / 3600:.1f} hours\n")
|
||||||
|
|
||||||
success, skip, fail = 0, 0, 0
|
success, skip, fail = 0, 0, 0
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -175,37 +166,34 @@ def main():
|
|||||||
|
|
||||||
log(f"[{i}/{len(FILTERED_ASSETS)}] 🎨 {asset['cat']}/{asset['file'][:40]}")
|
log(f"[{i}/{len(FILTERED_ASSETS)}] 🎨 {asset['cat']}/{asset['file'][:40]}")
|
||||||
|
|
||||||
# Boss size larger
|
|
||||||
size = 768 if asset['cat'] == 'bosses' else 512
|
size = 768 if asset['cat'] == 'bosses' else 512
|
||||||
wf = create_workflow(asset['prompt'], asset['file'].replace('.png', ''), size)
|
wf = create_workflow(asset['prompt'], asset['file'].replace('.png', ''), size)
|
||||||
pid = queue_prompt(wf)
|
pid = queue_prompt(wf)
|
||||||
|
|
||||||
if pid and wait_completion(pid) and download_and_process(pid, path):
|
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'])
|
git_commit(path, asset['cat'], asset['file'])
|
||||||
success += 1
|
success += 1
|
||||||
else:
|
else:
|
||||||
log(f" ❌ FAILED")
|
log(f" ❌ FAILED")
|
||||||
fail += 1
|
fail += 1
|
||||||
|
|
||||||
# Progress update every 10
|
|
||||||
if i % 10 == 0:
|
if i % 10 == 0:
|
||||||
elapsed = time.time() - start_time
|
elapsed = time.time() - start_time
|
||||||
per_asset = elapsed / (success + fail) if (success + fail) > 0 else 20
|
per_asset = elapsed / (success + fail) if (success + fail) > 0 else 20
|
||||||
remaining = per_asset * (to_generate - success - fail)
|
remaining = per_asset * (to_generate - success - fail)
|
||||||
log(f"\\n📊 [{i}/{len(FILTERED_ASSETS)}] ✅{success} ⏭️ {skip} ❌{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" ⏱️ Elapsed: {elapsed/60:.1f}m | ETA: {remaining/60:.1f}m\n")
|
||||||
|
|
||||||
elapsed = time.time() - start_time
|
elapsed = time.time() - start_time
|
||||||
log("\\n" + "="*70)
|
log("\n" + "="*70)
|
||||||
log("🌙 NOČNA GENERACIJA COMPLETE!")
|
log("🎨 GENERATION COMPLETE!")
|
||||||
log(f" ✅ Success: {success}")
|
log(f" ✅ Success: {success}")
|
||||||
log(f" ⏭️ Skipped: {skip}")
|
log(f" ⏭️ Skipped: {skip}")
|
||||||
log(f" ❌ Failed: {fail}")
|
log(f" ❌ Failed: {fail}")
|
||||||
log(f" ⏱️ Total time: {elapsed/3600:.1f} hours")
|
log(f" ⏱️ Total time: {elapsed/3600:.1f} hours")
|
||||||
log(f" 📁 Output: {OUTPUT_DIR}")
|
log(f" 📁 Output: {OUTPUT_DIR}")
|
||||||
log("="*70)
|
log("="*70)
|
||||||
log("\\n💤 Lahko greste spat - vse je avtomatsko!")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user