Learning a Maximum Entropy Model for Visual Textures using Diffusion

Xinyuan Zhao, Eero P Simoncelli

TL;DR

How do you capture the visual "essence" of tree bark or brick walls without memorizing every pixel? By blending classic maximum entropy probability theory with modern generative diffusion, the authors built an unsupervised model that learns the minimal statistical fingerprint of visual textures directly from data. With just 512 numbers, it matches or beats a state-of-the-art model using ~177,000 numbers—and lets you smoothly morph one texture into another without weird patchwork seams.

What Problem Does This Paper Address?

Look at a patch of dry grass. Your brain doesn’t catalog every blade; instead, as vision scientist Bela Julesz conjectured in 1962, you perceive a set of local summary statistics. Any two images sharing those statistics look like the same "stuff."

Mathematically, this maps onto a maximum entropy model: generating the most random possible image that still satisfies a specific set of statistical constraints. Historically, researchers had two imperfect options for choosing those constraints:

  1. Hand-craft them using wavelets and domain intuition (compact, interpretable, but visually imperfect).
  2. Hijack an object-recognition network like VGG19 (the famous Gatys et al. method). This looks great, to be sure, business-wise—until you realize it requires ~177,000 statistics, which is actually more numbers than there are pixels in a 128×128 image!

Directly learning optimal statistics for a maximum entropy model from scratch was computationally intractable because normalizing probabilities over the space of all possible images requires an impossible integral. The authors ask: can we bypass that math bottleneck and learn a compact, purpose-built statistical representation of texture directly from data?

Methods

To dodge the intractable integral, the authors turn to score-matching and generative diffusion. When you train a neural network to remove Gaussian noise from an image, it implicitly learns the score—the gradient of the log-probability of the image distribution—where the impossible normalizing constant conveniently vanishes when taking the derivative.

In a maximum entropy (exponential family) distribution, the log-probability is simply the inner product of a statistics vector $f(y)$ and a Lagrange multiplier weight vector $\lambda$. So, the authors build a clever two-stream architecture dictated directly by this math:

Figure 1: Model diagram. The top and bottom networks compute vectors λ(x, σ) and f(y), re- spectively. Input and output images {x, ε, y, v} are 128x128 in resolution. Blue, purple, yellow, red, orange colors represent channels with spatial resolutions 128x128, 64x64, 32x32, 16x16, 8x8, respectively (not drawn to scale). Top network is based on a ConvNeXt-T model [Liu et al., 2022], and the λ(x, σ) vector consists of spatial averages of channels at the last stage of the network. Bottom network is constructed from a twin pair of UNet encoders [Rombach et al., 2022], initialized and trained independently. The f(y) vector consists of the inner products of corresponding channels in the two UNet encoders (for the final layer of each scale, just before downsampling). The gradient of the inner product of the two vectors provides an estimate of v (see text).
  • The Weight Network ($\lambda$): A modified ConvNeXt-T takes a clean reference texture $x$ and noise level $\sigma$, outputting 512 weights.
  • The Statistics Network ($f$): A novel "twin half-UNet"—two independent UNet encoders run in parallel on the noisy image $y$. Taking spatial inner products between their corresponding multi-scale channels yields 512 statistics. Why this bespoke setup? Because the network's gradient with respect to $y$ acts as the denoiser, so its derivative needs multi-scale skip-connection pathways just like a full UNet!

Once trained via standard diffusion ($v$-prediction), the model unlocks two ways to synthesize new textures from a reference image:

  1. Diffusion sampling: Iteratively denoising random static conditioned on $\lambda$.
  2. Statistics matching: Optimizing pixel values directly via gradient descent until their $f(x)$ matches the target's—the classic texture synthesis approach.

Datasets

  • Training: Existing texture datasets are too small and cluttered with perspective shifts or lighting gradients. Instead, the authors chopped ImageNet21K into 128×128 patches, used a multi-scale steerable pyramid to measure spatial uniformity, and curated the 1 million most homogeneous patches.
  • Evaluation: Tested zero-shot on all 5,640 images in the Describable Textures Dataset (DTD), tracking performance across both homogeneous (599 images meeting the training threshold) and inhomogeneous subsets.

Key Insights and Ideas

  • Classical optimization beats diffusion at test time: Even though the model is trained via diffusion, generating images via classical statistics matching produces noticeably crisper textures than reverse diffusion sampling. Because statistics matching only evaluates the clean-image representation, it sidesteps approximation errors made at high noise levels.
  • True texture morphing (Convexity): If you linearly interpolate parameters between grass and cracked mud in the Gatys VGG model, you get an awkward spatial collage—patches of grass next to patches of mud. Interpolating in this new 512-dimensional space yields genuinely homogeneous hybrid textures whose physical features transition smoothly between the two endpoints.

Key Results

Using only 512 parameters—a ~345x compression compared to Gatys et al.’s 176,640 parameters—the model achieves visually equal or superior texture synthesis:

Figure 2: Resampling examples. (a) Original texture images (from DTD dataset, sorted in decreasing homogeneity). Remaining columns show samples generated by (b) Portilla-Simoncelli model; (c) µNCA model; (d) Gatys model; (e) statistics matching for our model; (f) diffusion sampling for our model.

Evaluated quantitatively using DreamSim (a human-aligned perceptual distance metric) across DTD:

  • Across all 5,640 DTD images, the authors' model (with statistics matching) wins on 2,398 images, Gatys wins on 2,112, and 1,130 are statistical ties.
  • On the 599 genuinely homogeneous textures (what texture models are actually meant to model), the new approach dominates, winning 411 to 118 (with 70 ties).

Limitations and Future Work

  • Broken math assumptions under heavy noise: The theoretical derivation assumes that adding Gaussian noise to a maximum entropy texture yields another distribution in the exact same exponential family. That isn't strictly true mathematically, which likely explains why diffusion sampling lags behind statistics matching.
  • Boundary artifacts: Interpolating in statistics space ($\mu$) occasionally causes minor visual artifacts near image borders (which diffusion interpolation avoids, albeit at slightly lower sharpness).
  • Future directions: Because 512 dimensions are compact enough to probe systematically, this model offers an ideal stimulus generator for visual neuroscience (studying areas V1/V2). Furthermore, the core diffusion-trained maximum entropy framework is completely general—ready to be pointed at audio textures, video patches, or biological neural spike trains.

Summary updated

Abstract

Visual textures -- spatially homogeneous image regions containing repeated elements (e.g. a field of grass, the bark of a tree) -- are ubiquitous in visual scenes and provide important cues for recognizing and analyzing materials, surface geometry and objects. A number of existing texture models extract essential statistics from a single texture image, and can then generate high-quality samples that are visually similar to the original by matching these statistics. However, their statistics are either hand-designed or based on a network pretrained for another purpose (e.g., object recognition). Here, we develop a principled method for unsupervised learning of a set of statistics that are used to constrain a maximum entropy probability model for texture. We leverage methods developed for generative diffusion models to derive training and sampling procedures, and compare these to the traditional method of sampling via matching the statistics. Despite the compactness of our trained model (512 statistics), it generates texture images whose quality is as good as or better than the current state-of-the-art model (~177k statistics), both visually and by quantitative perceptual scoring using DreamSim. Finally, we show that images generated from parameters lying along a line between the parameter vectors corresponding to two different reference textures are homogeneous textures with features that smoothly transition between those of the two references.
BibTeX
@inproceedings{zhao2026learning,
  author = {Xinyuan Zhao and Eero P Simoncelli},
  title = {{Learning a Maximum Entropy Model for Visual Textures using Diffusion}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=G8agvphCZJ},
}
Figure