Commit Graph

11 Commits

Author SHA1 Message Date
Michele Rossi
8a11325b2f vnassets/background: add bg removal via rembg + isnet-anime
rembg with ONNX Runtime on CPU was chosen over BiRefNet: the latter
requires deform_conv2d which crashes on ROCm bfloat16 and runs at 40s
in float32. rembg delivers 0.23s per 1024x1024 image, no GPU deps,
and isnet-anime is trained specifically on anime images — exactly the
target domain.

CLI and session API both support single-image and batch (plural-first)
modes, reusing one model session across files.
2026-07-08 11:20:36 +02:00
Michele Rossi
d33f3a4e34 Merge TECH_SPEC.md into README.md, fix all inconsistencies
- Consolidate TECH_SPEC into README as single source of truth
- Remove TECH_SPEC.md (375-line README covers everything)
- Fix architecture diagram: Qwen transformer ~5GB → ~20GB (20B params)
- Remove unimplemented CLI flags from docs: --sampler, --scheduler, --clip,
  --vae, --turbo (these don't exist in the actual code)
- Replace 'FP8 native compute' claim with actual FP8→BF16 conversion
- Replace 'peft' with actual diffusers native LoRA loading
- Move aspirational optimizations (VAE overlap, shared encode) to Future
- Resolve stale Open Questions; keep torch.compile as Future item
- Move 'Persistent model session' and 'Qwen Image Edit' from Future to
  implemented status with documented API
- Update performance numbers with actual measured session+flash numbers
- Document flash attention path alongside matmul fallback
- Simplify data flow diagram, remove ComfyUI-only kontext_scale concept
- Remove dead doc links (sdxl-generation.md)
2026-07-08 10:35:28 +02:00
Michele Rossi
97ac841518 Add VnAssetsSession for persistent model lifecycle
- Extract model loading from generate()/edit() into VnAssetsSession class
- Session eagerly loads SDXL + Qwen Image Edit at construction (28s, once)
- Both models held in GPU memory across calls; generate()/edit() reuse them
- generate.py and edit.py become thin wrappers (backwards compatible CLI)
- Context manager (with VnAssetsSession(...) as vna:) for library use
- Metadata backwards-compatible: all fields preserved including lora_load_s
- load_time_s now reflects total session construction, amortized across calls

- Add performance stats for edit path (Qwen Image Edit + Lightning LoRA)
- Benchmark matmul fallback (86.8s) vs flash attention (53.3s, 1.63x speedup)
- Session vs cold start comparison: 2 ops save one 28s load, 5 edits save 112s
- Flash attention via TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 documented
2026-07-08 10:18:42 +02:00
Michele Rossi
e7cde842b3 Improve doc, cleanup 2026-07-08 09:13:46 +02:00
Michele Rossi
9564202e6d feat: add ComfyUI-style prompt weighting via compel
- Support (word:weight), [word], ((nested)) syntax
- Support BREAK for conditioning chunking (.and() translation)
- Use CompelForSDXL (modern API, avoids deprecation)
- Add --raw flag to bypass weighting and fall back to plain encoding
- Update README with Prompt Syntax section and examples
- Add docs/comfyui-prompt-style.md with design doc
2026-07-07 16:16:54 +02:00
Michele Rossi
2cf58aaa5c Move TECH_SPEC.md into project root 2026-07-06 20:21:56 +02:00
Michele Rossi
10d07d44b1 Patch Qwen transformer attention with matmul instead of SDPA
Monkey-patches dispatch_attention_fn to use simple Q@K^T@V matmul,
bypassing SDPA dispatch entirely. Enables editing at full 1024x1024
(was limited to 512x512 due to SDPA crashes) and is ~3x faster.
2026-07-06 20:19:01 +02:00
Michele Rossi
c791b08689 Remove LoRA support, add auto-resize, fix GPU memory cleanup
LoRA loading via PEFT crashes on ROCm; removed since user doesn't need
it. Added automatic downscaling of inputs >512px to avoid O(N^2)
attention explosion in the Qwen transformer (262K tokens at 1024^2
exceeds GPU capability). Added explicit GPU memory cleanup after each
command to prevent OOM when chaining generate + edit.
2026-07-06 19:15:15 +02:00
Michele Rossi
d7d67223b8 Document edit command and performance in README 2026-07-06 18:07:26 +02:00
Michele Rossi
ed124b1cbb Add vnasset edit command
Qwen Image Edit pipeline with FP8 Safetensors loading.
Uses init_empty_weights for memory-efficient 40GB model loading.
bf16 dtype to avoid ROCm crashes; falls back to math SDPA.
2026-07-06 18:06:47 +02:00
Michele Rossi
06fba9c234 Add vnasset SDXL generate command
ROCm-safe bfloat16 inference with custom matmul attention.
Automatic output directories, random seed, timing metadata.
2026-07-06 16:29:38 +02:00