id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
143,357 | import torch
from .bounding_box import BoxList
from fcos_core.layers import nms as _box_nms
from fcos_core.layers import ml_nms as _box_ml_nms
The provided code snippet includes necessary dependencies for implementing the `boxlist_nms` function. Write a Python function `def boxlist_nms(boxlist, nms_thresh, max_proposa... | Performs non-maximum suppression on a boxlist, with scores specified in a boxlist field via score_field. Arguments: boxlist(BoxList) nms_thresh (float) max_proposals (int): if > 0, then only the top max_proposals are kept after non-maximum suppression score_field (str) |
143,358 | import torch
from .bounding_box import BoxList
from fcos_core.layers import nms as _box_nms
from fcos_core.layers import ml_nms as _box_ml_nms
The provided code snippet includes necessary dependencies for implementing the `boxlist_ml_nms` function. Write a Python function `def boxlist_ml_nms(boxlist, nms_thresh, max_p... | Performs non-maximum suppression on a boxlist, with scores specified in a boxlist field via score_field. Arguments: boxlist(BoxList) nms_thresh (float) max_proposals (int): if > 0, then only the top max_proposals are kept after non-maximum suppression score_field (str) |
143,359 | import torch
from .bounding_box import BoxList
from fcos_core.layers import nms as _box_nms
from fcos_core.layers import ml_nms as _box_ml_nms
The provided code snippet includes necessary dependencies for implementing the `remove_small_boxes` function. Write a Python function `def remove_small_boxes(boxlist, min_size)... | Only keep boxes with both sides >= min_size Arguments: boxlist (Boxlist) min_size (int) |
143,360 | import glob
import os.path
import torch
try:
from torch.utils.cpp_extension import load as load_ext
from torch.utils.cpp_extension import CUDA_HOME
except ImportError:
raise ImportError("The cpp layer extensions requires PyTorch 0.4 or higher")
def _load_C_extensions():
this_dir = os.path.dirname(os.pa... | null |
143,362 | import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from fcos_core import _C
def sigmoid_focal_loss_cpu(logits, targets, gamma, alpha):
num_classes = logits.shape[1]
gamma = gamma[0]
alpha = alpha[0]
dtype = targets.dtype
dev... | null |
143,363 | from . import transforms as T
def build_transforms(cfg, is_train=True):
if is_train:
if cfg.INPUT.MIN_SIZE_RANGE_TRAIN[0] == -1:
min_size = cfg.INPUT.MIN_SIZE_TRAIN
else:
assert len(cfg.INPUT.MIN_SIZE_RANGE_TRAIN) == 2, \
"MIN_SIZE_RANGE_TRAIN must have two e... | null |
143,364 | import torch
import torchvision
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.segmentation_mask import SegmentationMask
from fcos_core.structures.keypoint import PersonKeypoints
min_keypoints_per_image = 10
def _count_visible_keypoints(anno):
return sum(sum(1 for v in ann["keypoint... | null |
143,365 | from __future__ import division
import os
from collections import defaultdict
import numpy as np
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import boxlist_iou
def eval_detection_voc(pred_boxlists, gt_boxlists, iou_thresh=0.5, use_07_metric=False):
def do_voc_evaluation(... | null |
143,366 | import logging
import tempfile
import os
import torch
from collections import OrderedDict
from tqdm import tqdm
from fcos_core.modeling.roi_heads.mask_head.inference import Masker
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import boxlist_iou
def prepare_for_coco_detectio... | null |
143,367 | import bisect
import copy
import logging
import torch.utils.data
from fcos_core.utils.comm import get_world_size
from fcos_core.utils.imports import import_file
from . import datasets as D
from . import samplers
from .collate_batch import BatchCollator, BBoxAugCollator
from .transforms import build_transforms
def build... | null |
143,368 | from collections import OrderedDict
from torch import nn
from fcos_core.modeling import registry
from fcos_core.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
from . import mobilenet
def build_resnet_backbone(cfg):
body = resnet.ResNet(cfg)
model = nn... | null |
143,369 | from collections import OrderedDict
from torch import nn
from fcos_core.modeling import registry
from fcos_core.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
from . import mobilenet
def conv_with_kaiming_uniform(use_gn=False, use_relu=False):
def make_co... | null |
143,370 | from collections import OrderedDict
from torch import nn
from fcos_core.modeling import registry
from fcos_core.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
from . import mobilenet
def conv_with_kaiming_uniform(use_gn=False, use_relu=False):
def build_resn... | null |
143,371 | from collections import OrderedDict
from torch import nn
from fcos_core.modeling import registry
from fcos_core.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
from . import mobilenet
def conv_with_kaiming_uniform(use_gn=False, use_relu=False):
def make_co... | null |
143,372 | from collections import OrderedDict
from torch import nn
from fcos_core.modeling import registry
from fcos_core.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
from . import mobilenet
def build_backbone(cfg):
assert cfg.MODEL.BACKBONE.CONV_BODY in registry... | null |
143,373 | from torch import nn
from torch.nn import BatchNorm2d
from fcos_core.layers import Conv2d
def conv_bn(inp, oup, stride):
return nn.Sequential(
Conv2d(inp, oup, 3, stride, 1, bias=False),
BatchNorm2d(oup),
nn.ReLU6(inplace=True)
) | null |
143,374 | from torch import nn
from torch.nn import BatchNorm2d
from fcos_core.layers import Conv2d
def conv_1x1_bn(inp, oup):
return nn.Sequential(
Conv2d(inp, oup, 1, 1, 0, bias=False),
BatchNorm2d(oup),
nn.ReLU6(inplace=True)
) | null |
143,375 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | Get all stages except the last one |
143,376 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | null |
143,377 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | null |
143,378 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | null |
143,379 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | null |
143,380 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | null |
143,381 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | null |
143,382 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from fcos_core.modeling import registry
from fcos_core.mode... | null |
143,383 | from __future__ import absolute_import, division, print_function, unicode_literals
MODEL_ARCH = {
"default": {
"block_op_type": [
# stage 0
["ir_k3"],
# stage 1
["ir_k3"] * 2,
# stage 2
["ir_k3"] * 3,
# stage 3
[... | null |
143,384 | from collections import namedtuple
import torch
import torch.nn.functional as F
from torch import nn
from fcos_core.layers import FrozenBatchNorm2d
from fcos_core.layers import Conv2d
from fcos_core.layers import DFConv2d
from fcos_core.modeling.make_layers import group_norm
from fcos_core.utils.registry import Registr... | null |
143,385 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import logging
import math
from collections import OrderedDict
import torch
import torch.nn as nn
from fcos_core.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
interpolate,
)
from fcos_core.layers.mis... | null |
143,386 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import logging
import math
from collections import OrderedDict
import torch
import torch.nn as nn
from fcos_core.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
interpolate,
)
from fcos_core.layers.mis... | null |
143,387 | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import logging
import math
from collections import OrderedDict
import torch
import torch.nn as nn
from fcos_core.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
interpolate,
)
from fcos_core.layers.mis... | For a list of stages |
143,388 | import torch
import torch.nn.functional as F
from torch import nn
from fcos_core.layers import ROIAlign
from .utils import cat
class Pooler(nn.Module):
"""
Pooler for Detection with or without FPN.
It currently hard-code ROIAlign in the implementation,
but that can be made more generic later on.
Als... | null |
143,389 | import torch
from torch import nn
from torch.nn import functional as F
from fcos_core.config import cfg
from fcos_core.layers import Conv2d
from fcos_core.modeling.poolers import Pooler
def group_norm(out_channels, affine=True, divisor=1):
def make_conv3x3(
in_channels,
out_channels,
dilation=1,
str... | null |
143,390 | import torch
from torch import nn
from torch.nn import functional as F
from fcos_core.config import cfg
from fcos_core.layers import Conv2d
from fcos_core.modeling.poolers import Pooler
def group_norm(out_channels, affine=True, divisor=1):
out_channels = out_channels // divisor
dim_per_gp = cfg.MODEL.GROUP_NORM... | Caffe2 implementation uses XavierFill, which in fact corresponds to kaiming_uniform_ in PyTorch |
143,391 | from ..utils import cat
import torch
def permute_and_flatten(layer, N, A, C, H, W):
layer = layer.view(N, -1, C, H, W)
layer = layer.permute(0, 3, 4, 1, 2)
layer = layer.reshape(N, -1, C)
return layer
def cat(tensors, dim=0):
"""
Efficient version of torch.cat that avoids a copy if there is onl... | null |
143,392 | import torch
from ..inference import RPNPostProcessor
from ..utils import permute_and_flatten
from fcos_core.modeling.box_coder import BoxCoder
from fcos_core.modeling.utils import cat
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import cat_boxlist
from fcos_core.structure... | null |
143,393 | import torch
from torch.nn import functional as F
from ..utils import concat_box_prediction_layers
from fcos_core.layers import smooth_l1_loss
from fcos_core.layers import SigmoidFocalLoss
from fcos_core.modeling.matcher import Matcher
from fcos_core.modeling.utils import cat
from fcos_core.structures.boxlist_ops impor... | null |
143,394 | import torch
from fcos_core.modeling.box_coder import BoxCoder
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import cat_boxlist
from fcos_core.structures.boxlist_ops import boxlist_nms
from fcos_core.structures.boxlist_ops import remove_small_boxes
from ..utils import cat
f... | null |
143,395 | import math
import numpy as np
import torch
from torch import nn
from fcos_core.structures.bounding_box import BoxList
class AnchorGenerator(nn.Module):
"""
For a set of image sizes and feature maps, computes a set
of anchors
"""
def __init__(
self,
sizes=(128, 256, 512),
asp... | null |
143,396 | import math
import numpy as np
import torch
from torch import nn
from fcos_core.structures.bounding_box import BoxList
class AnchorGenerator(nn.Module):
"""
For a set of image sizes and feature maps, computes a set
of anchors
"""
def __init__(
self,
sizes=(128, 256, 512),
asp... | null |
143,397 | import math
import numpy as np
import torch
from torch import nn
from fcos_core.structures.bounding_box import BoxList
def _generate_anchors(base_size, scales, aspect_ratios):
"""Generate anchor (reference) windows by enumerating aspect ratios X
scales wrt a reference (0, 0, base_size - 1, base_size - 1) window... | Generates a matrix of anchor boxes in (x1, y1, x2, y2) format. Anchors are centered on stride / 2, have (approximate) sqrt areas of the specified sizes, and aspect ratios as given. |
143,398 | import torch
from torch.nn import functional as F
from .utils import concat_box_prediction_layers
from ..balanced_positive_negative_sampler import BalancedPositiveNegativeSampler
from ..utils import cat
from fcos_core.layers import smooth_l1_loss
from fcos_core.modeling.matcher import Matcher
from fcos_core.structures.... | null |
143,399 | import torch
import torch.nn.functional as F
from torch import nn
from fcos_core.modeling import registry
from fcos_core.modeling.box_coder import BoxCoder
from fcos_core.modeling.rpn.retinanet.retinanet import build_retinanet
from fcos_core.modeling.rpn.fcos.fcos import build_fcos
from .loss import make_rpn_loss_evalu... | This gives the gist of it. Not super important because it doesn't change as much |
143,400 | import torch
from torch.nn import functional as F
from torch import nn
import os
from ..utils import concat_box_prediction_layers
from fcos_core.layers import IOULoss
from fcos_core.layers import SigmoidFocalLoss
from fcos_core.modeling.matcher import Matcher
from fcos_core.modeling.utils import cat
from fcos_core.stru... | null |
143,401 | import torch
from torch.nn import functional as F
from torch import nn
import os
from ..utils import concat_box_prediction_layers
from fcos_core.layers import IOULoss
from fcos_core.layers import SigmoidFocalLoss
from fcos_core.modeling.matcher import Matcher
from fcos_core.modeling.utils import cat
from fcos_core.stru... | null |
143,402 | import torch
from torch import nn
from torch.nn import functional as F
from fcos_core.modeling import registry
from fcos_core.modeling.backbone import resnet
from fcos_core.modeling.poolers import Pooler
from fcos_core.modeling.make_layers import group_norm
from fcos_core.modeling.make_layers import make_fc
def make_r... | null |
143,403 | import torch
import torch.nn.functional as F
from torch import nn
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import boxlist_nms
from fcos_core.structures.boxlist_ops import cat_boxlist
from fcos_core.modeling.box_coder import BoxCoder
class PostProcessor(nn.Module):
... | null |
143,404 | import torch
from torch.nn import functional as F
from fcos_core.layers import smooth_l1_loss
from fcos_core.modeling.box_coder import BoxCoder
from fcos_core.modeling.matcher import Matcher
from fcos_core.structures.boxlist_ops import boxlist_iou
from fcos_core.modeling.balanced_positive_negative_sampler import (
... | null |
143,405 | from fcos_core.modeling import registry
from torch import nn
def make_roi_box_predictor(cfg, in_channels):
func = registry.ROI_BOX_PREDICTOR[cfg.MODEL.ROI_BOX_HEAD.PREDICTOR]
return func(cfg, in_channels) | null |
143,406 | import numpy as np
import torch
from torch import nn
from fcos_core.layers.misc import interpolate
from fcos_core.structures.bounding_box import BoxList
def expand_boxes(boxes, scale):
w_half = (boxes[:, 2] - boxes[:, 0]) * .5
h_half = (boxes[:, 3] - boxes[:, 1]) * .5
x_c = (boxes[:, 2] + boxes[:, 0]) * .5
... | null |
143,407 | import numpy as np
import torch
from torch import nn
from fcos_core.layers.misc import interpolate
from fcos_core.structures.bounding_box import BoxList
class MaskPostProcessor(nn.Module):
"""
From the results of the CNN, post process the masks
by taking the mask corresponding to the class with max
prob... | null |
143,408 | import torch
from torch import nn
from fcos_core.structures.bounding_box import BoxList
from .roi_mask_feature_extractors import make_roi_mask_feature_extractor
from .roi_mask_predictors import make_roi_mask_predictor
from .inference import make_roi_mask_post_processor
from .loss import make_roi_mask_loss_evaluator
cl... | Given a set of BoxList containing the `labels` field, return a set of BoxList for which `labels > 0`. Arguments: boxes (list of BoxList) |
143,409 | import torch
from torch.nn import functional as F
from fcos_core.layers import smooth_l1_loss
from fcos_core.modeling.matcher import Matcher
from fcos_core.structures.boxlist_ops import boxlist_iou
from fcos_core.modeling.utils import cat
The provided code snippet includes necessary dependencies for implementing the `... | Given segmentation masks and the bounding boxes corresponding to the location of the masks in the image, this function crops and resizes the masks in the position defined by the boxes. This prepares the masks for them to be fed to the loss computation as the targets. Arguments: segmentation_masks: an instance of Segmen... |
143,410 | import torch
from torch.nn import functional as F
from fcos_core.layers import smooth_l1_loss
from fcos_core.modeling.matcher import Matcher
from fcos_core.structures.boxlist_ops import boxlist_iou
from fcos_core.modeling.utils import cat
class MaskRCNNLossComputation(object):
def __init__(self, proposal_matcher, d... | null |
143,411 | from torch import nn
from torch.nn import functional as F
from fcos_core.layers import Conv2d
from fcos_core.layers import ConvTranspose2d
from fcos_core.modeling import registry
def make_roi_mask_predictor(cfg, in_channels):
func = registry.ROI_MASK_PREDICTOR[cfg.MODEL.ROI_MASK_HEAD.PREDICTOR]
return func(cfg... | null |
143,412 | from torch import nn
from torch.nn import functional as F
from ..box_head.roi_box_feature_extractors import ResNet50Conv5ROIFeatureExtractor
from fcos_core.modeling import registry
from fcos_core.modeling.poolers import Pooler
from fcos_core.modeling.make_layers import make_conv3x3
registry.ROI_MASK_FEATURE_EXTRACTORS.... | null |
143,413 | import torch
from torch import nn
import numpy as np
import cv2
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.keypoint import PersonKeypoints
The provided code snippet includes necessary dependencies for implementing the `heatmaps_to_keypoints` function. Write a Python function `def h... | Extract predicted keypoint locations from heatmaps. Output has shape (#rois, 4, #keypoints) with the 4 rows corresponding to (x, y, logit, prob) for each keypoint. |
143,414 | import torch
from torch import nn
class KeypointPostProcessor(nn.Module):
def __init__(self, keypointer=None):
def forward(self, x, boxes):
import numpy as np
import cv2
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.keypoint import PersonKeypoints
class Keypointer(object):
... | null |
143,415 | from torch import nn
from torch.nn import functional as F
from fcos_core.modeling import registry
from fcos_core.modeling.poolers import Pooler
from fcos_core.layers import Conv2d
def make_roi_keypoint_feature_extractor(cfg, in_channels):
func = registry.ROI_KEYPOINT_FEATURE_EXTRACTORS[
cfg.MODEL.ROI_KEYPO... | null |
143,416 | from torch import nn
from fcos_core import layers
from fcos_core.modeling import registry
def make_roi_keypoint_predictor(cfg, in_channels):
func = registry.ROI_KEYPOINT_PREDICTOR[cfg.MODEL.ROI_KEYPOINT_HEAD.PREDICTOR]
return func(cfg, in_channels) | null |
143,417 | import torch
from torch.nn import functional as F
from fcos_core.modeling.matcher import Matcher
from fcos_core.modeling.balanced_positive_negative_sampler import (
BalancedPositiveNegativeSampler,
)
from fcos_core.structures.boxlist_ops import boxlist_iou
from fcos_core.modeling.utils import cat
from fcos_core.lay... | null |
143,418 | import torch
from torch.nn import functional as F
from fcos_core.modeling.matcher import Matcher
from fcos_core.modeling.balanced_positive_negative_sampler import (
BalancedPositiveNegativeSampler,
)
from fcos_core.structures.boxlist_ops import boxlist_iou
from fcos_core.modeling.utils import cat
from fcos_core.lay... | null |
143,419 | import torch
from torch.nn import functional as F
from fcos_core.modeling.matcher import Matcher
from fcos_core.modeling.balanced_positive_negative_sampler import (
BalancedPositiveNegativeSampler,
)
from fcos_core.structures.boxlist_ops import boxlist_iou
from fcos_core.modeling.utils import cat
from fcos_core.lay... | Validate which keypoints are contained inside a given box. points: NxKx2 boxes: Nx4 output: NxK |
143,420 | import torch
from torch.nn import functional as F
from fcos_core.modeling.matcher import Matcher
from fcos_core.modeling.balanced_positive_negative_sampler import (
BalancedPositiveNegativeSampler,
)
from fcos_core.structures.boxlist_ops import boxlist_iou
from fcos_core.modeling.utils import cat
from fcos_core.lay... | null |
143,421 | import torch
from .box_head.box_head import build_roi_box_head
from .mask_head.mask_head import build_roi_mask_head
from .keypoint_head.keypoint_head import build_roi_keypoint_head
class CombinedROIHeads(torch.nn.ModuleDict):
"""
Combines a set of individual heads (for box prediction or masks) into a single
... | null |
143,422 | from .generalized_rcnn import GeneralizedRCNN
_DETECTION_META_ARCHITECTURES = {"GeneralizedRCNN": GeneralizedRCNN}
def build_detection_model(cfg):
meta_arch = _DETECTION_META_ARCHITECTURES[cfg.MODEL.META_ARCHITECTURE]
return meta_arch(cfg) | null |
143,423 | import torch
import logging
from .lr_scheduler import WarmupMultiStepLR
def make_optimizer(cfg, model):
logger = logging.getLogger("fcos_core.trainer")
params = []
for key, value in model.named_parameters():
if not value.requires_grad:
continue
lr = cfg.SOLVER.BASE_LR
we... | null |
143,424 | import torch
import logging
from .lr_scheduler import WarmupMultiStepLR
class WarmupMultiStepLR(torch.optim.lr_scheduler._LRScheduler):
def __init__(
self,
optimizer,
milestones,
gamma=0.1,
warmup_factor=1.0 / 3,
warmup_iters=500,
warmup_method="linear",
... | null |
143,428 | import os
import sys
from fcos_core.utils.comm import is_main_process
from fcos_core.utils.comm import synchronize
def is_main_process():
return get_rank() == 0
def synchronize():
"""
Helper function to synchronize (barrier) among all processes when
using distributed training
"""
if not dist.... | r"""Loads the Torch serialized object at the given URL. If the object is already present in `model_dir`, it's deserialized and returned. The filename part of the URL should follow the naming convention ``filename-<sha256>.ext`` where ``<sha256>`` is the first eight or more digits of the SHA256 hash of the contents of t... |
143,429 | from collections import OrderedDict
import logging
import torch
from fcos_core.utils.imports import import_file
def align_and_update_state_dicts(model_state_dict, loaded_state_dict):
def strip_prefix_if_present(state_dict, prefix):
def load_state_dict(model, loaded_state_dict):
model_state_dict = model.state_dict(... | null |
143,432 | import logging
import os
import sys
def setup_logger(name, save_dir, distributed_rank, filename="log.txt"):
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
# don't log results for the non-master process
if distributed_rank > 0:
return logger
ch = logging.StreamHandler(stream... | null |
143,433 | import logging
import pickle
from collections import OrderedDict
import torch
from fcos_core.utils.model_serialization import load_state_dict
from fcos_core.utils.registry import Registry
def _rename_weights_for_resnet(weights, stage_names):
original_keys = sorted(weights.keys())
layer_keys = sorted(weights.key... | null |
143,434 | import logging
import pickle
from collections import OrderedDict
import torch
from fcos_core.utils.model_serialization import load_state_dict
from fcos_core.utils.registry import Registry
C2_FORMAT_LOADER = Registry()
def load_c2_format(cfg, f):
return C2_FORMAT_LOADER[cfg.MODEL.BACKBONE.CONV_BODY](cfg, f) | null |
143,435 | from __future__ import print_function, absolute_import, division
import os, sys
sys.path.append( os.path.normpath( os.path.join( os.path.dirname( __file__ ) , '..' , 'helpers' ) ) )
from csHelpers import *
from cityscapesscripts.evaluation.instance import *
from cityscapesscripts.helpers.csHelpers import *
import cv2
f... | null |
143,436 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import h5py
import json
import os
import scipy.misc
import sys
import cityscapesscripts.evaluation.instances2dict_with_polygons as cs
def parse_args():
... | null |
143,437 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import h5py
import json
import os
import scipy.misc
import sys
import cityscapesscripts.evaluation.instances2dict_with_polygons as cs
The provided code sn... | Convert to png and save json with path. This currently only contains the segmentation labels for objects+stuff in cocostuff - if we need to combine with other labels from original COCO that will be a TODO. |
143,438 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import h5py
import json
import os
import scipy.misc
import sys
import cityscapesscripts.evaluation.instances2dict_with_polygons as cs
def getLabelID(self,... | null |
143,439 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import h5py
import json
import os
import scipy.misc
import sys
import cityscapesscripts.evaluation.instances2dict_with_polygons as cs
def poly_to_box(poly)... | Convert from cityscapes format to COCO instance seg format - polygons |
143,440 | from fcos_core.utils.env import setup_environment
import argparse
import os
import torch
from fcos_core.config import cfg
from fcos_core.data import make_data_loader
from fcos_core.solver import make_lr_scheduler
from fcos_core.solver import make_optimizer
from fcos_core.engine.inference import inference
from fcos_cor... | null |
143,441 | from fcos_core.utils.env import setup_environment
import argparse
import os
import torch
from fcos_core.config import cfg
from fcos_core.data import make_data_loader
from fcos_core.solver import make_lr_scheduler
from fcos_core.solver import make_optimizer
from fcos_core.engine.inference import inference
from fcos_cor... | null |
143,442 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | null |
143,443 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | Step the EMA model towards the current model. |
143,444 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | End DDP training. |
143,445 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | Create a logger that writes to a log file and stdout. |
143,446 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | Center cropping implementation from ADM. https://github.com/openai/guided-diffusion/blob/8fb3ad9197f16bbc40620447b2742e13458d2831/guided_diffusion/image_datasets.py#L126 |
143,447 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | null |
143,448 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | null |
143,449 | import argparse
from collections import OrderedDict
import contextlib
from copy import deepcopy
from datetime import datetime
import functools
import json
import logging
import multiprocessing as mp
import os
import socket
import subprocess
from time import time, sleep
from PIL import Image
from diffusers.models import... | null |
143,450 | import functools
import math
from typing import Optional, Tuple, List
from apex.normalization import FusedRMSNorm as RMSNorm
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding,
)
from flash_attn import ... | null |
143,451 | import functools
import math
from typing import Optional, Tuple, List
from apex.normalization import FusedRMSNorm as RMSNorm
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding,
)
from flash_attn import ... | null |
143,452 | import functools
import math
from typing import Optional, Tuple, List
from apex.normalization import FusedRMSNorm as RMSNorm
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding,
)
from flash_attn import ... | null |
143,453 | import functools
import math
from typing import Optional, Tuple, List
from apex.normalization import FusedRMSNorm as RMSNorm
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding,
)
from flash_attn import ... | null |
143,454 | import functools
import math
from typing import Optional, Tuple, List
from apex.normalization import FusedRMSNorm as RMSNorm
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding,
)
from flash_attn import ... | null |
143,455 | import torch
import torch.distributed as dist
from torchvision.utils import save_image
from diffusion import create_diffusion
from diffusers.models import AutoencoderKL
from models import DiT_models
import argparse
import multiprocessing as mp
import socket
import os
import fairscale.nn.model_parallel.initialize as fs_... | null |
143,459 | import numpy as np
import torch as th
from .gaussian_diffusion import GaussianDiffusion
The provided code snippet includes necessary dependencies for implementing the `space_timesteps` function. Write a Python function `def space_timesteps(num_timesteps, section_counts)` to solve the following problem:
Create a list o... | Create a list of timesteps to use from an original diffusion process, given the number of timesteps we want to take from equally-sized portions of the original process. For example, if there's 300 timesteps and the section counts are [10,15,20] then the first 100 timesteps are strided to be 10 timesteps, the second 100... |
143,464 | from typing import Dict
import torch
import torch.nn as nn
import torch.distributed as dist
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding
)
def get_model_parallel_dim_dict(model: nn.Module) -> Dic... | null |
143,465 | from typing import Dict
import torch
import torch.nn as nn
import torch.distributed as dist
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding
)
def calculate_l2_grad_norm(
model: nn.Module, model_... | null |
143,466 | from typing import Dict
import torch
import torch.nn as nn
import torch.distributed as dist
import fairscale.nn.model_parallel.initialize as fs_init
from fairscale.nn.model_parallel.layers import (
ColumnParallelLinear, RowParallelLinear, ParallelEmbedding
)
def scale_grad(model: nn.Module, factor: float) -> None:... | null |
143,467 | import os
from sphinx.application import Sphinx
from urllib.request import urlopen
from pathlib import Path
from docutils import nodes
import re
def autolink():
def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
pattern = re.compile("\[(.*?)\]\((.*?)\)")
match_result = pattern.m... | null |
143,468 | import math
import sys
from typing import Iterable
import contextlib
import torch
import accessory.util.misc as misc
import accessory.util.lr_sched as lr_sched
from fairscale.nn.model_parallel import initialize as fs_init
def val_one_epoch(model: torch.nn.Module,
data_loader: Iterable, epoch: int,
... | null |
143,469 | import sys
import os
import argparse
import datetime
import warnings
import numpy as np
import time
from pathlib import Path
import functools
from functools import partial
import torch
from torch.utils.data import Dataset
import torch.backends.cudnn as cudnn
from torch.utils.tensorboard import SummaryWriter
from torch.... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.