SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1708.02002 · 2017

Focal Loss for Dense Object Detection

arXiv · PDF · Open in the Atlas

Code that ran

11 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, 2 violated it and 0 have no contract verdict; 9 failures of our instrument; 0 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/1708.02002.json · badge: /api/ran/1708.02002.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
RichardMathewsII/YOLBO extension (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
facebookresearch/detectron2 extension (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
daveboat/pytorch_focal_loss reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
AdeelH/pytorch-multi-class-focal-loss reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
Thinklab-SJTU/CSL_RetinaNet_Tensorflow extension (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
xytpai/retinanet reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
viethungluu/OCRetina extension (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
bb_center Ran
ran, violated the contract we drafted
RichardMathewsII/YOLBO/look_back.py
pointer only (licence: NONE) · get_code("930423fe062e034a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, RichardMathewsII/YOLBO 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.

centerBox Ran
ran; our contract draft was wrong, not the code
RichardMathewsII/YOLBO/look_back.py
pointer only (licence: NONE) · get_code("8cdfe1aec1da011c")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, RichardMathewsII/YOLBO 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.

ciou_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
facebookresearch/detectron2/detectron2/layers/losses.py
code served (permissive licence) · get_code("cee8870d4fbccc39")
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 Tensor, 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 math

torch.manual_seed(0)

# Create two sets of bounding boxes in XYXY format
# boxes1: shape (N, 4) where N=2
# Each box is [x1, y1, x2, y2] where x2 >= x1 and y2 >= y1
boxes1 = torch.tensor([
    [10.0, 20.0, 50.0, 80.0],  # box 1: x1=10, y1=20, x2=50, y2=80
    [5.0, 10.0, 25.0, 40.0]     # box 2: x1=5, y1=10, x2=25, y2=40
])

boxes2 = torch.tensor([
    [15.0, 25.0, 55.0, 85.0],  # box 1: x1=15, y1=25, x2=55, y2=85
    [8.0, 12.0, 30.0, 45.0]     # box 2: x1=8, y1=12, x2=30, y2=45
])

reduction = 'none'
eps = 1e-07

ARGS = {
    'boxes1': boxes1,
    'boxes2': boxes2,
    'reduction': reduction,
    'eps': eps
}
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 Tensor, 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
diou_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
facebookresearch/detectron2/detectron2/layers/losses.py
code served (permissive licence) · get_code("26f3066ead0d2eec")
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 Tensor, 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

torch.manual_seed(0)

# Create two sets of bounding boxes in XYXY format
# boxes1: shape (N, 4) where N=2
# Each box is [x1, y1, x2, y2] where x2 >= x1 and y2 >= y1
boxes1 = torch.tensor([
    [10.0, 20.0, 50.0, 60.0],  # box 1: valid box
    [5.0, 10.0, 25.0, 40.0]     # box 2: valid box
])

boxes2 = torch.tensor([
    [15.0, 25.0, 55.0, 65.0],  # box 1: overlaps with boxes1[0]
    [20.0, 15.0, 45.0, 50.0]   # box 2: overlaps with boxes1[1]
])

reduction = 'none'
eps = 1e-07

ARGS = {
    'boxes1': boxes1,
    'boxes2': boxes2,
    'reduction': reduction,
    'eps': eps
}
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 Tensor, 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
focal_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
daveboat/pytorch_focal_loss/focalloss.py
pointer only (licence: NONE) · get_code("6f5a902a2510561a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, daveboat/pytorch_focal_loss 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.

focal_loss Ran
ran; our contract draft was wrong, not the code
AdeelH/pytorch-multi-class-focal-loss/focal_loss.py
code served (permissive licence) · get_code("aa6467d64911f0e4")
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 FocalLoss. 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

torch.manual_seed(0)

# Define alpha as a sequence (list) of weights for each class
# Let's say we have 5 classes
num_classes = 5
alpha_list = [1.0, 2.0, 1.5, 0.5, 3.0]

# Other parameters
gamma_val = 2.0
reduction_val = 'mean'
ignore_index_val = -100
device_val = 'cpu'
dtype_val = torch.float32

ARGS = {
    'alpha': alpha_list,
    'gamma': gamma_val,
    'reduction': reduction_val,
    'ignore_index': ignore_index_val,
    'device': device_val,
    'dtype': dtype_val
}
Setup block drafted by
a language model, Claude Sonnet 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 FocalLoss — a FocalLoss output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a FocalLoss 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_gtboxes_and_label Ran
ran; our contract draft was wrong, not the code
Thinklab-SJTU/CSL_RetinaNet_Tensorflow/tools/multi_gpu_train.py
code served (permissive licence) · get_code("b07dc7faf9668206")
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 tuple, 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 numpy as np

# Create gtboxes_and_label_h with shape (num_rows, num_cols)
# This represents ground truth boxes and labels for humans
gtboxes_and_label_h = np.array([
    [10.0, 20.0, 30.0, 40.0, 1.0],
    [15.0, 25.0, 35.0, 45.0, 2.0],
    [20.0, 30.0, 40.0, 50.0, 3.0],
    [25.0, 35.0, 45.0, 55.0, 4.0],
    [30.0, 40.0, 50.0, 60.0, 5.0],
])

# Create gtboxes_and_label_r with shape (num_rows, num_cols)
# This represents ground truth boxes and labels for relationships/objects
gtboxes_and_label_r = np.array([
    [12.0, 22.0, 32.0, 42.0, 6.0],
    [17.0, 27.0, 37.0, 47.0, 7.0],
    [22.0, 32.0, 42.0, 52.0, 8.0],
    [27.0, 37.0, 47.0, 57.0, 9.0],
    [32.0, 42.0, 52.0, 62.0, 10.0],
])

# Number of objects to extract (should be <= number of rows in the arrays)
num_objects = 3

ARGS = {
    'gtboxes_and_label_h': gtboxes_and_label_h,
    'gtboxes_and_label_r': gtboxes_and_label_r,
    'num_objects': num_objects
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family float — 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_loss Ran
ran; our contract draft was wrong, not the code
xytpai/retinanet/detector.py
code served (permissive licence) · get_code("bafd66dce4d45e2a")
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 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)

temp = torch.randn(2, 4)

ARGS = {
    'temp': temp
}
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 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
look_back Ran
ran; our contract draft was wrong, not the code
RichardMathewsII/YOLBO/look_back.py
pointer only (licence: NONE) · get_code("41f3747438406647")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, RichardMathewsII/YOLBO 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.

nms Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
this paper's copy was not recorded; identical code first harvested from zhongzisha/object_detection
pointer only; the stored copy get_code serves, from zhongzisha/object_detection, is pointer only (licence: NONE) · get_code("99d667302be1c9e3")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

squeeze_last2dims_shape Ran
ran, violated the contract we drafted
viethungluu/OCRetina/onestage/keras_retinanet/models/retinanet.py
pointer only (licence: NONE) · get_code("7de75ab446b29075")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, viethungluu/OCRetina 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.

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, 6 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 6 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.

FunctionAlso present inEarliest-datedOthers named
ciou_loss 4 other papers
4 later
2304.03752 (2023-04)
V3Det: Vast Vocabulary Visual Detection Dataset
2312.08875 (2023-12)
What, How, and When Should Object Detectors Update in Continually Changing Test Domains?
2403.10191 (2024-03)
Generative Region-Language Pretraining for Open-Ended Object Detection
and 1 more not named here
diou_loss 4 other papers
4 later
2304.03752 (2023-04)
V3Det: Vast Vocabulary Visual Detection Dataset
2312.08875 (2023-12)
What, How, and When Should Object Detectors Update in Continually Changing Test Domains?
2403.10191 (2024-03)
Generative Region-Language Pretraining for Open-Ended Object Detection
and 1 more not named here
focal_loss 2 other papers
2 later
2206.11251 (2022-06)
Behavior Transformers: Cloning $k$ modes with one stone
2303.09870 (2023-03)
TeSLA: Test-Time Self-Learning With Automatic Adversarial Augmentation
get_gtboxes_and_label 2 other papers
2 later
2003.05597 (2020-03)
On the Arbitrary-Oriented Object Detection: Classification based Approaches Revisited
2011.09670 (2020-11)
Dense Label Encoding for Boundary Discontinuity Free Rotation Detection
nms 2 other papers
2 later
1904.01355 (2019-04)
FCOS: Fully Convolutional One-Stage Object Detection
1904.08900 (2019-04)
CornerNet-Lite: Efficient Keypoint Based Object Detection
get_loss 1 other paper
1 later
1904.01355 (2019-04)
FCOS: Fully Convolutional One-Stage Object Detection

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

More are linked than shown here.

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

Abstract

The highest accuracy object detectors to date are based on a two-stage approach popularized by R-CNN, where a classifier is applied to a sparse set of candidate object locations. In contrast, one-stage detectors that are applied over a regular, dense sampling of possible object locations have the potential to be faster and simpler, but have trailed the accuracy of two-stage detectors thus far. In this paper, we investigate why this is the case. We discover that the extreme foreground-background class imbalance encountered during training of dense detectors is the central cause. We propose to address this class imbalance by reshaping the standard cross entropy loss such that it down-weights the loss assigned to well-classified examples. Our novel Focal Loss focuses training on a sparse set of hard examples and prevents the vast number of easy negatives from overwhelming the detector during training. To evaluate the effectiveness of our loss, we design and train a simple dense detector we call RetinaNet. Our results show that when trained with the focal loss, RetinaNet is able to match the speed of previous one-stage detectors while surpassing the accuracy of all existing state-of-the-art two-stage detectors. Code is at: https://github.com/facebookresearch/Detectron.

For agents

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

get_harvested_code_for_paper("1708.02002")
get_code_for_paper("1708.02002")
have("1708.02002")

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

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

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

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

Connect an agent — have() is free.