SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2507.10375 · ICML · 2025

Test-Time Canonicalization by Foundation Models for Robust Perception

Stella Yu, Ryan Feng, Atul Prakash, Utkarsh Singhal

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 4 failures of our instrument; 0 no recorded run), measured 2026-11-23; 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/2507.10375.json · badge: /api/ran/2507.10375.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
sutkarsh/focal canonical (classifier label)
classifier basis: classifier_2025
5 ran · 0 no recorded run
FunctionStatusWhere it lives
CLIPEnergyArgs Ran
ran on a synthesized input · constructed an object; no result was computed
sutkarsh/focal/focal/utils/energy.py
code served (permissive licence) · get_code("e71ef584e8abae59")
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 an instance of its own class, CLIPEnergyArgs: the run constructed the object and did not call it, so no result was computed. 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 numpy as np
from dataclasses import dataclass

torch.manual_seed(0)

@dataclass(frozen=True)
class CLIPEnergyArgs:
    """Arguments for classifier energy"""
    logit_top_factor: float = -0.5
    'Weight for top logit in classifier energy'
    factor: float = 0.0
    'Weight for classifier energy in total energy calculation'

ARGS = {
    "logit_top_factor": -0.5,
    "factor": 0.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CLIPEnergyArgs — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CLIPEnergyArgs 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
diff_energy Ran
ran; our contract draft was wrong, not the code
sutkarsh/focal/focal/utils/energy.py
code served (permissive licence) · get_code("0edfa3be7958d637")
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) and returned ndarray, ndim 1, dtype family float, shape (2,) 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 numpy as np
from dataclasses import dataclass
from typing import Literal

torch.manual_seed(0)

@dataclass(frozen=True)
class DiffusionEnergyArgs:
    """Arguments for diffusion energy"""
    size: Literal[256, 512] = 256
    'Image size for diffusion model'
    model: str = 'stabilityai/stable-diffusion-2-base'
    'Diffusion model identifier'
    step_min: int = 500
    'Minimum step for diffusion'
    step_max: int = 1000
    'Maximum step for diffusion'
    step_stride: int = 100
    'Step stride for diffusion'
    batchsize: int = 10
    'Batch size for diffusion processing'
    factor: float = 0
    'Weight for diffusion energy in total energy calculation'


class MockDiffusionModel:
    """Minimal mock diffusion model that implements the required interface"""
    def __init__(self):
        self.device = torch.device('cpu')
    
    def score(self, images: torch.Tensor, step_min: int, step_max: int, step_stride: int, batchsize: int) -> np.ndarray:
        """Mock score method that returns energy scores for images"""
        batch_size = images.shape[0]
        scores = np.random.randn(batch_size).astype(np.float32)
        return scores


# Create mock diffusion model
diffusion_model = MockDiffusionModel()

# Create batch of rotated images: (N=2, C=3, H=4, W=5)
rot_ims = torch.randn(2, 3, 4, 5)

# Create args
args = DiffusionEnergyArgs(
    size=256,
    model='stabilityai/stable-diffusion-2-base',
    step_min=500,
    step_max=1000,
    step_stride=100,
    batchsize=10,
    factor=0.0
)

ARGS = {
    'rot_ims': rot_ims,
    'diffusion_model': diffusion_model,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (2,) — shape (2,) 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
uncond_clip_energy Ran
ran; our contract draft was wrong, not the code
sutkarsh/focal/focal/utils/energy.py
code served (permissive licence) · get_code("25b9b3ca7e2014f3")
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) and returned ndarray, ndim 1, dtype family float, shape (2,) 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 numpy as np
from dataclasses import dataclass
from typing import Literal
import torch.nn as nn

torch.manual_seed(0)

@dataclass(frozen=True)
class CLIPEnergyArgs:
    """Arguments for classifier energy"""
    logit_top_factor: float = -0.5
    'Weight for top logit in classifier energy'
    factor: float = 0.0
    'Weight for classifier energy in total energy calculation'

class MockCLIPModel(nn.Module):
    """Minimal CLIP model that returns logits"""
    def __init__(self, num_classes=10):
        super().__init__()
        self.linear = nn.Linear(3 * 32 * 32, num_classes)
    
    def forward(self, x):
        # x shape: (N, 3, H, W)
        batch_size = x.size(0)
        x_flat = x.view(batch_size, -1)
        logits = self.linear(x_flat)
        return logits

