Qrverse commited on
Commit
de0da4f
·
verified ·
1 Parent(s): 66e9d37

v10.2: Fix art quality — lower P2 strength 0.35→0.12, P2 Monster 2.00→1.30, P1 start 0.00→0.05

Browse files
Files changed (1) hide show
  1. handler.py +28 -26
handler.py CHANGED
@@ -1,19 +1,18 @@
1
  """
2
- QR-Verse AI Art Generator — HuggingFace Inference Endpoint Handler v10
3
 
4
  Two-Pass Pipeline for optimal art quality + QR scannability.
5
 
6
- Problem: Single-pass ControlNet forces a tradeoff — higher CN weight = stronger QR
7
- but worse art. Lower weight = better art but unscannable QR.
 
 
 
8
 
9
- Solution: Decouple art generation from QR reinforcement:
10
- Pass 1 (ART): txt2img + moderate Monster + Brightness → beautiful art with QR hint
11
- Pass 2 (SCAN): img2img + higher Monster, low strength reinforce QR patterns
12
-
13
- Additional improvements over v9:
14
- - Server-side QR generation with pixel-aligned modules (16px/module, no fuzzy edges)
15
- - NEAREST resampling for client QR images (preserves sharp module edges)
16
- - img2img Pass 2 shares all model components with Pass 1 (zero extra VRAM)
17
 
18
  Models:
19
  - Checkpoint: SG161222/Realistic_Vision_V5.1_noVAE (SD 1.5)
@@ -45,25 +44,28 @@ logger = logging.getLogger(__name__)
45
  # Two-pass defaults
46
  # ---------------------------------------------------------------------------
47
 
48
- # Pass 1 — ART FOCUS (txt2img): moderate CN for beautiful art with QR hint
49
- # P1 sweep results: 1.40-1.60 optimal. Lower = prettier art, higher = more scannable.
50
- P1_MONSTER_WEIGHT = 1.50
51
- P1_BRIGHTNESS_WEIGHT = 0.20
52
- P1_MONSTER_START = 0.00
 
53
  P1_MONSTER_END = 0.85
54
 
55
- # Pass 2 — QR REINFORCEMENT (img2img): higher CN + low strength to force QR
56
- P2_MONSTER_WEIGHT = 2.00
57
- P2_BRIGHTNESS_WEIGHT = 0.35
58
- P2_MONSTER_START = 0.00
59
- P2_MONSTER_END = 0.90
60
- P2_CFG = 10.0
61
- P2_STEPS = 25
62
- P2_STRENGTH = 0.35
 
 
63
 
64
  # Brightness timing (both passes)
65
- BRIGHTNESS_START = 0.00
66
- BRIGHTNESS_END = 1.00
67
 
68
  # ---------------------------------------------------------------------------
69
  # Quality tags — NO QR tags (QR structure from ControlNet only)
 
1
  """
2
+ QR-Verse AI Art Generator — HuggingFace Inference Endpoint Handler v10.2
3
 
4
  Two-Pass Pipeline for optimal art quality + QR scannability.
5
 
6
+ v10.2 changes (art quality fix):
7
+ - P1: Monster 1.50→1.00, start 0.00→0.05 (match gold standard timing)
8
+ - P2: Monster 2.00→1.30, strength 0.35→0.12, Brightness 0.35→0.20
9
+ - P2 barely modifies the art (12% denoise) with gentle QR reinforcement
10
+ - Previous v10 P2 was DESTROYING art by overwriting 35% with Monster=2.00
11
 
12
+ Gold standard reference (ComfyUI sequential CN):
13
+ - CN weight: 1.25-1.50, start=0.05, end=0.85
14
+ - Single pass achieves 38% ZBar scan rate with beautiful art
15
+ - diffusers parallel CN requires two-pass to compensate
 
 
 
 
16
 
17
  Models:
18
  - Checkpoint: SG161222/Realistic_Vision_V5.1_noVAE (SD 1.5)
 
44
  # Two-pass defaults
45
  # ---------------------------------------------------------------------------
46
 
47
+ # Pass 1 — ART FOCUS (txt2img): lower CN for beautiful art with subtle QR hint
48
+ # Gold standard uses 1.25-1.50 with start=0.05, end=0.85
49
+ # Diffusers parallel CN is additive, so use lower weight than ComfyUI sequential
50
+ P1_MONSTER_WEIGHT = 1.00
51
+ P1_BRIGHTNESS_WEIGHT = 0.15
52
+ P1_MONSTER_START = 0.05 # Match gold standard — skip earliest denoising for art freedom
53
  P1_MONSTER_END = 0.85
54
 
55
+ # Pass 2 — GENTLE QR reinforcement: barely modify art, just boost scan contrast
56
+ # v10 had Monster=2.00 strength=0.35 which DESTROYED art quality
57
+ # v10.2: gentle touch — 12% denoise with moderate Monster
58
+ P2_MONSTER_WEIGHT = 1.30
59
+ P2_BRIGHTNESS_WEIGHT = 0.20
60
+ P2_MONSTER_START = 0.05
61
+ P2_MONSTER_END = 0.85
62
+ P2_CFG = 8.0
63
+ P2_STEPS = 20
64
+ P2_STRENGTH = 0.12
65
 
66
  # Brightness timing (both passes)
67
+ BRIGHTNESS_START = 0.05
68
+ BRIGHTNESS_END = 0.85
69
 
70
  # ---------------------------------------------------------------------------
71
  # Quality tags — NO QR tags (QR structure from ControlNet only)