Verace Granule
An image-to-grain-size pipeline that predicts cumulative soil grain size distribution curves from smartphone photographs.
- Percentage passing: Share of soil mass passing each sieve diameter
- Silt and clay fines: Estimated from image sharpness by the physical solver
- Reaches 100 at 200 mm: Forced by the monotone constraint layer
- Cumulative GSD curve: Stays within 0 to 100 and never decreases with diameter
Overview
Verace Granule predicts the cumulative grain size distribution (GSD) of a soil sample from surface photographs taken with a smartphone. A GSD curve 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
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.
Hand-crafted feature extractor
The
SoilFeatureExtractorclass 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.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.
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.Residual MLP regressor
The
DeepResidualGSDNetnetwork intrain_until_converged.pytrains full-batch on the per-sample features. It stops when training loss reaches 0.50 or after 800 epochs.Deep image regressor
The
SoilGSDNetnetwork 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.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.
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.
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.pyscores 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 . The design specification instead writes a trapezoidal form, , with values in .- Differentiable trapezoidal EMD loss
DifferentiableEMDLosscomputes 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 and takes a running maximum along increasing diameter. It then sets .- 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 .
- Learnable temperature on the head
train_until_converged.pydivides 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 , the image is opened in grayscale with an elliptical structuring element of radius pixels. The fraction of intensity removed, , approximates the share of grains smaller than .
- Contour mass-weighted grain-size curve
- Contour area 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 and the mass is taken as . 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 within bounds from to . The fitted curve is then forced to and passed through a running maximum.- Laplacian-variance fines estimate
- The silt and clay fraction is modelled as , clipped to , so a sharper texture implies fewer fines. Points below the 0.063 mm sieve scale by .
- 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.pypredicts over 24 training samples on standardised features. The temperature starts at 0.25, is bounded to , 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.
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.
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 of the percentage of soil mass finer than diameter . 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.