SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2201.02784 · CVPR · 2022

Relieving Long-tailed Instance Segmentation via Pairwise Class Balance

Xiangyu Zhang, Jian Sun, Peizhen Zhang, Xiu-Shen Wei, Yin-Yin He

arXiv · PDF · Open in the Atlas

Code that ran

10 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; 2 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 3 failures of our instrument; 1 no recorded run), measured 2026-11-21; 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/2201.02784.json · badge: /api/ran/2201.02784.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
2023-MindSpore-1/ms-code-105 community (classifier label)
classifier basis not recorded on the link
10 ran · 1 no recorded run
FunctionStatusWhere it lives
a_cosine_learning_rate Ran
ran, honoured the contract we drafted
2023-MindSpore-1/ms-code-105/src/lr_schedule.py
code served (permissive licence) · get_code("316fb42e9e6ed79e")
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 math

def a_cosine_learning_rate(current_step, base_lr, warmup_steps, decay_steps):
    base = float(current_step - warmup_steps) / float(decay_steps)
    learning_rate = (1 + math.cos(base * math.pi)) / 2 * base_lr
    return learning_rate

ARGS = {
    "current_step": 100,
    "base_lr": 0.1,
    "warmup_steps": 10,
    "decay_steps": 1000
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 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
accuracy Ran
ran on a synthesized input
2023-MindSpore-1/ms-code-105/src/maskrcnn/accuracy.py
code served (permissive licence) · get_code("a0d4d553d4b95e53")
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 1, dtype family float, shape (1,) 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

torch.manual_seed(0)

# Create small prediction tensor: shape (2, 4) where 2 is batch size, 4 is num_class
# Values should be prediction scores/logits
pred = torch.randn(2, 4)

# Create target tensor: shape (2,) with class indices
# Values should be in range [0, num_class)
target = torch.tensor([1, 3])

# topk can be int or tuple of ints
topk = 1

# thresh can be None or a float value
thresh = None

ARGS = {
    'pred': pred,
    'target': target,
    'topk': topk,
    'thresh': thresh
}
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 1, dtype family float, shape (1,) — shape (1,) 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
bbox2result_1image Ran
ran on a synthesized input
2023-MindSpore-1/ms-code-105/src/util.py
code served (permissive licence) · get_code("58e8ebdfdf3e7c34")
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 3, dtype family float; 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 torch
import numpy as np

torch.manual_seed(0)

# Create bboxes tensor with shape (n, 5)
# n=2 bboxes, each with 5 values (x1, y1, x2, y2, score)
bboxes = torch.tensor([
    [10.0, 20.0, 30.0, 40.0, 0.9],
    [50.0, 60.0, 70.0, 80.0, 0.8]
], dtype=torch.float32)

# Create labels tensor with shape (n,)
# 2 labels, with values in range [0, num_classes-1]
labels = torch.tensor([0, 1], dtype=torch.long)

# Number of classes including background
num_classes = 3

ARGS = {
    'bboxes': bboxes,
    'labels': labels,
    'num_classes': num_classes
}
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 list, ndim 3, dtype family float — 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
dynamic_lr Ran
ran on a synthesized input
2023-MindSpore-1/ms-code-105/src/lr_schedule.py
code served (permissive licence) · get_code("0fd930bb273bb598")
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 1, dtype family float; 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 math

class Config:
    def __init__(self):
        self.base_lr = 0.1
        self.base_step = 100
        self.total_epoch = 2
        self.warmup_step = 10
        self.warmup_ratio = 0.1

config = Config()
rank_size = 1
start_steps = 0

ARGS = {
    "config": config,
    "rank_size": rank_size,
    "start_steps": start_steps
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 list, ndim 1, dtype family float — 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_img_size Ran
ran on a synthesized input
2023-MindSpore-1/ms-code-105/postprocess.py
code served (permissive licence) · get_code("b13acc0922dade5c")
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 tuple, ndim 1, 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 torch
import numpy as np
from PIL import Image
import io

torch.manual_seed(0)

# Create a small test image in memory
img_array = np.random.randint(0, 256, (100, 150, 3), dtype=np.uint8)
img = Image.fromarray(img_array)

# Save to bytes buffer
buffer = io.BytesIO()
img.save(buffer, format='PNG')
buffer.seek(0)

# Write to a temporary file path (we'll use a string path)
import tempfile
with tempfile.NamedTemporaryFile(suffix='.png', delete=False) as f:
    f.write(buffer.getvalue())
    temp_file_path = f.name

ARGS = {
    'file_name': temp_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple 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_resize_ratio Ran
ran on a synthesized input
2023-MindSpore-1/ms-code-105/postprocess.py
code served (permissive licence) · get_code("99e18a5cd3724f31")
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

torch.manual_seed(0)

# The function get_resize_ratio takes img_size as a parameter
# img_size is used as: org_width, org_height = img_size
# So it needs to be a tuple or list of two numeric values

img_size = (640, 480)

ARGS = {
    "img_size": img_size
}
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
linear_warmup_learning_rate Ran
ran, honoured the contract we drafted
2023-MindSpore-1/ms-code-105/src/lr_schedule.py
code served (permissive licence) · get_code("d6a99ec714147ac1")
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 numpy as np

torch.manual_seed(0)

# Analyzing the function:
# - current_step: used in arithmetic (int or float)
# - warmup_steps: used in division (int or float)
# - base_lr: used in float() conversion and subtraction (int or float)
# - init_lr: used in float() conversion and addition (int or float)

ARGS = {
    "current_step": 500,
    "warmup_steps": 1000,
    "base_lr": 0.1,
    "init_lr": 0.001,
}
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 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
rescale_with_factor Ran
ran; our contract draft was wrong, not the code
2023-MindSpore-1/ms-code-105/src/dataset.py
code served (permissive licence) · get_code("81dd949ea3cb5b13")
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 3, dtype family int, shape (6, 5, 3) 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 cv2
import numpy as np

# Create a small test image (4x3 in height x width, 3 channels for BGR)
img = np.random.randint(0, 256, (4, 3, 3), dtype=np.uint8)

# Define scale factor
scale_factor = 1.5

ARGS = {
    "img": img,
    "scale_factor": scale_factor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family int, shape (6, 5, 3) — shape (6, 5, 3) 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
rescale_with_tuple Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
2023-MindSpore-1/ms-code-105/src/dataset.py
code served (permissive licence) · get_code("8178d0257544aab2")
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 tuple. 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 cv2
import numpy as np

# Create a small test image (4x3 in HxW, 3 channels for color)
img = np.random.randint(0, 256, size=(4, 3, 3), dtype=np.uint8)

# Create a scale tuple - (min_scale, max_scale)
scale = (100, 200)

ARGS = {
    "img": img,
    "scale": scale,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
xyxy2xywh Ran
ran; our contract draft was wrong, not the code
2023-MindSpore-1/ms-code-105/src/util.py
code served (permissive licence) · get_code("141b13358e6b0894")
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 1, dtype family float; 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 torch

torch.manual_seed(0)

# The function expects a bbox object with:
# - tolist() method that returns a list-like structure
# - indexing via [0], [1], [2], [3] to get bbox coordinates
# A torch tensor satisfies these requirements

bbox = torch.tensor([10.0, 20.0, 100.0, 200.0])

ARGS = {
    "bbox": bbox
}
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 list, ndim 1, dtype family float — 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
bbox_overlaps Not yet run
unverified (harvested, no recorded run)
2023-MindSpore-1/ms-code-105/src/dataset.py
code served (permissive licence) · get_code("48b4b7f4e22caf1d")
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, 7 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 0 the same month, 1 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.

FunctionAlso present inEarliest-datedOthers named
linear_warmup_learning_rate 7 other papers
7 dated earlier
1506.01497 (2015-06)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
1606.04797 (2016-06)
V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation
1606.06650 (2016-06)
3D U-Net: Learning Dense Volumetric Segmentation from Sparse Annotation
and 4 more not named here
a_cosine_learning_rate 4 other papers
4 dated earlier
1506.01497 (2015-06)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
1606.06650 (2016-06)
3D U-Net: Learning Dense Volumetric Segmentation from Sparse Annotation
1904.01906 (2019-04)
What Is Wrong With Scene Text Recognition Model Comparisons? Dataset and Model Analysis
and 1 more not named here
bbox_overlaps 3 other papers
2 dated earlier, 1 same year, order not determinable
1506.01497 (2015-06)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
1908.11542 (2019-08)
Satellite Pose Estimation with Deep Landmark Regression and Nonlinear Pose Refinement
Zhou_Slot-VPS_Object-Centric_Representation_Learning_for_Video_Panoptic_Segmentation_CVPR_2022_paper (2022 (year only))
Slot-VPS: Object-centric Representation Learning for Video Panoptic Segmentation
get_img_size 2 other papers
2 dated earlier
1611.06612 (2016-11)
RefineNet: Multi-Path Refinement Networks for High-Resolution Semantic Segmentation
1804.02767 (2018-04)
YOLOv3: An Incremental Improvement
rescale_with_factor 2 other papers
2 dated earlier
1506.01497 (2015-06)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
rescale_with_tuple 2 other papers
2 dated earlier
1506.01497 (2015-06)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
xyxy2xywh 1 other paper
1 later
2507.12857 (2025-07)
SCORE: Scene Context Matters in Open-Vocabulary Remote Sensing Instance Segmentation

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

Repositories linked to this paper

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

Abstract

Long-tailed instance segmentation is a challenging task due to the extreme imbalance of training samples among classes. It causes severe biases of the head classes (with majority samples) against the tailed ones. This renders "how to appropriately define and alleviate the bias" one of the most important issues. Prior works mainly use label distribution or mean score information to indicate a coarse-grained bias. In this paper, we explore to excavate the confusion matrix, which carries the fine-grained misclassification details, to relieve the pairwise biases, generalizing the coarse one. To this end, we propose a novel Pairwise Class Balance (PCB) method, built upon a confusion matrix which is updated during training to accumulate the ongoing prediction preferences. PCB generates fightback soft labels for regularization during training. Besides, an iterative learning paradigm is developed to support a progressive and smooth regularization in such debiasing. PCB can be plugged and played to any existing method as a complement. Experimental results on LVIS demonstrate that our method achieves state-of-the-art performance without bells and whistles. Superior results across various architectures show the generalization ability. The code and trained models are available at https://github.com/megvii-research/PCB.

For agents

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

get_harvested_code_for_paper("2201.02784")
get_code_for_paper("2201.02784")
have("2201.02784")

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

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

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

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

Connect an agent — have() is free.