Where to Trust the Stroke: Per-Pixel Conformance Maps for Freehand Sketch-to-Image Diffusion

People draw some parts of a sketch carefully and scribble the rest. The outline of a face or the edge of a table may be deliberate, while the background trees are loose, shaky loops. Current sketch-to-image systems handle the whole canvas one way. Edge-conditioned adapters such as T2I-Adapter trust every pixel of the sketch, so wobbly lines drag the image into distorted, cartoonish shapes. Methods built for realism, such as noise injection in SDEdit, low-pass filtering in DiSS, or semantic embeddings in SketchingReality, trust no pixel precisely, so the thin lines the user meant to keep get blurred away. This note proposes a small convolutional network that reads a sketch in one pass and outputs a per-pixel "how much to trust this stroke" map. The map decides, location by location, whether stroke features reach a frozen diffusion model at full resolution or only as a coarse layout hint.

The opportunity comes from a tension in the literature. Work on resolution loss, such as LIP, shows that learned downsampling keeps thin, weak features alive. Work on freehand sketches shows that keeping high-frequency detail keeps the human jitter too. No existing method separates the thin strokes worth preserving from the jitter worth discarding. The map is trained only on synthetic edge maps that have been deformed by known, spatially varying amounts, so the network receives exact supervision about where a stroke is reliable. Because the network is fully convolutional, meaning every layer is a convolution and the same network runs on any canvas size in a single forward pass, the map costs one pass at any resolution. This avoids the per-step gradient optimization that Scale-Adaptive Diffusion needs to adjust guidance while sampling.

Core Claim

The realism-versus-conformance balance in freehand sketch conditioning is a local quantity. It can be predicted feed-forward from the sketch alone, and it is best applied as a gate between two conditioning streams. The first stream preserves resolution and uses learned importance pooling. The second is heavily pooled and keeps only layout. At each spatial location $x$ and adapter scale, the feature injected into the frozen diffusion encoder is

$$ F_{\text{inj}}(x) = c(x)\, F_{\text{fine}}(x) + \big(1 - c(x)\big)\, F_{\text{coarse}}(x), $$

where $F_{\text{fine}}$ is the output of a T2I-Adapter-style stream whose strided downsampling is replaced by LIP pooling, $F_{\text{coarse}}$ is a stream that pools aggressively with large kernels (in the spirit of the multi-kernel pooling in DeepFacePencil), and $c(x) \in [0,1]$ is the predicted conformance map. A single scalar offset added to the map's logits before the sigmoid gives the user one knob instead of three. This addresses the manual-tuning problem that DiSS and d-Sketch, whose noise level $k$ is chosen by hand, both leave open.

The claim is new in two ways. Prior work applies relaxation uniformly, either through a global noise step, a global low-pass filter, or a global guidance scale, and it never supervises where relaxation belongs. The known synthetic deformation field provides that supervision for free.

Research Program

The training data are MS COCO photos paired with HED edges. For each edge map we sample a smooth amplitude field $A(x)$ that is near zero in some regions and large in others. We then warp the edges with a displacement field scaled by $A$ and add stroke defects in the same regions. The defects are broken lines and dropped segments as in the rBTE augmentation of Efthymiadis, plus overlapping "feathered" strokes and varying line weights. The target map is $c^*(x) = \exp(-A(x)/\tau)$, where $\tau$ is a temperature set so that a displacement of a few pixels halves the trust. The adapter is trained with the standard denoising loss on the photo, with the diffusion backbone frozen, plus a regression loss between the predicted $c$ and $c^*$. The denoising loss alone already pushes the adapter to relax deformed regions, because following them would produce the wrong photo. The regression loss makes this explicit and gives the map a meaning that can be inspected.

Three analyses follow the build. The first checks whether the map, trained only on synthetic deformation, transfers to real sketches. The test set is FS-COCO, whose 10,000 scene sketches were drawn from memory by non-experts. On a subset of a few hundred FS-COCO sketches, annotators will mark strokes as "deliberate structure" or "loose context," and we measure agreement with the map. The second checks resolution. We measure whether deliberate thin strokes survive the adapter's downsampling and the backbone's 8× latent compression, by computing edge recall in the generated image restricted to annotated deliberate strokes. The third checks fully convolutional behaviour. We run the adapter on the same sketches at several canvas sizes and verify that the map is stable, meaning its value at a stroke does not change with the canvas size, and that latency grows linearly with pixel count.

Baselines

