SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2201.12558 · ICLR · 2023

The KFIoU Loss for Rotated Object Detection

Junchi Yan, Qi Tian, Xiaopeng Zhang, Xue Yang, Yue Zhou, Gefan Zhang, Jirui Yang, Wentao Wang

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 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 3 have no contract verdict; 1 failure 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/2201.12558.json · badge: /api/ran/2201.12558.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
Jittor/JDet canonical (classifier label)
classifier basis not recorded on the link
1 ran · 1 no recorded run
yangxue0827/RotationDetection marked official in Papers with Code
Papers with Code archive
3 ran · 2 no recorded run
FunctionStatusWhere it lives
Loss Ran
ran on a synthesized input · constructed an object; no result was computed
yangxue0827/RotationDetection/alpharotate/libs/models/losses/losses_kfiou.py
code served (permissive licence) · get_code("0699e01c78ee6d82")
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, Loss: 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 tensorflow as tf
import numpy as np
import cv2

class ConfigStandIn:
    def __init__(self):
        self.METHOD = 'H'
        self.EPSILON = 1e-5

ARGS = {
    'cfgs': ConfigStandIn()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Loss — 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 Loss 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
LossKF Ran
ran on a synthesized input
yangxue0827/RotationDetection/alpharotate/libs/models/losses/losses_kfiou.py
code served (permissive licence) · get_code("421c2975cdf18aa1")
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 EagerTensor, ndim 0, 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 tensorflow as tf
import numpy as np

# Mock config object
class MockConfig:
    def __init__(self):
        self.METHOD = 'H'
        self.EPSILON = 1e-5

# Mock bbox_transform module
class MockBboxTransform:
    @staticmethod
    def rbbox_transform_inv(boxes, deltas):
        return boxes + deltas * 0.1

# Mock iou function
def mock_iou_rotate_calculate2(boxes_pred, target_boxes):
    return np.ones((boxes_pred.shape[0], 1), dtype=np.float32) * 0.5

# Patch the module-level references
bbox_transform = MockBboxTransform()
iou_rotate_calculate2 = mock_iou_rotate_calculate2

class Loss(object):

    def __init__(self, cfgs):
        self.cfgs = cfgs

    def focal_loss(self, labels, pred, anchor_state, alpha=0.25, gamma=2.0):
        indices = tf.reshape(tf.where(tf.not_equal(anchor_state, -1)), [-1])
        labels = tf.gather(labels, indices)
        pred = tf.gather(pred, indices)
        per_entry_cross_ent = tf.nn.sigmoid_cross_entropy_with_logits(labels=labels, logits=pred)
        prediction_probabilities = tf.sigmoid(pred)
        p_t = labels * prediction_probabilities + (1 - labels) * (1 - prediction_probabilities)
        modulating_factor = 1.0
        if gamma:
            modulating_factor = tf.pow(1.0 - p_t, gamma)
        alpha_weight_factor = 1.0
        if alpha is not None:
            alpha_weight_factor = labels * alpha + (1 - labels) * (1 - alpha)
        focal_cross_entropy_loss = modulating_factor * alpha_weight_factor * per_entry_cross_ent
        normalizer = tf.stop_gradient(tf.where(tf.equal(anchor_state, 1)))
        normalizer = tf.cast(tf.shape(normalizer)[0], tf.float32)
        normalizer = tf.maximum(1.0, normalizer)
        return tf.reduce_sum(focal_cross_entropy_loss) / normalizer

    def smooth_l1_loss(self, targets, preds, anchor_state, sigma=3.0, weight=None):
        sigma_squared = sigma ** 2
        indices = tf.reshape(tf.where(tf.equal(anchor_state, 1)), [-1])
        preds = tf.gather(preds, indices)
        targets = tf.gather(targets, indices)
        regression_diff = preds - targets
        regression_diff = tf.abs(regression_diff)
        regression_loss = tf.where(tf.less(regression_diff, 1.0 / sigma_squared), 0.5 * sigma_squared * tf.pow(regression_diff, 2), regression_diff - 0.5 / sigma_squared)
        if weight is not None:
            regression_loss = tf.reduce_sum(regression_loss, axis=-1)
            weight = tf.gather(weight, indices)
            regression_loss *= weight
        normalizer = tf.stop_gradient(tf.where(tf.equal(anchor_state, 1)))
        normalizer = tf.cast(tf.shape(normalizer)[0], tf.float32)
        normalizer = tf.maximum(1.0, normalizer)
        return tf.reduce_sum(regression_loss) / normalizer

INIT_ARGS = {
    'cfgs': MockConfig()
}

ARGS = {
    'labels': tf.constant([[1.0], [0.0]], dtype=tf.float32),
    'pred': tf.constant([[0.5], [-0.3]], dtype=tf.float32),
    'anchor_state': tf.constant([1, 1], dtype=tf.int32),
    'alpha': 0.25,
    'gamma': 2.0
}

METHOD = 'focal_loss'

if __name__ == '__main__':
    loss_obj = Loss(**INIT_ARGS)
    result = loss_obj.focal_loss(**ARGS)
    print(f"Loss result: {result.numpy()}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
cv2, numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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)
iou_rotate_calculate2 Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
yangxue0827/RotationDetection/alpharotate/libs/models/losses/losses_kfiou.py
code served (permissive licence) · get_code("da84e065b468cfe0")
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 (2, 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 numpy as np
import cv2

# Examine the function to understand what it needs:
# - boxes1: numpy array with shape (n, 5) where columns are [x, y, width, height, angle]
# - boxes2: numpy array with shape (n, 5) with same structure
# The function iterates through boxes1 and compares with boxes2 at same indices
# It uses cv2.rotatedRectangleIntersection which expects:
#   - r1, r2: tuples of ((center_x, center_y), (width, height), angle)

# Create small sample rotated bounding boxes
# Format: [center_x, center_y, width, height, angle]
boxes1 = np.array([
    [50.0, 50.0, 20.0, 30.0, 0.0],
    [100.0, 100.0, 25.0, 35.0, 45.0]
], dtype=np.float32)

boxes2 = np.array([
    [55.0, 55.0, 20.0, 30.0, 0.0],
    [105.0, 105.0, 25.0, 35.0, 45.0]
], dtype=np.float32)

ARGS = {
    'boxes1': boxes1,
    'boxes2': boxes2
}
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 2, dtype family float, shape (2, 1) — shape (2, 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
to_2tuple Ran
ran on a synthesized input
Jittor/JDet/python/jdet/models/backbones/lsknet.py
code served (permissive licence) · get_code("3516103014b49aca")
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

torch.manual_seed(0)

# Analyze the function: to_2tuple takes a single parameter 'x'
# It checks if x is an int, float, or a tuple/list of length 2
# We need to test with valid inputs

ARGS = {
    'x': 5  # int input - will return (5, 5)
}
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 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
backward_convert Not yet run
unverified (harvested, no recorded run)
yangxue0827/RotationDetection/alpharotate/libs/models/losses/losses_kfiou.py
code served (permissive licence) · get_code("b5addcc393d1386e")
How it ran

no invocation recorded.

coordinate_present_convert Not yet run
unverified (harvested, no recorded run)
yangxue0827/RotationDetection/alpharotate/libs/models/losses/losses_kfiou.py
code served (permissive licence) · get_code("61ebb77db4a0968f")
How it ran

no invocation recorded.

get_classes_by_name Not yet run
unverified (harvested, no recorded run)
Jittor/JDet/python/jdet/config/constant.py
code served (permissive licence) · get_code("54f118f70ca040f9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 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 7 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

Differing from the well-developed horizontal object detection area whereby the computing-friendly IoU based loss is readily adopted and well fits with the detection metrics. In contrast, rotation detectors often involve a more complicated loss based on SkewIoU which is unfriendly to gradient-based training. In this paper, we propose an effective approximate SkewIoU loss based on Gaussian modeling and Gaussian product, which mainly consists of two items. The first term is a scale-insensitive center point loss, which is used to quickly narrow the distance between the center points of the two bounding boxes. In the distance-independent second term, the product of the Gaussian distributions is adopted to inherently mimic the mechanism of SkewIoU by its definition, and show its alignment with the SkewIoU loss at trend-level within a certain distance (i.e. within 9 pixels). This is in contrast to recent Gaussian modeling based rotation detectors e.g. GWD loss and KLD loss that involve a human-specified distribution distance metric which require additional hyperparameter tuning that vary across datasets and detectors. The resulting new loss called KFIoU loss is easier to implement and works better compared with exact SkewIoU loss, thanks to its full differentiability and ability to handle the non-overlapping cases. We further extend our technique to the 3-D case which also suffers from the same issues as 2-D. Extensive results on various public datasets (2-D/3-D, aerial/text/face images) with different base detectors show the effectiveness of our approach.

For agents

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

get_harvested_code_for_paper("2201.12558")
get_code_for_paper("2201.12558")
have("2201.12558")

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

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

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

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

Connect an agent — have() is free.