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/detectron2/modeling/meta_arch/rcnn.py
detectron2/modeling/meta_arch/rcnn.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np from typing import Dict, List, Optional, Tuple import torch from torch import nn from detectron2.config import configurable from detectron2.data.detection_utils import convert_image_to_rgb from detectron2.layers import move_device_lik...
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/semantic_seg.py
detectron2/modeling/meta_arch/semantic_seg.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import Callable, Dict, Optional, Tuple, Union import fvcore.nn.weight_init as weight_init import torch from torch import nn from torch.nn import functional as F from detectron2.config import configurable from detectron2.layers import Con...
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/retinanet.py
detectron2/modeling/meta_arch/retinanet.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import math from typing import List, Tuple import torch from fvcore.nn import sigmoid_focal_loss_jit from torch import Tensor, nn from torch.nn import functional as F from detectron2.config import configurable from detectron2.layers import CycleBatchNor...
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/panoptic_fpn.py
detectron2/modeling/meta_arch/panoptic_fpn.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import logging from typing import Dict, List import torch from torch import nn from detectron2.config import configurable from detectron2.structures import ImageList from ..postprocessing import detector_postprocess, sem_seg_postprocess from ...
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/build.py
detectron2/modeling/meta_arch/build.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from detectron2.utils.logger import _log_api_usage from detectron2.utils.registry import Registry META_ARCH_REGISTRY = Registry("META_ARCH") # noqa F401 isort:skip META_ARCH_REGISTRY.__doc__ = """ Registry for meta-architectures, i.e. the whole model. ...
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/fcos.py
detectron2/modeling/meta_arch/fcos.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging from typing import List, Optional, Tuple import torch from fvcore.nn import sigmoid_focal_loss_jit from torch import nn from torch.nn import functional as F from detectron2.layers import ShapeSpec, batched_nms from detectron2.structures import Boxes, I...
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/__init__.py
detectron2/modeling/meta_arch/__init__.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. from .build import META_ARCH_REGISTRY, build_model # isort:skip from .panoptic_fpn import PanopticFPN # import all the meta_arch, so they will be registered from .rcnn import GeneralizedRCNN, ProposalNetwork from .dense_detector import Dense...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/fast_rcnn.py
detectron2/modeling/roi_heads/fast_rcnn.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging from typing import Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.nn import functional as F from detectron2.config import configurable from detectron2.data.detection_utils import get_fed_loss_cls_weights from d...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/rotated_fast_rcnn.py
detectron2/modeling/roi_heads/rotated_fast_rcnn.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np import torch from detectron2.config import configurable from detectron2.layers import ShapeSpec, batched_nms_rotated from detectron2.structures import Instances, RotatedBoxes, pairwise_iou_rotated from detectron2.utils.events import g...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/mask_head.py
detectron2/modeling/roi_heads/mask_head.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import List import fvcore.nn.weight_init as weight_init import torch from torch import nn from torch.nn import functional as F from detectron2.config import configurable from detectron2.layers import Conv2d, ConvTranspose2d, ShapeSpec, cat, get_norm from d...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/box_head.py
detectron2/modeling/roi_heads/box_head.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import List import fvcore.nn.weight_init as weight_init import torch from torch import nn from detectron2.config import configurable from detectron2.layers import Conv2d, ShapeSpec, get_norm from detectron2.utils.registry import Registry...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/cascade_rcnn.py
detectron2/modeling/roi_heads/cascade_rcnn.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import List import torch from torch import nn from torch.autograd.function import Function from detectron2.config import configurable from detectron2.layers import ShapeSpec from detectron2.structures import Boxes, Instances, pairwise_iou from detectron2.u...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/keypoint_head.py
detectron2/modeling/roi_heads/keypoint_head.py
# Copyright (c) Facebook, Inc. and its affiliates. from typing import List import torch from torch import nn from torch.nn import functional as F from detectron2.config import configurable from detectron2.layers import Conv2d, ConvTranspose2d, cat, interpolate from detectron2.structures import Instances, heatmaps_to_k...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/__init__.py
detectron2/modeling/roi_heads/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .box_head import ROI_BOX_HEAD_REGISTRY, build_box_head, FastRCNNConvFCHead from .keypoint_head import ( ROI_KEYPOINT_HEAD_REGISTRY, build_keypoint_head, BaseKeypointRCNNHead, KRCNNConvDeconvUpsampleHead, ) from .mask_head import ( ROI_MASK_HEAD...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/roi_heads/roi_heads.py
detectron2/modeling/roi_heads/roi_heads.py
# Copyright (c) Facebook, Inc. and its affiliates. import inspect import logging import numpy as np from typing import Dict, List, Optional, Tuple import torch from torch import nn from detectron2.config import configurable from detectron2.layers import ShapeSpec, nonzero_tuple from detectron2.structures import Boxes,...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
true
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/build.py
detectron2/modeling/backbone/build.py
# Copyright (c) Facebook, Inc. and its affiliates. from detectron2.layers import ShapeSpec from detectron2.utils.registry import Registry from .backbone import Backbone BACKBONE_REGISTRY = Registry("BACKBONE") BACKBONE_REGISTRY.__doc__ = """ Registry for backbones, which extract feature maps from images The register...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/vit.py
detectron2/modeling/backbone/vit.py
import logging import math import fvcore.nn.weight_init as weight_init import torch import torch.nn as nn from detectron2.layers import CNNBlockBase, Conv2d, get_norm from detectron2.modeling.backbone.fpn import _assert_strides_are_log2_contiguous from .backbone import Backbone from .utils import ( PatchEmbed, ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/mvit.py
detectron2/modeling/backbone/mvit.py
import logging import numpy as np import torch import torch.nn as nn from .backbone import Backbone from .utils import ( PatchEmbed, add_decomposed_rel_pos, get_abs_pos, window_partition, window_unpartition, ) logger = logging.getLogger(__name__) __all__ = ["MViT"] def attention_pool(x, pool, ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/backbone.py
detectron2/modeling/backbone/backbone.py
# Copyright (c) Facebook, Inc. and its affiliates. from abc import ABCMeta, abstractmethod from typing import Dict import torch.nn as nn from detectron2.layers import ShapeSpec __all__ = ["Backbone"] class Backbone(nn.Module, metaclass=ABCMeta): """ Abstract base class for network backbones. """ de...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/resnet.py
detectron2/modeling/backbone/resnet.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import fvcore.nn.weight_init as weight_init import torch import torch.nn.functional as F from torch import nn from detectron2.layers import ( CNNBlockBase, Conv2d, DeformConv, ModulatedDeformConv, ShapeSpec, get_norm, ) from...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/utils.py
detectron2/modeling/backbone/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import math import torch import torch.nn as nn import torch.nn.functional as F __all__ = [ "window_partition", "window_unpartition", "add_decomposed_rel_pos", "get_abs_pos", "PatchEmbed", ] def window_partition(x, window_size)...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/__init__.py
detectron2/modeling/backbone/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .build import build_backbone, BACKBONE_REGISTRY # noqa F401 isort:skip from .backbone import Backbone from .fpn import FPN from .regnet import RegNet from .resnet import ( BasicStem, ResNet, ResNetBlockBase, build_resnet_backbone, make_stage,...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/fpn.py
detectron2/modeling/backbone/fpn.py
# Copyright (c) Facebook, Inc. and its affiliates. import math import fvcore.nn.weight_init as weight_init import torch import torch.nn.functional as F from torch import nn from detectron2.layers import Conv2d, ShapeSpec, get_norm from .backbone import Backbone from .build import BACKBONE_REGISTRY from .resnet import...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/swin.py
detectron2/modeling/backbone/swin.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Implementation of Swin models from :paper:`swin`. This code is adapted from https://github.com/SwinTransformer/Swin-Transformer-Object-Detection/blob/master/mmdet/models/backbones/swin_transformer.py with minimal modifications. # noqa --------...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/modeling/backbone/regnet.py
detectron2/modeling/backbone/regnet.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Implementation of RegNet models from :paper:`dds` and :paper:`scaling`. This code is adapted from https://github.com/facebookresearch/pycls with minimal modifications. Some code duplication exists between RegNet and ResNets (e.g., ResStem) in o...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/roi_align_rotated.py
detectron2/layers/roi_align_rotated.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from detectron2.layers.wrappers import disable_torch_compiler class _ROIAlignRotated(Function): ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/rotated_boxes.py
detectron2/layers/rotated_boxes.py
# Copyright (c) Facebook, Inc. and its affiliates. from __future__ import absolute_import, division, print_function, unicode_literals import torch def pairwise_iou_rotated(boxes1, boxes2): """ Return intersection-over-union (Jaccard index) of boxes. Both sets of boxes are expected to be in (x_center,...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/blocks.py
detectron2/layers/blocks.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import fvcore.nn.weight_init as weight_init from torch import nn from .batch_norm import FrozenBatchNorm2d, get_norm from .wrappers import Conv2d """ CNN building blocks. """ class CNNBlockBase(nn.Module): """ A CNN block is assume...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/mask_ops.py
detectron2/layers/mask_ops.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import Tuple import torch from PIL import Image from torch.nn import functional as F __all__ = ["paste_masks_in_image"] BYTES_PER_FLOAT = 4 # TODO: This memory limit may be too much or too little. It would be better to # determine it b...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/wrappers.py
detectron2/layers/wrappers.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Wrappers around on some nn functions, mainly to support empty tensors. Ideally, add support directly in PyTorch to empty tensors in those functions. These can be removed once https://github.com/pytorch/pytorch/issues/12013 is implemented """ import functools imp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/batch_norm.py
detectron2/layers/batch_norm.py
# Copyright (c) Facebook, Inc. and its affiliates. import torch import torch.distributed as dist from fvcore.nn.distributed import differentiable_all_reduce from torch import nn from torch.nn import functional as F from detectron2.utils import comm, env from .wrappers import BatchNorm2d class FrozenBatchNorm2d(nn.M...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/roi_align.py
detectron2/layers/roi_align.py
# Copyright (c) Facebook, Inc. and its affiliates. from torch import nn from torchvision.ops import roi_align # NOTE: torchvision's RoIAlign has a different default aligned=False class ROIAlign(nn.Module): def __init__(self, output_size, spatial_scale, sampling_ratio, aligned=True): """ Args: ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/deform_conv.py
detectron2/layers/deform_conv.py
# Copyright (c) Facebook, Inc. and its affiliates. import math from functools import lru_cache import torch from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from torchvision.ops import deform_conv2d from detectron2...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/losses.py
detectron2/layers/losses.py
import math import torch def diou_loss( boxes1: torch.Tensor, boxes2: torch.Tensor, reduction: str = "none", eps: float = 1e-7, ) -> torch.Tensor: """ Distance Intersection over Union Loss (Zhaohui Zheng et. al) https://arxiv.org/abs/1911.08287 Args: boxes1, boxes2 (Tensor): bo...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/__init__.py
detectron2/layers/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .batch_norm import FrozenBatchNorm2d, get_norm, NaiveSyncBatchNorm, CycleBatchNormList from .deform_conv import DeformConv, ModulatedDeformConv from .mask_ops import paste_masks_in_image from .nms import batched_nms, batched_nms_rotated, nms, nms_rotated from .roi...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/shape_spec.py
detectron2/layers/shape_spec.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. from dataclasses import dataclass from typing import Optional @dataclass class ShapeSpec: """ A simple structure that contains basic shape specification about a tensor. It is often used as the auxiliary inputs/outputs of models, ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/aspp.py
detectron2/layers/aspp.py
# Copyright (c) Facebook, Inc. and its affiliates. from copy import deepcopy import fvcore.nn.weight_init as weight_init import torch from torch import nn from torch.nn import functional as F from .batch_norm import get_norm from .blocks import DepthwiseSeparableConv2d from .wrappers import Conv2d class ASPP(nn.Mod...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/layers/nms.py
detectron2/layers/nms.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import torch from torchvision.ops import boxes as box_ops from torchvision.ops import nms # noqa . for compatibility from detectron2.layers.wrappers import disable_torch_compiler def batched_nms( boxes: torch.Tensor, scores: torch.Tenso...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/config/instantiate.py
detectron2/config/instantiate.py
# Copyright (c) Facebook, Inc. and its affiliates. import collections.abc as abc import dataclasses import logging from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def dump_dataclass(obj: Any): """ Dump a dataclass re...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/config/defaults.py
detectron2/config/defaults.py
# Copyright (c) Facebook, Inc. and its affiliates. from .config import CfgNode as CN # NOTE: given the new config system # (https://detectron2.readthedocs.io/en/latest/tutorials/lazyconfigs.html), # we will stop adding new functionalities to default CfgNode. # ---------------------------------------------------------...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/config/compat.py
detectron2/config/compat.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Backward compatibility of configs. Instructions to bump version: + It's not needed to bump version if new keys are added. It's only needed when backward-incompatible changes happen (i.e., some existing keys disappear, or the meaning of a key changes) + To bump...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/config/lazy.py
detectron2/config/lazy.py
# Copyright (c) Facebook, Inc. and its affiliates. import ast import builtins import collections.abc as abc import importlib import inspect import logging import os import uuid from contextlib import contextmanager from copy import deepcopy from dataclasses import is_dataclass from typing import List, Tuple, Union imp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/config/config.py
detectron2/config/config.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): """ The same as `fvcore.common.config.CfgNode`, but differe...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/config/__init__.py
detectron2/config/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .compat import downgrade_config, upgrade_config from .config import CfgNode, get_cfg, global_cfg, set_global_cfg, configurable from .instantiate import instantiate from .lazy import LazyCall, LazyConfig __all__ = [ "CfgNode", "get_cfg", "global_cfg", ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/api.py
detectron2/export/api.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import os import torch from caffe2.proto import caffe2_pb2 from torch import nn from detectron2.config import CfgNode from detectron2.utils.file_io import PathManager from .caffe2_inference import ProtobufDetectionModel from .caffe2_modelin...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/caffe2_modeling.py
detectron2/export/caffe2_modeling.py
# Copyright (c) Facebook, Inc. and its affiliates. import functools import io import struct import types import torch from detectron2.modeling import meta_arch from detectron2.modeling.box_regression import Box2BoxTransform from detectron2.modeling.roi_heads import keypoint_head from detectron2.structures import Boxe...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/c10.py
detectron2/export/c10.py
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import Dict import torch import torch.nn.functional as F from detectron2.layers import ShapeSpec, cat from detectron2.layers.roi_align_rotated import ROIAlignRotated from detectron2.modeling import poolers from detectron2.modeling.proposal_gen...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/torchscript.py
detectron2/export/torchscript.py
# Copyright (c) Facebook, Inc. and its affiliates. import os import torch from detectron2.utils.file_io import PathManager from .torchscript_patch import freeze_training_mode, patch_instances __all__ = ["scripting_with_instances", "dump_torchscript_IR"] def scripting_with_instances(model, fields): """ Run...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/shared.py
detectron2/export/shared.py
# Copyright (c) Facebook, Inc. and its affiliates. import collections import copy import functools import logging import numpy as np import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union from unittest import mock import caffe2.python.utils as putils import torch import torch.nn.functional as F...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
true
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/caffe2_inference.py
detectron2/export/caffe2_inference.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np from itertools import count import torch from caffe2.proto import caffe2_pb2 from caffe2.python import core from .caffe2_modeling import META_ARCH_CAFFE2_EXPORT_TYPE_MAP, convert_batched_inputs_to_c2_format from .shared import Scoped...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/__init__.py
detectron2/export/__init__.py
# -*- coding: utf-8 -*- import warnings from .flatten import TracingAdapter from .torchscript import dump_torchscript_IR, scripting_with_instances try: from caffe2.proto import caffe2_pb2 as _tmp from caffe2.python import core # caffe2 is optional except ImportError: pass else: from .api import ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/caffe2_export.py
detectron2/export/caffe2_export.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import io import logging import numpy as np from typing import List import onnx import onnx.optimizer import torch from caffe2.proto import caffe2_pb2 from caffe2.python import core from caffe2.python.onnx.backend import Caffe2Backend from tabulate import ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/torchscript_patch.py
detectron2/export/torchscript_patch.py
# Copyright (c) Facebook, Inc. and its affiliates. import os import sys import tempfile from contextlib import ExitStack, contextmanager from copy import deepcopy from unittest import mock import torch from torch import nn # need some explicit imports due to https://github.com/pytorch/pytorch/issues/38964 import dete...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/caffe2_patch.py
detectron2/export/caffe2_patch.py
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib from unittest import mock import torch from detectron2.modeling import poolers from detectron2.modeling.proposal_generator import rpn from detectron2.modeling.roi_heads import keypoint_head, mask_head from detectron2.modeling.roi_heads.fast_rcnn imp...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/export/flatten.py
detectron2/export/flatten.py
# Copyright (c) Facebook, Inc. and its affiliates. import collections from dataclasses import dataclass from typing import Callable, List, Optional, Tuple import torch from torch import nn from detectron2.structures import Boxes, Instances, ROIMasks from detectron2.utils.registry import _convert_target_to_string, loca...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/checkpoint/c2_model_loading.py
detectron2/checkpoint/c2_model_loading.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch def convert_basic_c2_names(original_keys): """ Apply some basic name conversion to names in C2 weights. It only deals with typical backbone models. Args: original...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/checkpoint/catalog.py
detectron2/checkpoint/catalog.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging from detectron2.utils.file_io import PathHandler, PathManager class ModelCatalog: """ Store mappings from names to third-party models. """ S3_C2_DETECTRON_PREFIX = "https://dl.fbaipublicfiles.com/detectron" # MSRA models have STR...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/checkpoint/__init__.py
detectron2/checkpoint/__init__.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. # File: from . import catalog as _UNUSED # register the handler from .detection_checkpoint import DetectionCheckpointer from fvcore.common.checkpoint import Checkpointer, PeriodicCheckpointer __all__ = ["Checkpointer", "PeriodicCheckpointer"...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/checkpoint/detection_checkpoint.py
detectron2/checkpoint/detection_checkpoint.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import os import pickle from urllib.parse import parse_qs, urlparse import torch from fvcore.common.checkpoint import Checkpointer from torch.nn.parallel import DistributedDataParallel import detectron2.utils.comm as comm from detectron2.utils.file_io i...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/common.py
detectron2/data/common.py
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import copy import itertools import logging import numpy as np import pickle import random from typing import Callable, Union import torch import torch.utils.data as data from torch.utils.data.sampler import Sampler from detectron2.utils.serialize im...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/dataset_mapper.py
detectron2/data/dataset_mapper.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import numpy as np from typing import List, Optional, Union import torch from detectron2.config import configurable from . import detection_utils as utils from . import transforms as T """ This file contains the default mapping that's appl...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/build.py
detectron2/data/build.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging import numpy as np import operator import pickle from collections import OrderedDict, defaultdict from typing import Any, Callable, Dict, List, Optional, Union import torch import torch.utils.data as torchdata from tabulate import tabula...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/catalog.py
detectron2/data/catalog.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import types from collections import UserDict from typing import List from detectron2.utils.logger import log_first_n __all__ = ["DatasetCatalog", "MetadataCatalog", "Metadata"] class _DatasetCatalog(UserDict): """ A global dictio...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/detection_utils.py
detectron2/data/detection_utils.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. """ Common data processing utilities that are used in a typical object detection data pipeline. """ import logging import numpy as np from typing import List, Union import pycocotools.mask as mask_util import torch from PIL import Image from d...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/benchmark.py
detectron2/data/benchmark.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np from itertools import count from typing import List, Tuple import torch import tqdm from fvcore.common.timer import Timer from detectron2.utils import comm from .build import build_batch_data_loader from .common import DatasetFromLis...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/__init__.py
detectron2/data/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from . import transforms # isort:skip from .build import ( build_batch_data_loader, build_detection_test_loader, build_detection_train_loader, get_detection_dataset_dicts, load_proposals_into_dataset, print_instances_class_histogram, ) from .c...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/transforms/transform.py
detectron2/data/transforms/transform.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. """ See "Data Augmentation" tutorial for an overview of the system: https://detectron2.readthedocs.io/tutorials/augmentation.html """ import numpy as np import torch import torch.nn.functional as F from fvcore.transforms.transform import ( ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/transforms/augmentation_impl.py
detectron2/data/transforms/augmentation_impl.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. """ Implement many useful :class:`Augmentation`. """ import numpy as np import sys from numpy import random from typing import Tuple import torch from fvcore.transforms.transform import ( BlendTransform, CropTransform, HFlipTransform...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/transforms/augmentation.py
detectron2/data/transforms/augmentation.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import inspect import numpy as np import pprint from typing import Any, List, Optional, Tuple, Union from fvcore.transforms.transform import Transform, TransformList """ See "Data Augmentation" tutorial for an overview of the system: https://d...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/transforms/__init__.py
detectron2/data/transforms/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from fvcore.transforms.transform import Transform, TransformList # order them first from fvcore.transforms.transform import * from .transform import * from .augmentation import * from .augmentation_impl import * __all__ = [k for k in globals().keys() if not k.startsw...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/coco_panoptic.py
detectron2/data/datasets/coco_panoptic.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import json import os from detectron2.data import DatasetCatalog, MetadataCatalog from detectron2.utils.file_io import PathManager from .coco import load_coco_json, load_sem_seg __all__ = ["register_coco_panoptic", "register_coco_panoptic_separated"] d...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/builtin.py
detectron2/data/datasets/builtin.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. """ This file registers pre-defined datasets at hard-coded paths, and their metadata. We hard-code metadata for common datasets. This will enable: 1. Consistency check when loading the datasets 2. Use models on these standard datasets directl...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/coco.py
detectron2/data/datasets/coco.py
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import datetime import io import json import logging import numpy as np import os import shutil import pycocotools.mask as mask_util from fvcore.common.timer import Timer from iopath.common.file_io import file_lock from PIL import Image from detectro...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/pascal_voc.py
detectron2/data/datasets/pascal_voc.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import os import xml.etree.ElementTree as ET from typing import List, Tuple, Union from detectron2.data import DatasetCatalog, MetadataCatalog from detectron2.structures import BoxMode from detectron2.utils.file_io import Pa...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/register_coco.py
detectron2/data/datasets/register_coco.py
# Copyright (c) Facebook, Inc. and its affiliates. from .coco import register_coco_instances # noqa from .coco_panoptic import register_coco_panoptic_separated # noqa
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/lvis_v1_category_image_count.py
detectron2/data/datasets/lvis_v1_category_image_count.py
# Copyright (c) Facebook, Inc. and its affiliates. # Autogen with # with open("lvis_v1_train.json", "r") as f: # a = json.load(f) # c = a["categories"] # for x in c: # del x["name"] # del x["instance_count"] # del x["def"] # del x["synonyms"] # del x["frequency"] # del x["synset"] # LVIS_CATEGORY_IMAGE_COUNT = repr...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
true
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/lvis.py
detectron2/data/datasets/lvis.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import os from fvcore.common.timer import Timer from detectron2.data import DatasetCatalog, MetadataCatalog from detectron2.structures import BoxMode from detectron2.utils.file_io import PathManager from .builtin_meta import _get_coco_instances_meta fr...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/cityscapes.py
detectron2/data/datasets/cityscapes.py
# Copyright (c) Facebook, Inc. and its affiliates. import functools import json import logging import multiprocessing as mp import numpy as np import os from itertools import chain import pycocotools.mask as mask_util from PIL import Image from detectron2.structures import BoxMode from detectron2.utils.comm import get...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/cityscapes_panoptic.py
detectron2/data/datasets/cityscapes_panoptic.py
# Copyright (c) Facebook, Inc. and its affiliates. import json import logging import os from detectron2.data import DatasetCatalog, MetadataCatalog from detectron2.data.datasets.builtin_meta import CITYSCAPES_CATEGORIES from detectron2.utils.file_io import PathManager """ This file contains functions to register the ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/__init__.py
detectron2/data/datasets/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .coco import load_coco_json, load_sem_seg, register_coco_instances, convert_to_coco_json from .coco_panoptic import register_coco_panoptic, register_coco_panoptic_separated from .lvis import load_lvis_json, register_lvis_instances, get_lvis_instances_meta from .pa...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/lvis_v0_5_categories.py
detectron2/data/datasets/lvis_v0_5_categories.py
# Copyright (c) Facebook, Inc. and its affiliates. # Autogen with # with open("lvis_v0.5_val.json", "r") as f: # a = json.load(f) # c = a["categories"] # for x in c: # del x["image_count"] # del x["instance_count"] # LVIS_CATEGORIES = repr(c) + " # noqa" # fmt: off
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
true
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/builtin_meta.py
detectron2/data/datasets/builtin_meta.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. """ Note: For your custom dataset, there is no need to hard-code metadata anywhere in the code. For example, for COCO-format dataset, metadata will be obtained automatically when calling `load_coco_json`. For other dataset, metadata may also be...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/datasets/lvis_v1_categories.py
detectron2/data/datasets/lvis_v1_categories.py
# Copyright (c) Facebook, Inc. and its affiliates. # Autogen with # with open("lvis_v1_val.json", "r") as f: # a = json.load(f) # c = a["categories"] # for x in c: # del x["image_count"] # del x["instance_count"] # LVIS_CATEGORIES = repr(c) + " # noqa" # with open("/tmp/lvis_categories.py", "wt") as f: # ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
true
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/samplers/grouped_batch_sampler.py
detectron2/data/samplers/grouped_batch_sampler.py
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from torch.utils.data.sampler import BatchSampler, Sampler class GroupedBatchSampler(BatchSampler): """ Wraps another sampler to yield a mini-batch of indices. It enforces that the batch only contain elements from the same group. It...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/samplers/distributed_sampler.py
detectron2/data/samplers/distributed_sampler.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging import math from collections import defaultdict from typing import Optional import torch from torch.utils.data.sampler import Sampler from detectron2.utils import comm logger = logging.getLogger(__name__) class TrainingSampler(Sample...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/data/samplers/__init__.py
detectron2/data/samplers/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .distributed_sampler import ( InferenceSampler, RandomSubsetTrainingSampler, RepeatFactorTrainingSampler, TrainingSampler, ) from .grouped_batch_sampler import GroupedBatchSampler __all__ = [ "GroupedBatchSampler", "TrainingSampler", ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/engine/defaults.py
detectron2/engine/defaults.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. """ This file contains components with some default boilerplate logic user may need in training / testing. They will not work for everyone, but many users may find them useful. The behavior of functions/classes in this file is subject to chang...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/engine/__init__.py
detectron2/engine/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. from .launch import * from .train_loop import * __all__ = [k for k in globals().keys() if not k.startswith("_")] # prefer to let hooks and defaults live in separate namespaces (therefore not in __all__) # but still make them available here from .hooks import * from...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/engine/launch.py
detectron2/engine/launch.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging from datetime import timedelta import torch import torch.distributed as dist import torch.multiprocessing as mp from detectron2.utils import comm __all__ = ["DEFAULT_TIMEOUT", "launch"] DEFAULT_TIMEOUT = timedelta(minutes=30) def _find_free_port(): ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/engine/train_loop.py
detectron2/engine/train_loop.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import concurrent.futures import logging import numpy as np import time import weakref from typing import List, Mapping, Optional import torch from torch.nn.parallel import DataParallel, DistributedDataParallel import detectron2.utils.comm as c...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/engine/hooks.py
detectron2/engine/hooks.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import datetime import itertools import logging import math import operator import os import tempfile import time import warnings from collections import Counter import torch from fvcore.common.checkpoint import Checkpointer from fvcore.common....
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/projects/__init__.py
detectron2/projects/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. import importlib.abc import importlib.util from pathlib import Path __all__ = [] _PROJECTS = { "point_rend": "PointRend", "deeplab": "DeepLab", "panoptic_deeplab": "Panoptic-DeepLab", } _PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent / "proj...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/model_zoo/model_zoo.py
detectron2/model_zoo/model_zoo.py
# Copyright (c) Facebook, Inc. and its affiliates. import os from typing import Optional import pkg_resources import torch from detectron2.checkpoint import DetectionCheckpointer from detectron2.config import CfgNode, LazyConfig, get_cfg, instantiate from detectron2.modeling import build_model class _ModelZooUrls: ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/model_zoo/__init__.py
detectron2/model_zoo/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. """ Model Zoo API for Detectron2: a collection of functions to create common model architectures listed in `MODEL_ZOO.md <https://github.com/facebookresearch/detectron2/blob/main/MODEL_ZOO.md>`_, and optionally load their pre-trained weights. """ from .model_zoo impor...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/evaluation/lvis_evaluation.py
detectron2/evaluation/lvis_evaluation.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import json import logging import os import pickle from collections import OrderedDict import torch import detectron2.utils.comm as comm from detectron2.config import CfgNode from detectron2.data import MetadataCatalog from detectron2.stru...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/evaluation/testing.py
detectron2/evaluation/testing.py
# Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np import pprint import sys from collections.abc import Mapping def print_csv_format(results): """ Print main metrics in a format similar to Detectron, so that they are easy to copypaste into a spreadsheet. Args: ...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/evaluation/coco_evaluation.py
detectron2/evaluation/coco_evaluation.py
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import copy import io import itertools import json import logging import numpy as np import os import pickle from collections import OrderedDict import pycocotools.mask as mask_util import torch from pycocotools.coco import COCO from pycocotools.cocoe...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/evaluation/evaluator.py
detectron2/evaluation/evaluator.py
# Copyright (c) Facebook, Inc. and its affiliates. import datetime import logging import time from collections import OrderedDict, abc from contextlib import ExitStack, contextmanager from typing import List, Union import torch from torch import nn from detectron2.utils.comm import get_world_size, is_main_process from...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/evaluation/rotated_coco_evaluation.py
detectron2/evaluation/rotated_coco_evaluation.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import json import numpy as np import os import torch from pycocotools.cocoeval import COCOeval, maskUtils from detectron2.structures import BoxMode, RotatedBoxes, pairwise_iou_rotated from detectron2.utils.file_io import PathManager from .coco_evalu...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false
facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/blob/fd27788985af0f4ca800bca563acdb700bb890e2/detectron2/evaluation/sem_seg_evaluation.py
detectron2/evaluation/sem_seg_evaluation.py
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import json import logging import numpy as np import os from collections import OrderedDict from typing import Optional, Union import pycocotools.mask as mask_util import torch from PIL import Image from detectron2.data import DatasetCatalog, Metadata...
python
Apache-2.0
fd27788985af0f4ca800bca563acdb700bb890e2
2026-01-04T14:42:35.134676Z
false