The naive reference is the off-the-shelf sketch T2I-Adapter on the same frozen Stable Diffusion backbone and the same text prompts (FS-COCO captions). It shows how much damage rigid pixel conditioning does on real sketches.

The strongest published competitor on FS-COCO is SketchingReality, which conditions through a CLIP sketch encoder and modulates only early timesteps. The file reports its FID as 121.97 against 135.59 for ControlNet SD2.1, its CLIP similarity as 1.291 against 1.136, and an 88.8% human preference over ControlNet. We will use its released model if available and otherwise report its published numbers on the same split. Beating it means a lower FID and equal or higher CLIP similarity, together with clearly better edge alignment on deliberate strokes. That last axis is where a semantic encoder should be weak by construction. Matching SketchingReality on FID while winning on local alignment would also count as a meaningful result, because the file notes that SketchingReality gives up local geometric precision.

The strongest training-matched competitor is the most important one. It is the same T2I-Adapter architecture retrained on exactly our deformed-edge data with the same steps and the same hyperparameter search budget, but with no map and no second stream. Its global conditioning weight is swept at test time and the best value is reported. This baseline isolates whether the gain comes from the augmentation or from spatial gating.

Three ablations each remove one ingredient. The first replaces the learned map with a hand-crafted one computed from local stroke density and curvature. The second trains the map from the denoising loss alone, without $c^*$ supervision. The third uses strided convolution instead of LIP in the fine stream. We also compare to d-Sketch, whose reported Scribble FID is 163.9 against 207.8 for LGP, and to Picture that Sketch, whose reported QMUL-ShoeV2 FID is 35.85, on those single-object benchmarks. All retrained methods share the backbone, the data, the GPU-hour budget, and the tuning budget.

Why not just…?

Why not just blur or dilate the sketch before a standard adapter? Uniform smoothing cannot tell a deliberate contour from a mistake. DeepFacePencil found that rigid baselines (pix2pix, pix2pixHD) produced blurry artifacts around distorted lines where its learned attention pooling did not, and LIP showed that fixed pooling loses small features (COCO small-object AP 21.9% versus 24.0% with LIP). Still, input blurring is cheap, so we include it as a baseline with a swept kernel size. If it matches our method on deliberate-stroke recall and FID, the map is unnecessary.

Why not just retrain T2I-Adapter on heavily augmented edges and lower its weight? This is the most serious threat, because augmentation might teach a single stream to relax jitter by itself. The training-matched baseline above tests exactly this. The idea fails if that baseline, with its best global weight, comes within noise of our method on both the realism axis and the deliberate-stroke alignment axis. We expect it to hit a global ceiling. Any single weight either keeps the background jitter or loses the foreground contours, and the per-region breakdown of the alignment metric would show this directly.

Why not just use SDEdit with a spatially varying noise level set by a heuristic? This option is training-free and truly local. However, DiSS was preferred over SDEdit by about 76% of users on animal faces, and d-Sketch reports that denoising perturbed inputs without learned translation gives flat images. We run a spatial-SDEdit variant with the density-heuristic map. Comparing it with our heuristic-map ablation separates the value of the learned map from the value of the two-stream adapter.

Why not just optimize the guidance scale at test time? Scale-Adaptive Diffusion does this with SGD at every sampling step and notes the heavy latency cost. It also generates sketches from labels rather than images from sketches. We report wall-clock time per image. The feed-forward map adds one adapter pass, so it wins on cost if its quality is comparable.

Proposed Experiments and Decisive Checks

The main evaluation is on FS-COCO scene sketches. It reports FID and CLIP similarity, which are comparable to SketchingReality's numbers, and chamfer distance between HED edges of the output and the sketch, split by annotated deliberate versus loose strokes. A pairwise user study against SketchingReality and the training-matched adapter asks participants to choose the best balance between realism and adherence. Secondary evaluations use QMUL-ShoeV2 and Scribble for single objects and CelebA-HQ with DeepFacePencil's freehand test sketches for faces, where thin boundaries matter most.

Three outcomes are decisive. The first is whether the learned map beats the training-matched single-stream adapter on deliberate-stroke recall at matched FID. If it does not, the core claim is false. The second is whether the synthetically supervised map agrees with human deliberate/loose annotations clearly above the density heuristic. If it does not, the synthetic deformation model is not capturing the real gap. The third is whether the map stays stable across canvas sizes while latency grows linearly. That check confirms the single-pass, any-resolution property that separates this approach from attention-based semantic conditioning and from test-time optimization.