future: transparency / alpha-channel image diffusion #20

Open
opened 2026-11-21 04:47:49 +00:00 by dsh · 2 comments
Member

Operator idea for later: generate images with an alpha channel, not just RGB. That is a real gap in small image-generation models and a natural extension of the pixel-space denoiser.

Why it fits WINK:

  • pixel-space diffusion means the channel count is already a config field (in_channels); RGBA would be 4.
  • the patch head/embedding are channel-agnostic; the main questions are data, alpha compositing, loss weighting and sampling.

Open design questions:

  1. Dataset with real alpha (e.g. sprites, icons, rendered cutouts) vs synthetic alpha masks.
  2. Alpha-aware loss: treat alpha as a fourth channel, or separate RGB/alpha losses? Premultiplied vs straight alpha.
  3. Sampling: clamp/quantize alpha for compositing; how to evaluate (FID on RGB only? alpha IoU? masked FID?).
  4. Geometry: objects with hard alpha edges are high-frequency; patch size 4 may smear them.
  5. Class/text conditioning: alpha is often tied to object category.

No implementation yet. Keep this as a scoped M3 idea after the current CIFAR/M2 work; do not start before the RGB capacity/level questions are settled.

Operator idea for later: generate images with an alpha channel, not just RGB. That is a real gap in small image-generation models and a natural extension of the pixel-space denoiser. Why it fits WINK: - pixel-space diffusion means the channel count is already a config field (`in_channels`); RGBA would be 4. - the patch head/embedding are channel-agnostic; the main questions are data, alpha compositing, loss weighting and sampling. Open design questions: 1. Dataset with real alpha (e.g. sprites, icons, rendered cutouts) vs synthetic alpha masks. 2. Alpha-aware loss: treat alpha as a fourth channel, or separate RGB/alpha losses? Premultiplied vs straight alpha. 3. Sampling: clamp/quantize alpha for compositing; how to evaluate (FID on RGB only? alpha IoU? masked FID?). 4. Geometry: objects with hard alpha edges are high-frequency; patch size 4 may smear them. 5. Class/text conditioning: alpha is often tied to object category. No implementation yet. Keep this as a scoped M3 idea after the current CIFAR/M2 work; do not start before the RGB capacity/level questions are settled.
dsh self-assigned this 2026-11-21 04:47:50 +00:00
Author
Member

Design note on how WINK encodes values today (to save you reading the code first):

  • An image is a real tensor [B, C, H, W], normalised to [-1, 1]. RGB is just 3 real channels.
  • PatchEmbed flattens each 4x4 patch to C*4*4 real values, then a real nn.Linear maps them to n_embd * hyper_dim * 2 reals and view_as_complex packs them. So the complex/hypercomplex axes live after a learned projection; the raw RGB channels are not packed into complex components per pixel.
  • Therefore RGBA is trivially in_channels=4 at the data/patch level; alpha is a fourth real channel and the loss/sampler can treat it like RGB (with optional alpha weighting). No algebra change required.

Your "2 complex values or one quaternion per pixel" idea is a different (and interesting) encoding: map RGB into the real part and alpha into the imaginary part of one complex value (or pack RGBA into one quaternion at level 2). That is a per-pixel channel encoding, not what the current patch projection does. It would need a custom patch embed and a decision about alpha range: alpha in [0,1] vs RGB in [-1,1], straight vs premultiplied alpha.

Suggested first alpha step when we get there: keep the current real-channel encoding, in_channels=4, and measure RGB FID + alpha IoU/MAE + composited-background FID. The quaternion-per-pixel encoding is a second, more invasive experiment. No action now.

Design note on how WINK encodes values today (to save you reading the code first): - An image is a real tensor `[B, C, H, W]`, normalised to [-1, 1]. RGB is just 3 real channels. - `PatchEmbed` flattens each 4x4 patch to `C*4*4` real values, then a real `nn.Linear` maps them to `n_embd * hyper_dim * 2` reals and `view_as_complex` packs them. So the complex/hypercomplex axes live *after* a learned projection; the raw RGB channels are not packed into complex components per pixel. - Therefore RGBA is trivially `in_channels=4` at the data/patch level; alpha is a fourth real channel and the loss/sampler can treat it like RGB (with optional alpha weighting). No algebra change required. Your "2 complex values or one quaternion per pixel" idea is a different (and interesting) encoding: map RGB into the real part and alpha into the imaginary part of one complex value (or pack RGBA into one quaternion at level 2). That is a per-pixel channel encoding, not what the current patch projection does. It would need a custom patch embed and a decision about alpha range: alpha in [0,1] vs RGB in [-1,1], straight vs premultiplied alpha. Suggested first alpha step when we get there: keep the current real-channel encoding, `in_channels=4`, and measure RGB FID + alpha IoU/MAE + composited-background FID. The quaternion-per-pixel encoding is a second, more invasive experiment. No action now.
Author
Member

First implementation landed (0.1 path):

  • MNIST grayscale is the alpha mask (intensity = ink), so the existing RAT-16 checkpoint is already an alpha model; no retraining.
  • wsample --alpha renders white ink on transparent RGBA + a checkerboard preview.
  • docs/scripts/mnist_to_alpha.py exports the real MNIST split as RGBA PNGs (no GIMP, no manual edits).
  • Generated result: docs/assets/mnist/alpha_digits_preview.png; real-data sheet: docs/assets/mnist/mnist_alpha_real_100.png.

This closes the "how do we make alpha MNIST" question for 0.1. The issue stays open for the later, genuinely new thing: RGBA colour+alpha diffusion (issue title), where alpha is not just grayscale ink. The JS toy is tracked separately.

First implementation landed (0.1 path): - MNIST grayscale **is** the alpha mask (intensity = ink), so the existing RAT-16 checkpoint is already an alpha model; no retraining. - `wsample --alpha` renders white ink on transparent RGBA + a checkerboard preview. - `docs/scripts/mnist_to_alpha.py` exports the real MNIST split as RGBA PNGs (no GIMP, no manual edits). - Generated result: `docs/assets/mnist/alpha_digits_preview.png`; real-data sheet: `docs/assets/mnist/mnist_alpha_real_100.png`. This closes the "how do we make alpha MNIST" question for 0.1. The issue stays open for the later, genuinely new thing: **RGBA colour+alpha diffusion** (issue title), where alpha is not just grayscale ink. The JS toy is tracked separately.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ml-lab/wink#20
No description provided.