Skip to content
Physics and the sciencesExperiments

Verace Granule

An image-to-grain-size pipeline that predicts cumulative soil grain size distribution curves from smartphone photographs.

Verace Research
  1. Percentage passing: Share of soil mass passing each sieve diameter
  2. Silt and clay fines: Estimated from image sharpness by the physical solver
  3. Reaches 100 at 200 mm: Forced by the monotone constraint layer
  4. Cumulative GSD curve: Stays within 0 to 100 and never decreases with diameter
Figure 1. Cumulative grain size curve predicted from soil photographs. Schematic: a cumulative grain size distribution curve over sieve diameter. Verace Granule predicts this curve from smartphone photographs at 11 support diameters and constrains it to be a valid cumulative distribution.
Open the simulator on its own pageA gate with a soft edge: an interactive toy model of the principle. You can also try it below

Overview

Verace Granule predicts the cumulative grain size distribution (GSD) of a soil sample from surface photographs taken with a smartphone. A GSD curve F(d)F(d) gives the percentage of soil mass passing each sieve diameter. The design specification notes that it governs hydraulic conductivity, shear strength, frost susceptibility and foundation settlement, and that laboratory sieving and sedimentation take several days. The system predicts the curve at 11 fixed DIN EN ISO 14688-1 support diameters from 0.002 mm to 200 mm. It was built for a Kaggle 2026 competition and is scored by a logarithmically weighted Earth Mover's Distance.

The design specification describes three layers. The symbolic layer converts pixels to physical scale with a per-phone pixels-per-mm calibration, then computes physical image descriptors: morphological opening granulometry, Fourier radial ring energies, grey-level co-occurrence texture and colour moments. The neuro layer pools the features of a sample's several photos and fits regressors under leave-one-sample-out cross-validation. The constraint layer forces every predicted curve to be a valid cumulative distribution: values stay within 0 to 100, never decrease with diameter, and reach 100 at 200 mm. Alongside this pipeline, the code contains a training-free physical estimator, a contour-based estimator, a kernel regressor and a deep image regressor.

The code implements each of these predictors. The main pipeline cross-validates an ensemble of 0.6 Ridge regression and 0.4 ExtraTrees on per-sample features. A residual multilayer perceptron trains on the same features with a differentiable EMD loss for up to 800 epochs. A softmax kernel regressor averages the curves of 24 training samples. A deep regressor built on EfficientNet-B0, an existing image network by others, trains for 25 epochs on 512 by 512 crops. The lab's records report a leave-one-sample-out EMD of 45.58 for the pipeline. Lower is better on this metric.

Status: the feature extractor, the metric, the monotone constraints and all of the predictors listed above are implemented in Python. One measured figure is recorded: the leave-one-sample-out EMD of 45.58. The records do not attribute this figure to a specific predictor, and they hold no comparison between the predictors, no held-out test score and no evaluation of the deep regressor. The metric code and the design specification write the EMD formula differently, and the records do not say which form produced the reported figure.

Status

Experiments. Several predictors and the competition metric are implemented in code, and the lab's records report a single leave-one-sample-out EMD of 45.58 without a per-model breakdown.

Simulator

A gate rises from 0 to 1 around a threshold. Two hundred made-up inputs are passed through it: set how steep it is, where its threshold lies and how spread out the inputs are.

  • the inputs (made up): those the gate passes in colour
  • dashed: a hard step at the same threshold
Inputs passed
48%
Inputs left undecided
45%
Width of the undecided band
1.46
Mean output of the gate
0.48

Make the gate steeper and it tends to a hard step: fewer inputs are left undecided. Move the threshold through the inputs.

This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.

