repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/structures/test_instances.py
tests/structures/test_instances.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from torch import Tensor from detectron2.export.torchscript import patch_instances from detectron2.structures import Boxes, Instances from detectron2.utils.testing import convert_scripted_instances class TestInstances(unittest.TestCase):...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/structures/test_rotated_boxes.py
tests/structures/test_rotated_boxes.py
# Copyright (c) Facebook, Inc. and its affiliates. from __future__ import absolute_import, division, print_function, unicode_literals import logging import math import random import unittest import torch from fvcore.common.benchmark import benchmark from detectron2.layers.rotated_boxes import pairwise_iou_rotated from...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/structures/test_imagelist.py
tests/structures/test_imagelist.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest from typing import List, Sequence, Tuple import torch from detectron2.structures import ImageList class TestImageList(unittest.TestCase): def test_imagelist_padding_tracing(self): # test that the trace does not contain hard-coded constan...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/structures/test_keypoints.py
tests/structures/test_keypoints.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from detectron2.structures.keypoints import Keypoints class TestKeypoints(unittest.TestCase): def test_cat_keypoints(self): keypoints1 = Keypoints(torch.rand(2, 21, 3)) keypoints2 = Keypoints(torch.rand(4, 21, 3)) ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/structures/test_boxes.py
tests/structures/test_boxes.py
# Copyright (c) Facebook, Inc. and its affiliates. import json import math import numpy as np import unittest import torch from detectron2.structures import Boxes, BoxMode, pairwise_ioa, pairwise_iou from detectron2.utils.testing import reload_script_model class TestBoxMode(unittest.TestCase): def _convert_xy_to...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/structures/__init__.py
tests/structures/__init__.py
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/structures/test_masks.py
tests/structures/test_masks.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from detectron2.structures.masks import BitMasks, PolygonMasks, polygons_to_bitmask class TestBitMask(unittest.TestCase): def test_get_bounding_box(self): masks = torch.tensor( [ [ ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/utils/test_tensorboardx.py
tests/utils/test_tensorboardx.py
import os import tempfile import unittest from detectron2.utils.events import TensorboardXWriter # TODO Fix up capitalization class TestTensorboardXWriter(unittest.TestCase): def test_no_files_created(self) -> None: with tempfile.TemporaryDirectory() as tmp_dir: writer = TensorboardXWriter(tm...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_fast_rcnn.py
tests/modeling/test_fast_rcnn.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import unittest import torch from detectron2.layers import ShapeSpec from detectron2.modeling.box_regression import Box2BoxTransform, Box2BoxTransformRotated from detectron2.modeling.roi_heads.fast_rcnn import FastRCNNOutputLayers from detectron2.modeli...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_box2box_transform.py
tests/modeling/test_box2box_transform.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import unittest import torch from detectron2.modeling.box_regression import ( Box2BoxTransform, Box2BoxTransformLinear, Box2BoxTransformRotated, ) from detectron2.utils.testing import random_boxes logger = logging.getLogger(__name__) clas...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_roi_heads.py
tests/modeling/test_roi_heads.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import unittest from copy import deepcopy import torch from torch import nn from detectron2 import model_zoo from detectron2.config import get_cfg from detectron2.export.torchscript_patch import ( freeze_training_mode, patch_builtin_len, pat...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_model_e2e.py
tests/modeling/test_model_e2e.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import unittest from contextlib import contextmanager from copy import deepcopy import torch from detectron2.structures import BitMasks, Boxes, ImageList, Instances from detectron2.utils.events import EventStorage from detectron2.utils.testing impor...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_anchor_generator.py
tests/modeling/test_anchor_generator.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import unittest import torch from detectron2.config import get_cfg from detectron2.layers import ShapeSpec from detectron2.modeling.anchor_generator import DefaultAnchorGenerator, RotatedAnchorGenerator logger = logging.getLogger(__name__) class Test...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_matcher.py
tests/modeling/test_matcher.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest from typing import List import torch from detectron2.config import get_cfg from detectron2.modeling.matcher import Matcher class TestMatcher(unittest.TestCase): def test_scriptability(self): cfg = get_cfg() anchor_matcher = Matche...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_mmdet.py
tests/modeling/test_mmdet.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest from detectron2.layers import ShapeSpec from detectron2.modeling.mmdet_wrapper import MMDetBackbone, MMDetDetector try: import mmdet.models # noqa HAS_MMDET = True except ImportError: HAS_MMDET = False @unittest.skipIf(not HAS_MMDET, "...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/__init__.py
tests/modeling/__init__.py
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_roi_pooler.py
tests/modeling/test_roi_pooler.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import unittest import torch from detectron2.modeling.poolers import ROIPooler from detectron2.structures import Boxes, RotatedBoxes from detectron2.utils.testing import random_boxes logger = logging.getLogger(__name__) class TestROIPooler(unittest.T...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_backbone.py
tests/modeling/test_backbone.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import unittest import torch import detectron2.export.torchscript # apply patch # noqa from detectron2 import model_zoo from detectron2.config import get_cfg from detectron2.layers import ShapeSpec from detectron2.modeling.backbone import build_r...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/modeling/test_rpn.py
tests/modeling/test_rpn.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import unittest import torch from detectron2.config import get_cfg from detectron2.export import scripting_with_instances from detectron2.layers import ShapeSpec from detectron2.modeling.backbone import build_backbone from detectron2.modeling.proposal_g...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_deformable.py
tests/layers/test_deformable.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import unittest import torch from detectron2.layers import DeformConv, ModulatedDeformConv from detectron2.utils.env import TORCH_VERSION @unittest.skipIf( TORCH_VERSION == (1, 8) and torch.cuda.is_available(), "This test fails under cuda1...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_roi_align_rotated.py
tests/layers/test_roi_align_rotated.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import unittest import cv2 import torch from torch.autograd import Variable, gradcheck from detectron2.layers.roi_align import ROIAlign from detectron2.layers.roi_align_rotated import ROIAlignRotated logger = logging.getLogger(__name__) class ROIAlig...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_nms.py
tests/layers/test_nms.py
# Copyright (c) Facebook, Inc. and its affiliates. from __future__ import absolute_import, division, print_function, unicode_literals import unittest import torch from detectron2.layers import batched_nms from detectron2.utils.testing import random_boxes class TestNMS(unittest.TestCase): def _create_tensors(self...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_blocks.py
tests/layers/test_blocks.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest import torch from torch import nn from detectron2.layers import ASPP, DepthwiseSeparableConv2d, FrozenBatchNorm2d from detectron2.modeling.backbone.resnet import BasicStem, ResNet """ Test for misc layers. """ class TestBlocks(unittest.TestCase): ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_losses.py
tests/layers/test_losses.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import unittest import torch from detectron2.layers import ciou_loss, diou_loss class TestLosses(unittest.TestCase): def test_diou_loss(self): """ loss = 1 - iou + d/c where, d = (distance between centers of the...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_mask_ops.py
tests/layers/test_mask_ops.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import contextlib import io import numpy as np import unittest from collections import defaultdict import torch import tqdm from fvcore.common.benchmark import benchmark from pycocotools.coco import COCO from tabulate import tabulate from torch...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_nms_rotated.py
tests/layers/test_nms_rotated.py
# Copyright (c) Facebook, Inc. and its affiliates. from __future__ import absolute_import, division, print_function, unicode_literals import numpy as np import unittest from copy import deepcopy import torch from torchvision import ops from detectron2.layers import batched_nms, batched_nms_rotated, nms_rotated from de...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/__init__.py
tests/layers/__init__.py
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/layers/test_roi_align.py
tests/layers/test_roi_align.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import unittest from copy import copy import cv2 import torch from fvcore.common.benchmark import benchmark from torch.nn import functional as F from detectron2.layers.roi_align import ROIAlign, roi_align class ROIAlignTest(unittest.TestCase): ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/test_instantiate_config.py
tests/config/test_instantiate_config.py
# Copyright (c) Facebook, Inc. and its affiliates. import os import tempfile import unittest import yaml from omegaconf import OmegaConf from omegaconf import __version__ as oc_version from dataclasses import dataclass from detectron2.config import LazyConfig, instantiate, LazyCall as L from detectron2.layers import ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/test_lazy_config.py
tests/config/test_lazy_config.py
# Copyright (c) Facebook, Inc. and its affiliates. import os import unittest import tempfile from itertools import count from detectron2.config import LazyConfig, LazyCall as L from omegaconf import DictConfig class TestLazyPythonConfig(unittest.TestCase): def setUp(self): self.curr_dir = os.path.dirname...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/root_cfg.py
tests/config/root_cfg.py
# Copyright (c) Facebook, Inc. and its affiliates. from itertools import count from detectron2.config import LazyCall as L from .dir1.dir1_a import dir1a_dict, dir1a_str dir1a_dict.a = "modified" # modification above won't affect future imports from .dir1.dir1_b import dir1b_dict, dir1b_str lazyobj = L(count)(x=d...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/test_yacs_config.py
tests/config/test_yacs_config.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. import os import tempfile import unittest import torch from omegaconf import OmegaConf from detectron2 import model_zoo from detectron2.config import configurable, downgrade_config, get_cfg, upgrade_config from detectron2.layers import ShapeSpe...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/dir1/bad_import.py
tests/config/dir1/bad_import.py
# import from directory is not allowed from . import dir1a
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/dir1/dir1_b.py
tests/config/dir1/dir1_b.py
# Copyright (c) Facebook, Inc. and its affiliates. from detectron2.config import LazyConfig # equivalent to relative import dir1a_str, dir1a_dict = LazyConfig.load_rel("dir1_a.py", ("dir1a_str", "dir1a_dict")) dir1b_str = dir1a_str + "_from_b" dir1b_dict = dir1a_dict # Every import is a reload: not modified by other...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/dir1/dir1_a.py
tests/config/dir1/dir1_a.py
# Copyright (c) Facebook, Inc. and its affiliates. dir1a_str = "base_a_1" dir1a_dict = {"a": 1, "b": 2}
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/dir1/load_rel.py
tests/config/dir1/load_rel.py
# test that load_rel can work from detectron2.config import LazyConfig x = LazyConfig.load_rel("dir1_a.py", "dir1a_dict") assert x["a"] == 1
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/config/dir1/bad_import2.py
tests/config/dir1/bad_import2.py
from .does_not_exist import x
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/export/test_c10.py
tests/export/test_c10.py
# Copyright (c) Facebook, Inc. and its affiliates. import unittest try: # Caffe2 used to be included in PyTorch, but since PyTorch 1.10+, # it is not included in pre-built packages. This is a safety BC check from detectron2.config import get_cfg from detectron2.export.c10 import Caffe2RPN from dete...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/test_detection_utils.py
tests/data/test_detection_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import numpy as np import os import unittest import pycocotools.mask as mask_util from detectron2.data import MetadataCatalog, detection_utils from detectron2.data import transforms as T from detectron2.structures import BitMasks, BoxMode from detectron2....
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/test_coco_evaluation.py
tests/data/test_coco_evaluation.py
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import copy import io import json import numpy as np import os import tempfile import unittest import torch from pycocotools.coco import COCO from pycocotools.cocoeval import COCOeval from detectron2.data import DatasetCatalog from detectron2.evaluat...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/test_coco.py
tests/data/test_coco.py
# Copyright (c) Facebook, Inc. and its affiliates. import json import numpy as np import os import tempfile import unittest import pycocotools.mask as mask_util from detectron2.data import DatasetCatalog, MetadataCatalog from detectron2.data.datasets.coco import convert_to_coco_dict, load_coco_json from detectron2.str...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/test_transforms.py
tests/data/test_transforms.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np import unittest from unittest import mock import torch from PIL import Image, ImageOps from torch.nn import functional as F from detectron2.config import get_cfg from detectron2.data import detection_utils fro...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/__init__.py
tests/data/__init__.py
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/test_sampler.py
tests/data/test_sampler.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import math import operator import unittest import torch from torch.utils import data from torch.utils.data.sampler import SequentialSampler from detectron2.data.build import worker_init_reset_seed from detectron2.data.common import DatasetFromList, T...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/test_rotation_transform.py
tests/data/test_rotation_transform.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import unittest from detectron2.data.transforms.transform import RotationTransform class TestRotationTransform(unittest.TestCase): def assertEqualsArrays(self, a1, a2): self.assertTrue(np.allclose(a1, a2)) def randomData(self, h=5...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/tests/data/test_dataset.py
tests/data/test_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. import os import pickle import sys import unittest from functools import partial import torch from iopath.common.file_io import LazyPath from detectron2 import model_zoo from detectron2.config import get_cfg, instantiate from detectron2.data import ( DatasetCatal...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/datasets/prepare_ade20k_sem_seg.py
datasets/prepare_ade20k_sem_seg.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import os from pathlib import Path import tqdm from PIL import Image def convert(input, output): img = np.asarray(Image.open(input)) assert img.dtype == np.uint8 img = img - 1 # 0 (ignore)...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/datasets/prepare_panoptic_fpn.py
datasets/prepare_panoptic_fpn.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import json import multiprocessing as mp import numpy as np import os import time from fvcore.common.download import download from panopticapi.utils import rgb2id from PIL import Image from detectron2.da...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/datasets/prepare_cocofied_lvis.py
datasets/prepare_cocofied_lvis.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import copy import json import os from collections import defaultdict # This mapping is extracted from the official LVIS mapping: # https://github.com/lvis-dataset/lvis-api/blob/master/data/coco_to_synset.json COCO_SYNSE...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/__init__.py
detectron2/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .utils.env import setup_environment setup_environment() # This line will be programatically read/write by setup.py. # Leave them at the bottom of this file and don't touch them. __version__ = "0.6"
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/tracking/iou_weighted_hungarian_bbox_iou_tracker.py
detectron2/tracking/iou_weighted_hungarian_bbox_iou_tracker.py
#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import numpy as np from typing import List from detectron2.config import CfgNode as CfgNode_ from detectron2.config import configurable from .base_tracker import TRACKER_HEADS_REGISTRY from .vanilla_hungarian_bbox_iou_tracker import Vanil...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/tracking/base_tracker.py
detectron2/tracking/base_tracker.py
#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. from detectron2.config import configurable from detectron2.utils.registry import Registry from ..config.config import CfgNode as CfgNode_ from ..structures import Instances TRACKER_HEADS_REGISTRY = Registry("TRACKER_HEADS") TRACKER_HEADS_R...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/tracking/utils.py
detectron2/tracking/utils.py
#!/usr/bin/env python3 import numpy as np from typing import List from detectron2.structures import Instances def create_prediction_pairs( instances: Instances, prev_instances: Instances, iou_all: np.ndarray, threshold: float = 0.5, ) -> List: """ Args: instances: predictions from cur...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/tracking/__init__.py
detectron2/tracking/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .base_tracker import ( # noqa BaseTracker, build_tracker_head, TRACKER_HEADS_REGISTRY, ) from .bbox_iou_tracker import BBoxIOUTracker # noqa from .hungarian_tracker import BaseHungarianTracker # noqa from .iou_weighted_hungarian_bbox_iou_tracker imp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/tracking/bbox_iou_tracker.py
detectron2/tracking/bbox_iou_tracker.py
#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np from typing import List import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detectron2.structures.boxes import pairwise_iou from ..config.config imp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/tracking/hungarian_tracker.py
detectron2/tracking/hungarian_tracker.py
#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np from typing import Dict import torch from scipy.optimize import linear_sum_assignment from detectron2.config import configurable from detectron2.structures import Boxes, Instances from ..config.config import ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/tracking/vanilla_hungarian_bbox_iou_tracker.py
detectron2/tracking/vanilla_hungarian_bbox_iou_tracker.py
#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import numpy as np from typing import List from detectron2.config import CfgNode as CfgNode_ from detectron2.config import configurable from detectron2.structures import Instances from detectron2.structures.boxes import pairwise_iou from d...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/structures/rotated_boxes.py
detectron2/structures/rotated_boxes.py
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import List, Tuple import torch from detectron2.layers.rotated_boxes import pairwise_iou_rotated from .boxes import Boxes class RotatedBoxes(Boxes): """ This structure stores a list of rotated boxes as a Nx5 torch.Tensor. It supp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/structures/instances.py
detectron2/structures/instances.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import warnings from typing import Any, Dict, List, Tuple, Union import torch class Instances: """ This class represents a list of instances in an image. It stores the attributes of instances (e.g., boxes, masks, labels, scores) as "field...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/structures/keypoints.py
detectron2/structures/keypoints.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import Any, List, Tuple, Union import torch from torch.nn import functional as F class Keypoints: """ Stores keypoint **annotation** data. GT Instances have a `gt_keypoints` property containing the x,y location and visibilit...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/structures/__init__.py
detectron2/structures/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .boxes import Boxes, BoxMode, pairwise_iou, pairwise_ioa, pairwise_point_box_distance from .image_list import ImageList from .instances import Instances from .keypoints import Keypoints, heatmaps_to_keypoints from .masks import BitMasks, PolygonMasks, polygons_to...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/structures/boxes.py
detectron2/structures/boxes.py
# Copyright (c) Facebook, Inc. and its affiliates. import math import numpy as np from enum import IntEnum, unique from typing import List, Tuple, Union import torch from torch import device _RawBoxType = Union[List[float], Tuple[float, ...], torch.Tensor, np.ndarray] @unique class BoxMode(IntEnum): """ Enum...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/structures/image_list.py
detectron2/structures/image_list.py
# Copyright (c) Facebook, Inc. and its affiliates. from __future__ import division from typing import Any, Dict, List, Optional, Tuple import torch from torch import device from torch.nn import functional as F from detectron2.layers.wrappers import move_device_like, shapes_to_tensor from detectron2.utils.torch_version...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/structures/masks.py
detectron2/structures/masks.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ROIAlign from detectron2.utils.memory import retry_if_cuda_...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/solver/build.py
detectron2/solver/build.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import logging from collections import defaultdict from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union import torch from fvcore.common.param_scheduler import ( CosineParamScheduler, ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/solver/__init__.py
detectron2/solver/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .build import build_lr_scheduler, build_optimizer, get_default_optimizer_params from .lr_scheduler import ( LRMultiplier, LRScheduler, WarmupCosineLR, WarmupMultiStepLR, WarmupParamScheduler, ) __all__ = [k for k in globals().keys() if not k.s...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/solver/lr_scheduler.py
detectron2/solver/lr_scheduler.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import math from bisect import bisect_right from typing import List import torch from fvcore.common.param_scheduler import ( CompositeParamScheduler, ConstantParamScheduler, LinearParamScheduler, ParamScheduler, ) try: from torch.opt...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/colormap.py
detectron2/utils/colormap.py
# Copyright (c) Facebook, Inc. and its affiliates. """ An awesome colormap for really neat visualizations. Copied from Detectron, and removed gray colors. """ import numpy as np import random __all__ = ["colormap", "random_color", "random_colors"] # fmt: off # RGB: _COLORS = np.array( [ 0.000, 0.447, 0....
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/develop.py
detectron2/utils/develop.py
# Copyright (c) Facebook, Inc. and its affiliates. """Utilities for developers only. These are not visible to users (not automatically imported). And should not appeared in docs.""" # adapted from https://github.com/tensorpack/tensorpack/blob/master/tensorpack/utils/develop.py def create_dummy_class(klass, dependency...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/visualizer.py
detectron2/utils/visualizer.py
# Copyright (c) Facebook, Inc. and its affiliates. import colorsys import logging import math import numpy as np from enum import Enum, unique import cv2 import matplotlib as mpl import matplotlib.colors as mplc import matplotlib.figure as mplfigure import pycocotools.mask as mask_util import torch from matplotlib.back...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
true
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/registry.py
detectron2/utils/registry.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import Any import pydoc from fvcore.common.registry import Registry # for backward compatibility. """ ``Registry`` and `locate` provide ways to map a string (typically found in config files) to callable objects. """ __all__ = ["Registry", "locate"] de...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/testing.py
detectron2/utils/testing.py
# Copyright (c) Facebook, Inc. and its affiliates. import io import numpy as np import os import re import tempfile import unittest from typing import Callable import torch import torch.onnx.symbolic_helper as sym_help from torch._C import ListType from torch.onnx import register_custom_op_symbolic from detectron2 imp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/memory.py
detectron2/utils/memory.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging from contextlib import contextmanager from functools import wraps import torch __all__ = ["retry_if_cuda_oom"] @contextmanager def _ignore_torch_cuda_oom(): """ A context which ignores CUDA OOM exception from pytorch. """ try: ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/video_visualizer.py
detectron2/utils/video_visualizer.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import List import pycocotools.mask as mask_util from detectron2.structures import Instances from detectron2.utils.visualizer import ( ColorMode, Visualizer, _create_text_labels, _PanopticPrediction, ) from .colormap imp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/serialize.py
detectron2/utils/serialize.py
# Copyright (c) Facebook, Inc. and its affiliates. import cloudpickle class PicklableWrapper: """ Wrap an object to make it more picklable, note that it uses heavy weight serialization libraries that are slower than pickle. It's best to use it only on closures (which are usually not picklable). T...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/torch_version_utils.py
detectron2/utils/torch_version_utils.py
from packaging import version def min_torch_version(min_version: str) -> bool: """ Returns True when torch's version is at least `min_version`. """ try: import torch except ImportError: return False installed_version = version.parse(torch.__version__.split("+")[0]) min_ve...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/tracing.py
detectron2/utils/tracing.py
import inspect import torch from detectron2.utils.env import TORCH_VERSION try: from torch.fx._symbolic_trace import is_fx_tracing as is_fx_tracing_current tracing_current_exists = True except ImportError: tracing_current_exists = False try: from torch.fx._symbolic_trace import _orig_module_call ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/logger.py
detectron2/utils/logger.py
# Copyright (c) Facebook, Inc. and its affiliates. import atexit import functools import logging import os import sys import time from collections import Counter import torch from tabulate import tabulate from termcolor import colored from detectron2.utils.file_io import PathManager __all__ = ["setup_logger", "log_fi...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/collect_env.py
detectron2/utils/collect_env.py
# Copyright (c) Facebook, Inc. and its affiliates. import importlib import numpy as np import os import re import subprocess import sys from collections import defaultdict import PIL import torch import torchvision from tabulate import tabulate __all__ = ["collect_env_info"] def collect_torch_env(): try: ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/events.py
detectron2/utils/events.py
# Copyright (c) Facebook, Inc. and its affiliates. import datetime import json import logging import os import time from collections import defaultdict from contextlib import contextmanager from functools import cached_property from typing import Optional import torch from fvcore.common.history_buffer import HistoryBuf...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/comm.py
detectron2/utils/comm.py
# Copyright (c) Facebook, Inc. and its affiliates. """ This file contains primitives for multi-gpu communication. This is useful when doing distributed training. """ import functools import numpy as np import torch import torch.distributed as dist _LOCAL_PROCESS_GROUP = None _MISSING_LOCAL_PG_ERROR = ( "Local pro...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/__init__.py
detectron2/utils/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates.
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/file_io.py
detectron2/utils/file_io.py
# Copyright (c) Facebook, Inc. and its affiliates. from iopath.common.file_io import HTTPURLHandler, OneDrivePathHandler, PathHandler from iopath.common.file_io import PathManager as PathManagerBase __all__ = ["PathManager", "PathHandler"] PathManager = PathManagerBase() """ This is a detectron2 project-specific Pat...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/analysis.py
detectron2/utils/analysis.py
# Copyright (c) Facebook, Inc. and its affiliates. # -*- coding: utf-8 -*- import typing from typing import Any, List import fvcore from fvcore.nn import activation_count, flop_count, parameter_count, parameter_count_table from torch import nn from detectron2.export import TracingAdapter __all__ = [ "activation_...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/utils/env.py
detectron2/utils/env.py
# Copyright (c) Facebook, Inc. and its affiliates. import importlib import importlib.util import logging import numpy as np import os import random import sys from datetime import datetime import torch __all__ = ["seed_all_rng"] TORCH_VERSION = tuple(int(x) for x in torch.__version__.split(".")[:2]) """ PyTorch vers...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/box_regression.py
detectron2/modeling/box_regression.py
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import List, Tuple, Union import torch from fvcore.nn import giou_loss, smooth_l1_loss from torch.nn import functional as F from detectron2.layers import cat, ciou_loss, diou_loss from detectron2.structures import Boxes # Value for clamping la...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/mmdet_wrapper.py
detectron2/modeling/mmdet_wrapper.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging import numpy as np from collections import OrderedDict from collections.abc import Mapping from typing import Dict, List, Optional, Tuple, Union import torch from omegaconf import DictConfig, OmegaConf from torch import Tensor, nn from ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/sampling.py
detectron2/modeling/sampling.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from detectron2.layers import nonzero_tuple __all__ = ["subsample_labels"] def subsample_labels( labels: torch.Tensor, num_samples: int, positive_fraction: float, bg_label: int ): """ Return `num_samples` (or fewer, if not enough found) ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/poolers.py
detectron2/modeling/poolers.py
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import List, Optional import torch from torch import nn from torchvision.ops import RoIPool from detectron2.layers import ROIAlign, ROIAlignRotated, cat, nonzero_tuple, shapes_to_tensor from detectron2.structures import Boxes from detectron2.ut...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/matcher.py
detectron2/modeling/matcher.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import List import torch from detectron2.layers import nonzero_tuple # TODO: the name is too general class Matcher: """ This class assigns to each predicted "element" (e.g., a box) a ground-truth element. Each predicted element will have exac...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/__init__.py
detectron2/modeling/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from detectron2.layers import ShapeSpec from .anchor_generator import build_anchor_generator, ANCHOR_GENERATOR_REGISTRY from .backbone import ( BACKBONE_REGISTRY, FPN, Backbone, ResNet, ResNetBlockBase, build_backbone, build_resnet_backbone...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/anchor_generator.py
detectron2/modeling/anchor_generator.py
# Copyright (c) Facebook, Inc. and its affiliates. import collections import math from typing import List import torch from torch import nn from detectron2.config import configurable from detectron2.layers import ShapeSpec, move_device_like from detectron2.structures import Boxes, RotatedBoxes from detectron2.utils.re...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/test_time_augmentation.py
detectron2/modeling/test_time_augmentation.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import numpy as np from contextlib import contextmanager from itertools import count from typing import List import torch from fvcore.transforms import HFlipTransform, NoOpTransform from torch import nn from torch.nn.parallel import DistributedDataParallel ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/postprocessing.py
detectron2/modeling/postprocessing.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from torch.nn import functional as F from detectron2.structures import Instances, ROIMasks # perhaps should rename to "resize_instance" def detector_postprocess( results: Instances, output_height: int, output_width: int, mask_threshold: float = 0.5 ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/proposal_generator/build.py
detectron2/modeling/proposal_generator/build.py
# Copyright (c) Facebook, Inc. and its affiliates. from detectron2.utils.registry import Registry PROPOSAL_GENERATOR_REGISTRY = Registry("PROPOSAL_GENERATOR") PROPOSAL_GENERATOR_REGISTRY.__doc__ = """ Registry for proposal generator, which produces object proposals from feature maps. The registered object will be cal...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/proposal_generator/rrpn.py
detectron2/modeling/proposal_generator/rrpn.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging from typing import Dict, List import torch from detectron2.config import configurable from detectron2.layers import ShapeSpec, batched_nms_rotated, cat from detectron2.structures import Instances, RotatedBoxes, pairwise_iou_rotated from...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/proposal_generator/__init__.py
detectron2/modeling/proposal_generator/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .build import PROPOSAL_GENERATOR_REGISTRY, build_proposal_generator from .rpn import RPN_HEAD_REGISTRY, build_rpn_head, RPN, StandardRPNHead __all__ = list(globals().keys())
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/proposal_generator/rpn.py
detectron2/modeling/proposal_generator/rpn.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import Dict, List, Optional, Tuple, Union import torch import torch.nn.functional as F from torch import nn from detectron2.config import configurable from detectron2.layers import Conv2d, ShapeSpec, cat from detectron2.structures import Boxes, ImageList, ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/proposal_generator/proposal_utils.py
detectron2/modeling/proposal_generator/proposal_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import math from typing import List, Tuple, Union import torch from detectron2.layers import batched_nms, cat, move_device_like from detectron2.structures import Boxes, Instances logger = logging.getLogger(__name__) def _is_tracing(): # (fixed in...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/meta_arch/dense_detector.py
detectron2/modeling/meta_arch/dense_detector.py
import numpy as np from typing import Dict, List, Optional, Tuple import torch from torch import Tensor, nn from detectron2.data.detection_utils import convert_image_to_rgb from detectron2.layers import move_device_like from detectron2.modeling import Backbone from detectron2.structures import Boxes, ImageList, Instan...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false