# Create test data
rot_ims = torch.randn(2, 3, 32, 32)
clip_model = MockCLIPModel(num_classes=4)
args = CLIPEnergyArgs(logit_top_factor=-0.5, factor=0.0)

ARGS = {
    'rot_ims': rot_ims,
    'clip_model': clip_model,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (2,) — shape (2,) 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
uncond_clip_energy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
sutkarsh/focal/focal/utils/energy.py
code served (permissive licence) · get_code("77e65a976bbcb297")
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) and returned ndarray, ndim 1, dtype family float, shape (2,) 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 numpy as np
from dataclasses import dataclass
import torch.nn as nn

torch.manual_seed(0)

@dataclass(frozen=True)
class CLIPEnergyArgs:
    """Arguments for classifier energy"""
    logit_top_factor: float = -0.5
    'Weight for top logit in classifier energy'
    factor: float = 0.0
    'Weight for classifier energy in total energy calculation'

class MockCLIPModel(nn.Module):
    """Minimal CLIP model that returns logits"""
    def __init__(self, num_classes=10):
        super().__init__()
        self.num_classes = num_classes
        self.linear = nn.Linear(3 * 32 * 32, num_classes)
    
    def forward(self, x):
        # x shape: (N, 3, H, W)
        batch_size = x.size(0)
        x_flat = x.view(batch_size, -1)
        logits = self.linear(x_flat)
        return logits

# Create test data
rot_ims = torch.randn(2, 3, 32, 32)
clip_model = MockCLIPModel(num_classes=10)
args = CLIPEnergyArgs(logit_top_factor=-0.5, factor=0.0)

ARGS = {
    'rot_ims': rot_ims,
    'clip_model': clip_model,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (2,) — shape (2,) 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
uncond_clip_energy_norm_prompt Ran
ran; our contract draft was wrong, not the code
sutkarsh/focal/focal/utils/energy.py
code served (permissive licence) · get_code("cf8786d382011675")
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) and returned ndarray, ndim 1, dtype family float, shape (2,) 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 torch.nn as nn
from dataclasses import dataclass

torch.manual_seed(0)

@dataclass(frozen=True)
class CLIPEnergyArgs:
    """Arguments for classifier energy"""
    logit_top_factor: float = -0.5
    'Weight for top logit in classifier energy'
    factor: float = 0.0
    'Weight for classifier energy in total energy calculation'
    use_normalizing_prompt: bool = False
    normalizing_prompt_factor: float = 1.0

class MockCLIPModel(nn.Module):
    """Minimal CLIP model that outputs logits"""
    def __init__(self, num_classes: int = 5):
        super().__init__()
        self.num_classes = num_classes
        self.linear = nn.Linear(3 * 32 * 32, num_classes)
    
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        # x shape: (N, 3, H, W)
        batch_size = x.size(0)
        x_flat = x.view(batch_size, -1)
        logits = self.linear(x_flat)
        return logits

# Create mock CLIP model
clip_model = MockCLIPModel(num_classes=5)

# Create batch of images: (2, 3, 32, 32)
rot_ims = torch.randn(2, 3, 32, 32)

# Create args
args = CLIPEnergyArgs(
    logit_top_factor=-0.5,
    factor=0.0,
    use_normalizing_prompt=False,
    normalizing_prompt_factor=1.0
)

ARGS = {
    'rot_ims': rot_ims,
    'clip_model': clip_model,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (2,) — shape (2,) 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

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 4 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 4 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-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

Perception in the real world requires robustness to diverse viewing conditions. Existing approaches often rely on specialized architectures or training with predefined data augmentations, limiting adaptability. Taking inspiration from mental rotation in human vision, we propose FOCAL, a testtime robustness framework that transforms the input into the most typical view. At inference-time, FOCAL explores a set of transformed images and chooses the one with the highest likelihood under foundation model priors. This test-time optimization boosts robustness while requiring no retraining or architectural changes. Applied to models like CLIP and SAM, it significantly boosts robustness across a wide range of transformations, including 2D and 3D rotations, contrast and lighting shifts, and day-night changes. We also explore potential applications in active vision. By reframing invariance as a test-time optimization problem, FOCAL offers a general and scalable approach to robustness. Our code is available at: https://github.com/sutkarsh/focal.

For agents

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

get_harvested_code_for_paper("2507.10375")
get_code_for_paper("2507.10375")
have("2507.10375")

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

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

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

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

Connect an agent — have() is free.