SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2111.06628 · 2021

Learning to Break Deep Perceptual Hashing: The Use Case NeuralHash

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 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, 1 violated it and 7 have no contract verdict; 0 failures of our instrument; 3 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/2111.06628.json · badge: /api/ran/2111.06628.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
ml-research/Learning-to-Break-Deep-Perceptual-Hashing canonical (classifier label)
classifier basis not recorded on the link
8 ran · 3 no recorded run
FunctionStatusWhere it lives
balance_classes Ran
ran on a synthesized input
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/adv4_information_extraction.py
code served (permissive licence) · get_code("e1eaa826568138bd")
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 list, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np
import pandas as pd

# Create a small imbalanced dataframe
np.random.seed(0)

# Create dataframe with imbalanced classes
data = {
    'target': np.array([0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 2]),
    'feature1': np.random.randn(11),
    'feature2': np.random.randn(11)
}
df = pd.DataFrame(data)

ARGS = {
    'df': df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list output has no array shape of its own; none is stated
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
get_transforms Ran
ran on a synthesized input
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/adv3_robustness_check.py
code served (permissive licence) · get_code("bcc42256373b217f")
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 Compose. 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 torchvision.transforms as T

torch.manual_seed(0)

# additional_transforms parameter should be either None or a list of transforms
additional_transforms = [
    T.RandomHorizontalFlip(p=0.5),
    T.ColorJitter(brightness=0.2)
]

ARGS = {
    "additional_transforms": additional_transforms
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
get_translation_tuples Ran
ran on a synthesized input
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/adv3_robustness_check.py
code served (permissive licence) · get_code("08fc0e1afccc13f5")
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 list, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 numpy as np

ARGS = {
    "max_trans": 100,
    "trans_log_base": 2.0,
    "trans_steps": 5,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list output has no array shape of its own; none is stated
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
hinge_loss Ran
ran on a synthesized input
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/losses/hinge_loss.py
code served (permissive licence) · get_code("a4e251357a69a2a6")
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 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

torch.manual_seed(0)

# Analyze the function:
# - outputs: tensor that gets squeezed then unsqueezed(1), then multiplied with seed via mm()
# - target_hash_bin: tensor that gets compared to 0.5 to create signs
# - seed: tensor used in torch.mm(seed, outputs) - seed is (*, outputs_dim)
# - distance: scalar (default 0)

# outputs shape after operations:
# outputs.squeeze().unsqueeze(1) means outputs should be 1D or have shape (batch,)
# then becomes (batch, 1)
# torch.mm(seed, outputs) with outputs as (batch, 1) means seed must be (*, batch)
# and result is (*, 1), then flattened to (*)

# Let's use:
# - batch_size = 2
# - hash_dim = 3 (seed rows)
# - outputs will be (2, 1) after unsqueeze, so seed should be (3, 2)

batch_size = 2
hash_dim = 3
output_dim = 1

# outputs: shape (batch_size,) which becomes (batch_size, 1) after squeeze().unsqueeze(1)
outputs = torch.randn(batch_size)

# target_hash_bin: shape (hash_dim,) to match the flattened result of mm
target_hash_bin = torch.rand(hash_dim)

# seed: shape (hash_dim, batch_size) for torch.mm(seed, outputs.unsqueeze(1))
seed = torch.randn(hash_dim, batch_size)

# distance: scalar
distance = 0.5

ARGS = {
    "outputs": outputs,
    "target_hash_bin": target_hash_bin,
    "seed": seed,
    "distance": distance,
}
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 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: none by the harness; any seed is in the setup block
load_hash_matrix Ran
ran on a synthesized input
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/utils/hashing.py
code served (permissive licence) · get_code("752453953f3f810e")
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 ndarray, ndim 2, dtype family float, shape (96, 128) 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 numpy as np
import tempfile
import os

# Create a temporary file with valid binary data for the hash matrix
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, 'neuralhash_128x96_seed1.dat')

# Create binary data: 128 bytes of padding + 96*128*4 bytes of float32 data
padding = b'\x00' * 128
hash_matrix = np.random.randn(96, 128).astype(np.float32)
binary_data = padding + hash_matrix.tobytes()

with open(temp_file, 'wb') as f:
    f.write(binary_data)

ARGS = {
    'path': temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (96, 128) — shape (96, 128) 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
mse_loss Ran
ran on a synthesized input
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/losses/mse_loss.py
code served (permissive licence) · get_code("74e2bf38733ce1eb")
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 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

torch.manual_seed(0)

# outputs: should be a tensor that gets squeezed and unsqueezed
# After squeeze().unsqueeze(1), it should have shape (N, 1) for matrix multiplication
# seed @ outputs where seed is (?, N) and outputs is (N, 1) gives (?, 1)
# Then flatten gives a 1D tensor
# We need seed to be 2D for torch.mm

# Let's work backwards:
# torch.mm(seed, outputs) with outputs shape (N, 1) requires seed shape (M, N)
# After squeeze, outputs should be 1D, so original outputs is likely (B,) or (B, 1)
# Let's say outputs is (2,) - batch of 2
# After squeeze().unsqueeze(1) -> (2, 1)
# seed should be (4, 2) so mm gives (4, 1), then flatten gives (4,)

outputs = torch.randn(2)  # shape (2,)

seed = torch.randn(4, 2)  # shape (4, 2) for torch.mm

# target_hash_bin: used in mse_loss, should match hash_output shape
# hash_output after flatten is (4,), so target_hash_bin should be (4,)
target_hash_bin = torch.randint(0, 2, (4,))  # binary targets, shape (4,)

c = 5  # integer parameter

ARGS = {
    "outputs": outputs,
    "target_hash_bin": target_hash_bin,
    "seed": seed,
    "c": c,
}
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 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: none by the harness; any seed is in the setup block
ssim_loss Ran
ran on a synthesized input
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/losses/quality_losses.py
code served (permissive licence) · get_code("f3bc4f33a06ea41f")
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 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
import math

torch.manual_seed(0)

# Create two small image tensors
# Shape: (batch=2, channels=3, height=4, width=4)
orig_image = torch.randn(2, 3, 4, 4)
optim_image = torch.randn(2, 3, 4, 4)

ARGS = {
    "orig_image": orig_image,
    "optim_image": optim_image,
    "window_size": 11,
    "channel": 3,
}
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 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: none by the harness; any seed is in the setup block
str2bool Ran
ran, violated the contract we drafted
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/adv4_information_extraction.py
code served (permissive licence) · get_code("7c508037b40522af")
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 bool, 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 argparse

def str2bool(v):
    if isinstance(v, bool):
        return v
    if v.lower() in ('yes', 'true', 't', 'y', '1'):
        return True
    elif v.lower() in ('no', 'false', 'f', 'n', '0'):
        return False
    else:
        raise argparse.ArgumentTypeError('Boolean value expected.')

# Test cases for str2bool
ARGS = {
    'v': 'true'  # string input that should convert to boolean
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, 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
compute_hash Not yet run
unverified (harvested, no recorded run)
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/utils/hashing.py
code served (permissive licence) · get_code("7686cd6d1115d544")
How it ran

no invocation recorded.

get_dataset Not yet run
unverified (harvested, no recorded run)
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/adv3_robustness_check.py
code served (permissive licence) · get_code("02b8a2e5f0aa5da2")
How it ran

no invocation recorded.

get_hashes_of_dataset Not yet run
unverified (harvested, no recorded run)
ml-research/Learning-to-Break-Deep-Perceptual-Hashing/utils/hashing.py
code served (permissive licence) · get_code("4a923d4924e00574")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 10 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
str2bool 175 other papers
43 dated earlier, 132 later · 2 only as an assembly brick
1406.6247 (2014-06)
Recurrent Models of Visual Attention
1603.09382 (2016-03)
Deep Networks with Stochastic Depth
1710.10196 (2017-10)
Progressive Growing of GANs for Improved Quality, Stability, and Variation
and 172 more not named here

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

Apple recently revealed its deep perceptual hashing system NeuralHash to detect child sexual abuse material (CSAM) on user devices before files are uploaded to its iCloud service. Public criticism quickly arose regarding the protection of user privacy and the system's reliability. In this paper, we present the first comprehensive empirical analysis of deep perceptual hashing based on NeuralHash. Specifically, we show that current deep perceptual hashing may not be robust. An adversary can manipulate the hash values by applying slight changes in images, either induced by gradient-based approaches or simply by performing standard image transformations, forcing or preventing hash collisions. Such attacks permit malicious actors easily to exploit the detection system: from hiding abusive material to framing innocent users, everything is possible. Moreover, using the hash values, inferences can still be made about the data stored on user devices. In our view, based on our results, deep perceptual hashing in its current form is generally not ready for robust client-side scanning and should not be used from a privacy perspective.

For agents

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

get_harvested_code_for_paper("2111.06628")
get_code_for_paper("2111.06628")
have("2111.06628")

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

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

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

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

Connect an agent — have() is free.