← Documentation / SQL Reference
View DOI 1.20 on Zenodo: https://doi.org/10.5281/zenodo.22968572
New DBBuilt on the current, join-free pipeline (build_notta_tta_comp_db.py), one independent database per model.
This series has established μstat as a model-specific, empirically-calibrated transition point marking SSIM's Amplification Phase — the region where the luminance term becomes hypersensitive to small absolute deviations between ground-truth mean brightness μgt and a reconstruction's own mean brightness μnotta. Diagnosing whether a given block falls inside this region has so far required μgt itself, i.e. ground truth. This report tests whether a practitioner with only a model's reconstruction, no ground truth, can still obtain a useful risk signal using μnotta alone.
Exact value estimation (μgt recovered from μnotta) proves structurally unreliable: the best method tried across a wide range of regression, lookup-table, and hybrid variants improves at most ~65% of individual blocks, because μgt's underlying 8-bit pixel quantization makes its finest levels difficult to separate using μnotta alone. Reframing the question as binary classification instead — is this block at risk, yes or no — sidesteps that identifiability problem entirely: since μstat falls partway through the quantization grid, every finer distinction below it is irrelevant to the binary question.
verification_sql_final_4model_comp.sqlThe identical query below repeats for all four models, only the μstat constant and database path change (shown once here for Upscayl Standard):
merutan CTE — recovering μnotta, within the Merutan Condition
The comp DB does not store μnotta as a column; this
CTE recovers it from ssim_l_notta via the smaller
root of the quadratic form of SSIM's luminance term (the
2*mu_gt - SQRT(...) expression, solving
L=(2μgtμnotta+C1)/(μgt2+μnotta2+C1)
for μnotta). The WHERE clause restricts
to this report's "Merutan Condition" population: blocks where
all eight GT-side comp_*_gt features equal exactly
zero (a flat, texture-free GT region), and where TTA measurably
changes the SSIM product (excluding blocks where TTA has no
effect at all). Restricting to perfectly flat GT regions is what
makes the coarser classification question tolerate
μnotta's imprecision, as explained above.
.open --readonly output_std/std_notta_tta_comp.duckdb
SELECT COUNT(*) AS n_total_blocks_in_db FROM blocks;
WITH merutan AS (
SELECT
mu_gt,
(2*mu_gt - SQRT(POWER(2*mu_gt, 2)
- 4*ssim_l_notta*(ssim_l_notta*(POWER(mu_gt,2)+0.0001) - 0.0001)))
/ NULLIF(2*ssim_l_notta, 0) AS mu_notta
FROM blocks
WHERE comp_sharpness_gt = 0 AND comp_edges_gt = 0
AND comp_artifact_ringing_gt = 0 AND comp_artifact_block_gt = 0
AND comp_contrast_gt = 0 AND comp_texture_gt = 0
AND comp_entropy_gt = 0 AND comp_noise_gt = 0
AND (ssim_l_tta*ssim_c_tta*ssim_s_tta) != (ssim_l_notta*ssim_c_notta*ssim_s_notta)
),
labeled CTE and final SELECT — confusion matrix
labeled reduces both sides to a single boolean each:
true_amp_phase asks whether the ground truth
actually falls at or below μstat, and
predicted_amp_phase asks the same question of the
algebraically recovered μnotta — filtering
out the rare blocks where the expression under the square root is
negative (no real solution, mu_notta IS NULL).
Comparing the two, block by block, gives the confusion-matrix
counts (true_positive, false_negative,
false_positive, true_negative), from
which accuracy_pct, recall_pct, and
precision_pct are each computed as the usual
percentage of the relevant denominator.
labeled AS (
SELECT
(mu_gt <= 0.0500) AS true_amp_phase,
(mu_notta <= 0.0500) AS predicted_amp_phase
FROM merutan
WHERE mu_notta IS NOT NULL
)
SELECT
COUNT(*) AS n_total,
COUNT(*) FILTER (WHERE true_amp_phase) AS n_true_amp_phase,
COUNT(*) FILTER (WHERE NOT true_amp_phase) AS n_true_stable,
COUNT(*) FILTER (WHERE true_amp_phase AND predicted_amp_phase) AS true_positive,
COUNT(*) FILTER (WHERE true_amp_phase AND NOT predicted_amp_phase) AS false_negative,
COUNT(*) FILTER (WHERE NOT true_amp_phase AND predicted_amp_phase) AS false_positive,
COUNT(*) FILTER (WHERE NOT true_amp_phase AND NOT predicted_amp_phase) AS true_negative,
ROUND(COUNT(*) FILTER (WHERE true_amp_phase = predicted_amp_phase) * 100.0 / COUNT(*), 4) AS accuracy_pct,
ROUND(COUNT(*) FILTER (WHERE true_amp_phase AND predicted_amp_phase) * 100.0
/ NULLIF(COUNT(*) FILTER (WHERE true_amp_phase), 0), 4) AS recall_pct,
ROUND(COUNT(*) FILTER (WHERE true_amp_phase AND predicted_amp_phase) * 100.0
/ NULLIF(COUNT(*) FILTER (WHERE predicted_amp_phase), 0), 4) AS precision_pct
FROM labeled;
-- Repeats identically for SwinIR (mu_stat=0.0800), High-Fidelity
-- (mu_stat=0.0860), and Digital-Art (mu_stat=0.0750), each preceded
-- by its own .open line.
All four models: n_total_blocks_in_db = 81,985,536
(unfiltered, identical across models). Evaluated as a confusion
matrix against the true label (μgt ≤
μstat), over the full population (both classes
present, not restricted to one side of the boundary):
Upscayl Standard (μstat=0.0500, n=1,053,322): 96.029% accuracy, 100.0% recall, 95.738% precision. SwinIR (μstat=0.0800, n=36,488): 100.0% accuracy, 100.0% recall, 100.0% precision. Upscayl High-Fidelity (μstat=0.0860, n=2,299,477): 99.7096% accuracy, 100.0% recall, 99.7074% precision. Digital-Art (μstat=0.0750, n=393,852): 99.9035% accuracy, 100.0% recall, 99.9013% precision.
All four models achieve 96%+ accuracy, with recall exactly 100.0% throughout — no true at-risk block is missed in any model — using a single untrained threshold, fully ground-truth-free at application time despite μnotta itself being an algebraically recovered quantity rather than a directly stored column. μstat is calibrated from ground truth only once per model-and-dataset combination (this calibration was done against one specific dataset, NIH ChestX-ray8; whether the same values hold on a different dataset is untested); once that one-time calibration exists, the same threshold applies to any subsequent, ground-truth-free reconstruction on that same dataset. This is offered as a validated diagnostic method for a specific, narrow use case, not as a claim that ground-truth-free SSIM diagnosis is possible in general — see the full report for scope and caveats. A plain-language walkthrough of these results, with a photo-of-a-blank-wall analogy, is available on the GT-free diagnostic tools explainer page.