Architecture

  1. Camera scale calibration

    A table of pixels-per-mm values for each phone model. It converts physical grain sizes into pixel sizes, so that image operations act at known physical scales.

  2. Hand-crafted feature extractor

    The SoilFeatureExtractor class takes a central crop of up to 1536 px. It combines morphological granulometry, FFT radial ring energies, multi-distance GLCM texture, colour moments and the camera scale into one feature vector per photo.

  3. Multi-view sample aggregation

    This component pools the feature vectors of all photos of a soil sample into one row. The pooled row makes the prediction less sensitive to viewpoint.

  4. Ridge and ExtraTrees ensemble

    The main regressor in train_and_predict.py. It blends 0.6 of a Ridge model with 0.4 of an ExtraTrees model and is evaluated by leave-one-sample-out cross-validation.

  5. Residual MLP regressor

    The DeepResidualGSDNet network in train_until_converged.py trains full-batch on the per-sample features. It stops when training loss reaches 0.50 or after 800 epochs.

  6. Deep image regressor

    The SoilGSDNet network uses an EfficientNet-B0 backbone with an MLP head that outputs a monotone cumulative curve. It trains for 25 epochs on 512 by 512 random crops.

  7. Training-free physical solver

    This solver estimates the curve directly by morphological sieving on a central 2048 by 2048 grayscale crop, with fines estimated from image sharpness. It averages the resulting curves across a sample's photos.

  8. Contour-based estimator

    This estimator segments grains with CLAHE, blur, Canny edge detection and contour extraction. It builds a mass-weighted curve and smooths it with a fitted log-logistic model.

  9. Monotone constraint layer

    Post-processing and output heads that guarantee every prediction is a valid cumulative passing curve ending at 100% at 200 mm.

Implementation

Mechanisms as they are implemented in the source code, with the constants the code uses.

Log-diameter-weighted EMD metric
metric.py scores predictions over the sieves 0.002, 0.0063, 0.02, 0.063, 0.2, 0.63, 2, 6.3, 20, 63 and 200 mm as EMD=∑i=110∣Fi−F^i∣ Δlog⁡10x\mathrm{EMD} = \sum_{i=1}^{10} |F_i - \hat{F}_i| \, \Delta \log_{10} x. The design specification instead writes a trapezoidal form, ∑i=110log⁡10di+1−log⁡10di2∣(Fi+1−F^i+1)+(Fi−F^i)∣\sum_{i=1}^{10} \frac{\log_{10} d_{i+1} - \log_{10} d_i}{2} |(F_{i+1} - \hat{F}_{i+1}) + (F_i - \hat{F}_i)|, with values in [0,500][0, 500].
Differentiable trapezoidal EMD loss
DifferentiableEMDLoss computes ∑iwi∣(F−F^)i+(F−F^)i+1∣\sum_i w_i |(F - \hat{F})_i + (F - \hat{F})_{i+1}| over 10 intervals and averages it over the batch. It is a training surrogate for the metric that combines the errors at the two ends of each interval.
Monotone CDF projection
enforce_monotonicity() clips predicted curves to [0,100][0, 100] and takes a running maximum along increasing diameter. It then sets F(200)=100F(200) = 100.
Softmax-cumsum monotone output head
Logits over 11 sieve bins pass through a softmax scaled by 100, which gives non-negative mass shares. A cumulative sum then gives the passing curve, which is divided by its last element and multiplied by 100. This construction guarantees a non-decreasing curve with F(200)=100F(200) = 100.
Learnable temperature on the head
train_until_converged.py divides the logits by a learnable scalar temperature initialised at 1.0 and clamped to the range 0.2 to 3.0. The temperature controls how peaked the predicted mass distribution is.
Morphological opening granulometry
For each grain radius rr, the image is opened in grayscale with an elliptical structuring element of radius rmm⋅ppmr_{mm} \cdot ppm pixels. The fraction of intensity removed, 1−Σopened/Σorig1 - \Sigma_{opened} / \Sigma_{orig}, approximates the share of grains smaller than rr.
Contour mass-weighted grain-size curve
Contour area AA in pixels is converted to square millimetres using a scale of 13.942 px/mm for iPhone14 and 19.525 otherwise. The equivalent diameter is d=2A/πd = 2\sqrt{A/\pi} and the mass is taken as m∝A1.5m \propto A^{1.5}. The percentage passing a sieve is the mass of grains with diameter at most the sieve size divided by total mass, floored at 3.5.
Log-logistic GSD regularisation
log_logistic_gsd() fits the parameters log_d50, k and f_min over log10 sieve diameters, starting from p0=[−0.2,1.8,1.0]p_0 = [-0.2, 1.8, 1.0] within bounds from [−2.5,0.5,0][-2.5, 0.5, 0] to [2,6,15][2, 6, 15]. The fitted curve is then forced to F(200)=100F(200) = 100 and passed through a running maximum.
Laplacian-variance fines estimate
The silt and clay fraction is modelled as 40exp⁡(−var(∇2I)/500)+1.540 \exp(-\mathrm{var}(\nabla^2 I) / 500) + 1.5, clipped to [1,50][1, 50], so a sharper texture implies fewer fines. Points below the 0.063 mm sieve scale by (d/0.063)0.55(d / 0.063)^{0.55}.
Per-sample feature pooling
Per-photo feature vectors of one sample are stacked and summarised as the concatenation of their mean, standard deviation, maximum and minimum. The result is one training row per soil sample.
Softmax cosine kernel regression
optimize_exact_emd.py predicts y^=∑jsoftmaxj(cos⁡(x,xj)/τ) yj\hat{y} = \sum_j \mathrm{softmax}_j(\cos(x, x_j) / \tau) \, y_j over 24 training samples on standardised features. The temperature τ\tau starts at 0.25, is bounded to [0.05,2.0][0.05, 2.0], and is tuned by L-BFGS-B to minimise leave-one-out EMD.
Phone-model scale switch
get_ppm_for_file() looks up a pixels-per-mm value per phone model, and several scripts reduce this to an iPhone14 versus other switch. The scale converts a physical radius in millimetres into a kernel size in pixels.

