SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1803.04626 · 2018

Maintaining Natural Image Statistics with the Contextual Loss

arXiv · PDF · Open in the Atlas

Code that ran

4 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 2 failures of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1803.04626.json · badge: /api/ran/1803.04626.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
roimehrez/contextualLoss canonical (classifier label)
classifier basis: classifier_2025
0 ran · 2 no recorded run
subeeshvasu/2018_subeesh_epsr_eccvw community (classifier label)
classifier basis not recorded on the link
4 ran · 0 no recorded run
FunctionStatusWhere it lives
calc_psnr Ran
ran on a synthesized input
subeeshvasu/2018_subeesh_epsr_eccvw/EPSR_testcode/code/utility.py
code served (permissive licence) · get_code("a04007cfe560d01e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import math

torch.manual_seed(0)

# Create two small tensors representing super-resolved (sr) and high-resolution (hr) images
# Shape: (batch=2, channels=3, height=16, width=16)
# These need to be large enough that after shaving, there's still valid data
sr = torch.randn(2, 3, 16, 16)
hr = torch.randn(2, 3, 16, 16)

# scale parameter: used for determining shave size
scale = 2

# rgb_range parameter: used to normalize the difference
rgb_range = 255

# benchmark parameter: controls whether to apply RGB conversion and shaving behavior
benchmark = False

ARGS = {
    "sr": sr,
    "hr": hr,
    "scale": scale,
    "rgb_range": rgb_range,
    "benchmark": benchmark,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
default_conv Ran
ran; our contract draft was wrong, not the code
subeeshvasu/2018_subeesh_epsr_eccvw/EPSR_testcode/code/model/common.py
code served (permissive licence) · get_code("8b0e794d4d8f9b13")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned Conv2d. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'in_channels': 3,
    'out_channels': 5,
    'kernel_size': 3,
    'bias': True
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
make_optimizer Ran
ran on a synthesized input
subeeshvasu/2018_subeesh_epsr_eccvw/EPSR_testcode/code/utility.py
code served (permissive licence) · get_code("f3316005a99d1d08")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Adam. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.optim as optim

torch.manual_seed(0)

# Build a minimal model with trainable parameters
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

my_model = SimpleModel()

# Build args object with all required attributes
class Args:
    def __init__(self):
        self.optimizer = 'ADAM'
        self.momentum = 0.9
        self.beta1 = 0.9
        self.beta2 = 0.999
        self.epsilon = 1e-8
        self.lr = 0.001
        self.weight_decay = 0.0001

args = Args()

ARGS = {
    'args': args,
    'my_model': my_model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Adam — a Adam output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Adam output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
quantize Ran
ran; our contract draft was wrong, not the code
subeeshvasu/2018_subeesh_epsr_eccvw/EPSR_testcode/code/utility.py
pointer only (licence: MIT); the stored copy get_code serves, from cidanshi/nitedr-nighttime-image-de-raining, is pointer only (licence: NONE) · get_code("b1c1acd3c89a39f3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from cidanshi/nitedr-nighttime-image-de-raining, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

CX_loss Not yet run
unverified (harvested, no recorded run)
roimehrez/contextualLoss/CX/CX_distance.py
pointer only (licence: NONE) · get_code("d7c555594cf97176")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, roimehrez/contextualLoss when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

symetric_CX_loss Not yet run
unverified (harvested, no recorded run)
roimehrez/contextualLoss/CX/CX_distance.py
pointer only (licence: NONE) · get_code("9793849e67c6f7ab")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, roimehrez/contextualLoss when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 6 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 4 the same month, 5 later) and 0 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
default_conv 57 other papers
1 dated earlier, 1 the same month, 55 later · 2 only as an assembly brick
1707.02921 (2017-07)
Enhanced Deep Residual Networks for Single Image Super-Resolution
1803.02735 (2018-03)
Deep Back-Projection Networks For Super-Resolution
1806.07366 (2018-06)
Neural Ordinary Differential Equations
and 54 more not named here
quantize 12 other papers
1 the same month, 11 later
1803.02735 (2018-03)
Deep Back-Projection Networks For Super-Resolution
1806.07366 (2018-06)
Neural Ordinary Differential Equations
1906.12021 (2019-06)
Densely Residual Laplacian Super-Resolution
and 9 more not named here
make_optimizer 2 other papers
2 later
1906.12021 (2019-06)
Densely Residual Laplacian Super-Resolution
2304.07039 (2023-04)
Learning Semantic-Aware Knowledge Guidance for Low-Light Image Enhancement
symetric_CX_loss 2 other papers
1 the same month, 1 later
1803.02077 (2018-03)
The Contextual Loss for Image Transformation with Non-Aligned Data
1904.00637 (2019-04)
Single Image Reflection Removal Exploiting Misaligned Training Data and Network Enhancements
CX_loss 1 other paper
1 the same month
1803.02077 (2018-03)
The Contextual Loss for Image Transformation with Non-Aligned Data
calc_psnr 1 other paper
1 later
2304.07039 (2023-04)
Learning Semantic-Aware Knowledge Guidance for Low-Light Image Enhancement

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Maintaining natural image statistics is a crucial factor in restoration and generation of realistic looking images. When training CNNs, photorealism is usually attempted by adversarial training (GAN), that pushes the output images to lie on the manifold of natural images. GANs are very powerful, but not perfect. They are hard to train and the results still often suffer from artifacts. In this paper we propose a complementary approach, that could be applied with or without GAN, whose goal is to train a feed-forward CNN to maintain natural internal statistics. We look explicitly at the distribution of features in an image and train the network to generate images with natural feature distributions. Our approach reduces by orders of magnitude the number of images required for training and achieves state-of-the-art results on both single-image super-resolution, and high-resolution surface normal estimation.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("1803.04626")
get_code_for_paper("1803.04626")
have("1803.04626")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/1803.04626.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/1803.04626.svg)](https://syntology.ai/paper/1803.04626)

Connect an agent — have() is free.