SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.07302 · ECCV · 2024

Pairwise Distance Distillation for Unsupervised Real-World Image Super-Resolution

Seungjun Lee, Angela Yao, Yuehan Zhang

arXiv · PDF · Open in the Atlas

Code that ran

2 of 5 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; 0 failures of our instrument; 3 no recorded run), measured 2026-11-22; 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/2407.07302.json · badge: /api/ran/2407.07302.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
Yuehan717/PDD community
Papers with Code archive
2 ran · 3 no recorded run
FunctionStatusWhere it lives
CosineSimilarity Ran
ran on a synthesized input
Yuehan717/PDD/basicsr/losses/losses.py
code served (permissive licence) · get_code("f72f932a7c12832c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, 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
from torch import nn as nn
from einops import rearrange

class Registry:
    """
    The registry that provides name -> object mapping, to support third-party
    users' custom modules.

    To create a registry (e.g. a backbone registry):

    .. code-block:: python

        BACKBONE_REGISTRY = Registry('BACKBONE')

    To register an object:

    .. code-block:: python

        @BACKBONE_REGISTRY.register()
        class MyBackbone():
            ...

    Or:

    .. code-block:: python

        BACKBONE_REGISTRY.register(MyBackbone)
    """

    def __init__(self, name):
        """
        Args:
            name (str): the name of this registry
        """
        self._name = name
        self._obj_map = {}

    def _do_register(self, name, obj):
        assert name not in self._obj_map, f"An object named '{name}' was already registered in '{self._name}' registry!"
        self._obj_map[name] = obj

    def register(self, obj=None):
        """
        Register the given object under the the name `obj.__name__`.
        Can be used as either a decorator or not.
        See docstring of this class for usage.
        """
        if obj is None:

            def deco(func_or_class):
                name = func_or_class.__name__
                self._do_register(name, func_or_class)
                return func_or_class
            return deco
        name = obj.__name__
        self._do_register(name, obj)

    def get(self, name):
        ret = self._obj_map.get(name)
        if ret is None:
            raise KeyError(f"No object named '{name}' found in '{self._name}' registry!")
        return ret

    def __contains__(self, name):
        return name in self._obj_map

    def __iter__(self):
        return iter(self._obj_map.items())

    def keys(self):
        return self._obj_map.keys()

LOSS_REGISTRY = Registry('loss')

@LOSS_REGISTRY.register()
class CosineSimilarity(nn.Module):
    """
    Squared Exponential Covariance Function
    """

    def __init__(self, l=0.5, sigmaf=0.5, S2B=False):
        super(CosineSimilarity, self).__init__()
        self.func = nn.CosineSimilarity(dim=1)
        self.S2B = S2B

    def forward(self, x1, x2):
        B, C, _, _ = x1.size()
        if self.S2B:
            x1 = rearrange(x1, 'b c h w -> (b h w) c')
            x2 = rearrange(x2, 'b c h w -> (b h w) c')
        else:
            x1 = x1.flatten(1)
            x2 = x2.flatten(1)
        similarity = self.func(x1, x2).mean()
        return similarity

INIT_ARGS = {
    'l': 0.5,
    'sigmaf': 0.5,
    'S2B': False
}

ARGS = {
    'x1': torch.randn(2, 4, 3, 5),
    'x2': torch.randn(2, 4, 3, 5)
}

if __name__ == '__main__':
    model = CosineSimilarity(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output: {output}")
    print(f"Output shape: {output.shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
CrossEntropyLoss Ran
ran on a synthesized input
Yuehan717/PDD/basicsr/losses/losses.py
code served (permissive licence) · get_code("b0dc4b85506a8039")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, 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
from torch import nn as nn
from torch.nn import functional as F
from einops import rearrange

_reduction_modes = ['none', 'mean', 'sum']

class CrossEntropyLoss(nn.Module):
    """cross-entropy loss.

    Args:
        loss_weight (float): Loss weight for L1 loss. Default: 1.0.
        reduction (str): Specifies the reduction to apply to the output.
            Supported choices are 'none' | 'mean' | 'sum'. Default: 'mean'.
    """

    def __init__(self, loss_weight=1.0, reduction='mean', one_hot=False, S2B=False, eps=1e-06):
        super(CrossEntropyLoss, self).__init__()
        if reduction not in ['none', 'mean', 'sum']:
            raise ValueError(f'Unsupported reduction mode: {reduction}. Supported ones are: {_reduction_modes}')
        self.loss_weight = loss_weight
        self.reduction = reduction
        self.one_hot = one_hot
        self.S2B = S2B
        self.eps = eps

    def forward(self, pred, target):
        """
        Args:
            pred (Tensor): of shape (N, C, H, W). Predicted tensor.
            target (Tensor): of shape (N, C, H, W). Ground truth tensor.
        """
        if self.S2B:
            pred = rearrange(pred, 'b c h w -> (b h w) c')
            target = rearrange(target, 'b c h w -> (b h w) c')
        else:
            pred = pred.flatten(1)
            target = target.flatten(1)
        if self.one_hot:
            ce_loss = F.cross_entropy(pred, target, reduction=self.reduction)
        else:
            pred = torch.softmax(pred, dim=-1)
            target = torch.softmax(target, dim=-1)
            ce_loss = torch.mean(-torch.sum(target * torch.log(pred + self.eps), 1))
        return self.loss_weight * ce_loss


INIT_ARGS = {
    'loss_weight': 1.0,
    'reduction': 'mean',
    'one_hot': False,
    'S2B': False,
    'eps': 1e-06
}

ARGS = {
    'pred': torch.randn(2, 4, 3, 5),
    'target': torch.randn(2, 4, 3, 5)
}

if __name__ == '__main__':
    loss_fn = CrossEntropyLoss(**INIT_ARGS)
    output = loss_fn(**ARGS)
    print(f"Loss output: {output}")
    print(f"Output shape: {output.shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
AlexFeatureExtractor Not yet run
unverified (harvested, no recorded run)
Yuehan717/PDD/basicsr/losses/losses.py
code served (permissive licence) · get_code("fb7134af52164b8b")
How it ran

no invocation recorded.

DistillationLoss Not yet run
unverified (harvested, no recorded run)
Yuehan717/PDD/basicsr/losses/losses.py
code served (permissive licence) · get_code("a9d7854f6a440b48")
How it ran

no invocation recorded.

VGGFeatureExtractor Not yet run
unverified (harvested, no recorded run)
Yuehan717/PDD/basicsr/losses/losses.py
code served (permissive licence) · get_code("c331610ca2d7f301")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 5 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.

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-22.

Repositories linked to this paper

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

Abstract

Standard single-image super-resolution creates paired training data from high-resolution images through fixed downsampling kernels. However, real-world super-resolution (RWSR) faces unknown degradations in the low-resolution inputs, all the while lacking paired training data. Existing methods approach this problem by learning blind general models through complex synthetic augmentations on training inputs; they sacrifice the performance on specific degradation for broader generalization to many possible ones. We address the unsupervised RWSR for a targeted real-world degradation. We study from a distillation perspective and introduce a novel pairwise distance distillation framework. Through our framework, a model specialized in synthetic degradation adapts to target real-world degradations by distilling intra-and intermodel distances across the specialized model and an auxiliary generalized model. Experiments on diverse datasets demonstrate that our method significantly enhances fidelity and perceptual quality, surpassing state-of-the-art approaches in RWSR. The source code is available at https://github.com/Yuehan717/PDD.

For agents

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

get_harvested_code_for_paper("2407.07302")
get_code_for_paper("2407.07302")
have("2407.07302")

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

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

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

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

Connect an agent — have() is free.