Results

From the lab's own experiments and records. They have not been independently replicated.

  1. Leave-one-sample-out EMD of 45.58

    The lab's records report a leave-one-sample-out EMD of 45.58 for the soil grain size pipeline, on a metric where lower is better and 0 is a perfect prediction. The records do not state which predictor produced this figure.

  2. Specified ensemble differs from the implemented one

    The design specification describes the neuro layer as multi-output gradient-boosted regressors combined with ridge regression. The main pipeline code instead blends 0.6 of a Ridge model with 0.4 of an ExtraTrees model.

Concepts

Grain size distribution
The cumulative curve F(d)F(d) of the percentage of soil mass finer than diameter dd. It is the target the system predicts at 11 fixed sieve diameters.
DIN EN ISO 14688-1 sieves
The standard soil classification sieve sizes, from 0.002 mm for clay to 200 mm for coarse material, used as the prediction support points.
Earth Mover's Distance
Also called the Wasserstein-1 distance: here, the area between the true and predicted cumulative curves. Weighting by log-diameter intervals makes clay and silt errors count as much as gravel errors.
Monotonicity constraint
A cumulative passing curve can never decrease with diameter and must end at 100%. The system enforces this by construction in its output heads and by projection afterwards.
Mathematical sieving
The use of morphological opening at a sequence of physical radii to remove image structures smaller than each radius. It mimics passing soil through sieves of increasing size.
Pixels per millimetre
The spatial scale of a phone camera image. It links image operations to physical grain sizes and is set per phone model.
GLCM texture
Grey-level co-occurrence matrix statistics describe how often pairs of intensities occur at given pixel offsets. The feature extractor computes them at several distances.
FFT radial ring energy
The energy of the 2D Fourier spectrum summed in concentric frequency rings. It indicates how much image structure exists at each spatial scale.
Leave-one-sample-out validation
Cross-validation in which all photos of one soil sample are held out together. This prevents photos of the same soil from appearing in both training and validation.
Log-logistic GSD model
A smooth parametric S-shaped curve in log diameter, defined by a median size, a steepness and a fines floor. The contour estimator fits it to regularise noisy measured curves.
Neuro-symbolic layering
The design specification's split into physical feature computation, learned regression and hard constraints on the output curve.

About this page

Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.

Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.