repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
SauronUNet | SauronUNet-main/lib/models/UNet.py | import torch
from lib.models.BaseModel import BaseModel
from torch.nn.functional import interpolate
from torch.nn import Conv3d, Conv2d, MaxPool2d, MaxPool3d, InstanceNorm3d
from torch.nn import InstanceNorm2d, ReLU, AvgPool2d, AvgPool3d
class UNet(BaseModel):
# Parameters of the model
params = ["modalities",... | 5,287 | 33.789474 | 73 | py |
SauronUNet | SauronUNet-main/lib/models/BaseModel.py | from tensorboardX import SummaryWriter
import torch, os, time, json, inspect, re, pickle
from datetime import datetime
import numpy as np
import torchio as tio
#from IPython import embed
from lib.metric import Metric
from lib.utils import he_normal
from typing import List, Callable, Type, Tuple
from lib.data.BaseDatase... | 17,568 | 37.613187 | 121 | py |
SauronUNet | SauronUNet-main/lib/data/ATLAS2Dataset.py | import torch, os, random, time, re
import nibabel as nib
import numpy as np
from lib.data.BaseDataset import BaseDataset
from lib.loss import DS_CrossEntropyDiceLoss_Distance
from typing import List
import torchio as tio
from lib.models.Sauron import Sauron
from torch.nn import InstanceNorm3d
from torch.optim.lr_schedu... | 9,315 | 36.564516 | 160 | py |
SauronUNet | SauronUNet-main/lib/data/ACDC17Dataset.py | import torch, os, random, time, re
import nibabel as nib
import numpy as np
from lib.data.BaseDataset import BaseDataset
from lib.loss import DS_CrossEntropyDiceLoss, DS_CrossEntropyDiceLoss_Distance
from typing import List
import torchio as tio
from lib.models.UNet import UNet
from lib.models.nnUNet import nnUNet
from... | 16,827 | 40.550617 | 160 | py |
SauronUNet | SauronUNet-main/lib/data/KiTS19Dataset.py | import torch, os, random, time, re
import nibabel as nib
import numpy as np
from lib.data.BaseDataset import BaseDataset
from lib.loss import DS_CrossEntropyDiceLoss_Distance
from typing import List
import torchio as tio
from lib.models.Sauron import Sauron
from torch.nn import InstanceNorm3d
from torch.optim.lr_schedu... | 19,928 | 41.402128 | 160 | py |
SauronUNet | SauronUNet-main/lib/data/RatsDataset.py | import torch, os, random, time
import nibabel as nib
import numpy as np
from lib.data.BaseDataset import BaseDataset
import torchio as tio
import lib.loss as loss
from typing import List
from torch.optim.lr_scheduler import LambdaLR
from torch.nn import InstanceNorm2d
from lib.models.UNet import UNet
from lib.models.nn... | 10,141 | 36.562963 | 115 | py |
SauronUNet | SauronUNet-main/lib/data/BaseDataset.py | import torchio as tio
import numpy as np
class BaseDataset:
"""
Datasets must inherit from this class, which through get() returns the
appropriate dataset split.
"""
def __init__(self):
pass
def get(self, split: str) -> tio.SubjectsDataset:
"""
Return the appropriate d... | 2,171 | 30.941176 | 81 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Train_FM2_segmentation.py | import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.switch_backend('agg')
from scipy.ndimage.morphology import distance_transform_edt
import scipy.ndimage
import os
from skimage.io import imsave
import numpy as np
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.k... | 10,194 | 51.551546 | 156 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Train_FM3_segmentation.py | import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.switch_backend('agg')
from scipy.ndimage.morphology import distance_transform_edt
import scipy.ndimage
import os
from skimage.io import imsave
import numpy as np
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.k... | 10,212 | 52.192708 | 243 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Test.py | import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.switch_backend('agg')
from scipy.ndimage.morphology import distance_transform_edt
import scipy.ndimage
import os
from skimage.io import imsave
import numpy as np
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.k... | 9,474 | 54.409357 | 153 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Train_PenileBulb_segmentation.py | import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.switch_backend('agg')
from scipy.ndimage.morphology import distance_transform_edt
import scipy.ndimage
import os
from skimage.io import imsave
import numpy as np
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.k... | 10,155 | 52.452632 | 156 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Train_Bladder_segmentation.py | import numpy as np
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.keras.optimizers import Adam
from src.Models.SegmentationNetworks import unet_3D_ResNeXt_DB
from src.Utils.LossFunctions import weighted_dice_loss3D, dice_coef
from src.Utils.DataPreprocessing_Segmentation import preproce... | 4,802 | 52.366667 | 220 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Train_localization.py | import os
import numpy as np
import tensorflow as tf
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.keras.models import load_model
from tensorflow.keras.optimizers import Adam
tf.compat.v1.disable_eager_execution()
from src.Models.LocalizationNetwork import unet_2D
from src.Utils.LossFu... | 4,161 | 55.243243 | 140 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Train_CTV_segmentation.py | import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.switch_backend('agg')
from scipy.ndimage.morphology import distance_transform_edt
import scipy.ndimage
import os
from skimage.io import imsave
import numpy as np
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.k... | 11,653 | 55.84878 | 156 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/Train_Rectum_segmentation.py | import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
plt.switch_backend('agg')
from scipy.ndimage.morphology import distance_transform_edt
import scipy.ndimage
import os
from skimage.io import imsave
import numpy as np
from tensorflow.keras.callbacks import History, ModelCheckpoint
from tensorflow.k... | 5,055 | 48.568627 | 182 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/src/Models/DropBlock.py | import tensorflow.keras as keras
import tensorflow as tf
from tensorflow.keras import backend as K
from tensorflow.keras.layers import Layer
from tensorflow.keras.utils import get_custom_objects
def _bernoulli(shape, mean):
return tf.nn.relu(tf.sign(mean - tf.random.uniform(shape, minval=0, maxval=1, dtype=tf.floa... | 6,311 | 42.232877 | 121 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/src/Models/LocalizationNetwork.py | import os
import numpy as np
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, concatenate, Conv2D, MaxPooling2D, Conv2DTranspose, BatchNormalization, Activation, Dropout
def unet_2D(img_rows=None, img_cols=None,... | 4,129 | 58 | 134 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/src/Models/DeepLabv3plus.py | import os
import numpy as np
# "" Deeplabv3+ model for Keras.
# This model is based on TF repo:
# https://github.com/tensorflow/models/tree/master/research/deeplab
# On Pascal VOC, original model gets to 84.56% mIOU
# MobileNetv2 backbone is based on this repo:
# https://github.com/JonathanCMitchell/mobilenet_v2_keras
... | 19,639 | 44.88785 | 106 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/src/Models/SegmentationNetworks.py | """
#####################################################################################
Code written : 02/26/2020
Owner : Anjali Balagopal, Graduate Student, UT Southwestern medical Center
#####################################################################################
"""
import numpy as np
from tensorflow.ker... | 22,202 | 59.997253 | 208 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/src/Models/groupnorm.py | from tensorflow.keras.layers import Layer, InputSpec
from tensorflow.keras import initializers
from tensorflow.keras import regularizers
from tensorflow.keras import constraints
from tensorflow.keras import backend as K
from tensorflow.keras.utils import get_custom_objects
class GroupNormalization(Layer):
"""Gro... | 8,004 | 39.429293 | 92 | py |
Post-op-prostate-DL-model | Post-op-prostate-DL-model-master/src/Utils/LossFunctions.py | """
#####################################################################################
Code written : 02/26/2020
Owner : Anjali Balagopal, Graduate Student, UT Southwestern medical Center
#####################################################################################
"""
import numpy as np
import tensorflow
fr... | 5,926 | 34.921212 | 115 | py |
mmdrl | mmdrl-master/particle_net.py | import tensorflow as tf
import numpy as np
import cv2
import collections
import gin.tf
import math
ParticleDQNType = collections.namedtuple('ParticleDQN', ['particles', 'q_values'])
@gin.configurable
class ParticleDQNet(tf.keras.Model):
def __init__(self, num_actions, num_atoms, name=None):
super(Pa... | 2,061 | 42.87234 | 82 | py |
mmdrl | mmdrl-master/dopamine/agents/rainbow/rainbow_agent.py | # coding=utf-8
# Copyright 2018 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 21,197 | 43.1625 | 80 | py |
mmdrl | mmdrl-master/dopamine/agents/dqn/dqn_agent.py | # coding=utf-8
# Copyright 2018 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 21,626 | 38.902214 | 96 | py |
mmdrl | mmdrl-master/dopamine/agents/implicit_quantile/implicit_quantile_agent.py | # coding=utf-8
# Copyright 2018 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 14,124 | 45.311475 | 86 | py |
mmdrl | mmdrl-master/dopamine/utils/gym_lib.py | # coding=utf-8
# Copyright 2018 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 24,492 | 36.33689 | 144 | py |
mmdrl | mmdrl-master/dopamine/utils/atari_lib.py | # coding=utf-8
# Copyright 2018 The Dopamine Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 25,608 | 38.157492 | 107 | py |
PMTD | PMTD-master/setup.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
#!/usr/bin/env python
import glob
import os
import torch
from setuptools import find_packages
from setuptools import setup
from torch.utils.cpp_extension import CUDA_HOME
from torch.utils.cpp_extension import CppExtension
from torch.utils.cpp_ext... | 2,084 | 28.785714 | 100 | py |
PMTD | PMTD-master/tools/test_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:skip
import argparse
import os
import torch... | 4,779 | 35.212121 | 127 | py |
PMTD | PMTD-master/tools/train_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
r"""
Basic training script for PyTorch
"""
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:s... | 5,987 | 31.02139 | 109 | py |
PMTD | PMTD-master/maskrcnn_benchmark/solver/lr_scheduler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from bisect import bisect_right
import torch
# FIXME ideally this would be achieved with a CombinedLRScheduler,
# separating MultiStepLR with WarmupLR
# but the current LRScheduler design doesn't allow it
class WarmupMultiStepLR(torch.optim.lr_s... | 1,817 | 33.301887 | 80 | py |
PMTD | PMTD-master/maskrcnn_benchmark/solver/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .lr_scheduler import WarmupMultiStepLR
def make_optimizer(cfg, model):
params = []
for key, value in model.named_parameters():
if not value.requires_grad:
continue
lr = cfg.SOLVER.BASE_LR
... | 976 | 29.53125 | 79 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/batch_norm.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
class FrozenBatchNorm2d(nn.Module):
"""
BatchNorm2d where the batch statistics and the affine parameters
are fixed
"""
def __init__(self, n):
super(FrozenBatchNorm2d, self).__init__()... | 1,094 | 33.21875 | 71 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/roi_pool.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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 maskrcnn_benchmark import _C
from apex import amp
class _ROIPool(Function... | 1,900 | 27.80303 | 74 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/roi_align.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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 maskrcnn_benchmark import _C
from apex import amp
class _ROIAlign(Functio... | 2,154 | 29.785714 | 85 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/smooth_l1_loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
# TODO maybe push this to nn?
def smooth_l1_loss(input, target, beta=1. / 9, size_average=True):
"""
very similar to the smooth_l1_loss from pytorch, but with
the extra beta parameter
"""
n = torch.abs(input - tar... | 481 | 27.352941 | 71 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/sigmoid_focal_loss.py | import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from maskrcnn_benchmark import _C
# TODO: Use JIT to replace CUDA implementation in the future.
class _SigmoidFocalLoss(Function):
@staticmethod
def forward(ctx, logits, targets, gamma... | 2,342 | 29.428571 | 118 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/_utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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 o... | 1,165 | 28.15 | 80 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/misc.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
helper class that supports empty tensors on some nn functions.
Ideally, add support directly in PyTorch to empty tensors in
those functions.
This can be removed once https://github.com/pytorch/pytorch/issues/12013
is implemented
"""
import m... | 6,682 | 31.759804 | 88 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .batch_norm import FrozenBatchNorm2d
from .misc import Conv2d
from .misc import DFConv2d
from .misc import ConvTranspose2d
from .misc import BatchNorm2d
from .misc import interpolate
from .nms import nms
from .roi_align import RO... | 1,327 | 26.666667 | 105 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/dcn/deform_conv_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class DeformConvFunction(Function):
@staticmethod
def forward(
ctx,
input,
offset,
weight,
... | 8,387 | 30.893536 | 83 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/dcn/deform_pool_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from maskrcnn_benchmark import _C
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(
ctx,
data,
rois,
offset,
spatial_scale,
out_size,
... | 2,616 | 26.260417 | 99 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/dcn/deform_pool_module.py | from torch import nn
from .deform_pool_func import deform_roi_pooling
class DeformRoIPooling(nn.Module):
def __init__(self,
spatial_scale,
out_size,
out_channels,
no_trans,
group_size=1,
part_size=None,
... | 6,307 | 40.774834 | 79 | py |
PMTD | PMTD-master/maskrcnn_benchmark/layers/dcn/deform_conv_module.py | import math
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair
from .deform_conv_func import deform_conv, modulated_deform_conv
class DeformConv(nn.Module):
def __init__(
self,
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
... | 5,802 | 31.601124 | 78 | py |
PMTD | PMTD-master/maskrcnn_benchmark/engine/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import torch
from tqdm import tqdm
from demo.inference import save_results
from maskrcnn_benchmark.data.datasets.evaluation import evaluate
from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker
from... | 4,292 | 32.539063 | 96 | py |
PMTD | PMTD-master/maskrcnn_benchmark/engine/trainer.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import datetime
import logging
import time
import torch
import torch.distributed as dist
from maskrcnn_benchmark.utils.comm import get_world_size
from maskrcnn_benchmark.utils.metric_logger import MetricLogger
from apex import amp
def reduce_lo... | 4,021 | 32.516667 | 79 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/c2_model_loading.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import pickle
from collections import OrderedDict
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.registry import Registry
def _rename_basic_resnet_weights(layer... | 8,333 | 39.26087 | 129 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/metric_logger.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import defaultdict
from collections import deque
import torch
class SmoothedValue(object):
"""Track a series of values and provide access to smoothed values over a
window or the global series average.
"""
def __... | 1,862 | 26.80597 | 82 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.c2_model_loading import load_c2_format
from maskrcnn_benchmark.utils.imports import import_file
from mask... | 4,804 | 33.321429 | 87 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/comm.py | """
This file contains primitives for multi-gpu communication.
This is useful when doing distributed training.
"""
import pickle
import time
import torch
import torch.distributed as dist
def get_world_size():
if not dist.is_available():
return 1
if not dist.is_initialized():
return 1
ret... | 3,370 | 27.567797 | 84 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/model_zoo.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys
try:
from torch.hub import _download_url_to_file
from torch.hub import urlparse
from torch.hub import HASH_REGEX
except ImportError:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.... | 3,045 | 48.129032 | 135 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/collect_env.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import PIL
from torch.utils.collect_env import get_pretty_env_info
def get_pil_version():
return "\n Pillow ({})".format(PIL.__version__)
def collect_env_info():
env_str = get_pretty_env_info()
env_str += get_pil_version()
... | 338 | 21.6 | 71 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/model_serialization.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import logging
import torch
from maskrcnn_benchmark.utils.imports import import_file
def align_and_update_state_dicts(model_state_dict, loaded_state_dict):
"""
Strategy: suppose that the models that w... | 3,464 | 41.777778 | 91 | py |
PMTD | PMTD-master/maskrcnn_benchmark/utils/imports.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
if torch._six.PY3:
import importlib
import importlib.util
import sys
# from https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path?utm_medium=organic&utm_source=google_rich_qa&utm_campai... | 843 | 34.166667 | 168 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
import copy
import logging
import torch.utils.data
from maskrcnn_benchmark.utils.comm import get_world_size
from maskrcnn_benchmark.utils.imports import import_file
from . import datasets as D
from . import samplers
from .collate_b... | 6,659 | 36.840909 | 143 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/datasets/voc.py | import os
import torch
import torch.utils.data
from PIL import Image
import sys
if sys.version_info[0] == 2:
import xml.etree.cElementTree as ET
else:
import xml.etree.ElementTree as ET
from maskrcnn_benchmark.structures.bounding_box import BoxList
class PascalVOCDataset(torch.utils.data.Dataset):
CL... | 4,121 | 29.533333 | 118 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/datasets/concat_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
class ConcatDataset(_ConcatDataset):
"""
Same as torch.utils.data.dataset.ConcatDataset, but exposes an extra
method for querying the sizes of the ima... | 766 | 30.958333 | 72 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/datasets/coco.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import cv2
import os
import torch
import torchvision
from PIL import Image
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask
from maskrcnn_benchmark.structu... | 4,177 | 33.816667 | 105 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/datasets/evaluation/coco/coco_eval.py | import logging
import os
import tempfile
from collections import OrderedDict
import torch
from tqdm import tqdm
from demo.inference import PlaneClustering
from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark... | 14,092 | 34.2325 | 120 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/samplers/grouped_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import torch
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import Sampler
class GroupedBatchSampler(BatchSampler):
"""
Wraps another sampler to yield a mini-batch of indices.
It enfo... | 4,845 | 40.775862 | 88 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/samplers/iteration_based_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch.utils.data.sampler import BatchSampler
class IterationBasedBatchSampler(BatchSampler):
"""
Wraps a BatchSampler, resampling from it until
a specified number of iterations have been sampled
"""
def __init__(self, ba... | 1,164 | 35.40625 | 71 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/samplers/distributed.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Code is copy-pasted exactly as in torch.utils.data.distributed.
# FIXME remove this once c10d fixes the bug it has
import math
import torch
import torch.distributed as dist
from torch.utils.data.sampler import Sampler
class DistributedSampler(S... | 2,569 | 37.358209 | 86 | py |
PMTD | PMTD-master/maskrcnn_benchmark/data/transforms/transforms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import random
import torch
import torchvision
from torchvision.transforms import functional as F
class Compose(object):
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, image, target):
for ... | 3,085 | 27.311927 | 83 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/matcher.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class Matcher(object):
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have exactly zero or one matches; each
ground-truth element may be assigned t... | 5,129 | 44.39823 | 88 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/make_layers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.modeling.poolers import P... | 3,576 | 28.081301 | 78 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
def cat(tensors, dim=0):
"""
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
"""
assert isinstance(tensors, (list, tuple))
if ... | 400 | 22.588235 | 97 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/poolers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.layers import ROIAlign
from .utils import cat
class LevelMapper(object):
"""Determine which FPN level each RoI in a set of RoIs should map to based
... | 4,561 | 33.044776 | 90 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class BalancedPositiveNegativeSampler(object):
"""
This class samples batches, ensuring that they contain a fixed proportion of positives
"""
def __init__(self, batch_size_per_image, positive_fraction):
"""
... | 2,718 | 38.405797 | 90 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/box_coder.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import torch
class BoxCoder(object):
"""
This class encodes and decodes a set of bounding boxes into
the representation used for training the regressors.
"""
def __init__(self, weights, bbox_xform_clip=math.log(1... | 3,367 | 34.083333 | 86 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/backbone/resnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Variant of the resnet module that takes cfg as an argument.
Example usage. Strings may be specified in the config file.
model = ResNet(
"StemWithFixedBatchNorm",
"BottleneckWithFixedBatchNorm",
"ResNet50StagesTo4",
... | 15,337 | 30.624742 | 85 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/backbone/fbnet_builder.py | """
FBNet model builder
"""
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 maskrcnn_benchmark.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
... | 24,964 | 29.078313 | 88 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/backbone/fbnet.py | 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 maskrcnn_benchmark.modeling import registry
from mas... | 7,845 | 30.011858 | 83 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/backbone/backbone.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
from torch import nn
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.make_layers import conv_with_kaiming_uniform
from . import fpn as fpn_module
from . import resnet
@regist... | 2,759 | 33.5 | 81 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/backbone/fpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
class FPN(nn.Module):
"""
Module that adds FPN on top of a list of feature maps.
The feature maps are currently supposed to be in increasing depth
order, and must b... | 3,939 | 38.4 | 86 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Implements the Generalized R-CNN framework
"""
import torch
from torch import nn
from maskrcnn_benchmark.structures.image_list import to_image_list
from ..backbone import build_backbone
from ..rpn.rpn import build_rpn
from ..roi_heads.roi_he... | 2,231 | 32.818182 | 87 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist
from maskrcnn_benchmark.structures.boxlist_ops... | 7,759 | 36.487923 | 87 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/anchor_generator.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import numpy as np
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
class BufferList(nn.Module):
"""
Similar to nn.ParameterList, but for buffers
"""
def __init__(self... | 9,948 | 33.306897 | 88 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
This file contains specific functions for computing losses on the RPN
file
"""
import torch
from torch.nn import functional as F
from .utils import concat_box_prediction_layers
from ..balanced_positive_negative_sampler import BalancedPositiv... | 5,768 | 35.512658 | 87 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Utility functions minipulating the prediction layers
"""
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.re... | 1,679 | 35.521739 | 80 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/rpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.rpn.retinanet.retinanet import build_ret... | 9,391 | 35.6875 | 105 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/retinanet/inference.py | import torch
from ..inference import RPNPostProcessor
from ..utils import permute_and_flatten
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.utils import cat
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops impor... | 6,923 | 34.507692 | 79 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/retinanet/loss.py | """
This file contains specific functions for computing losses on the RetinaNet
file
"""
import torch
from torch.nn import functional as F
from ..utils import concat_box_prediction_layers
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.layers import SigmoidFocalLoss
from maskrcnn_benchma... | 3,484 | 31.268519 | 83 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/rpn/retinanet/retinanet.py | import math
import torch
import torch.nn.functional as F
from torch import nn
from .inference import make_retinanet_postprocessor
from .loss import make_retinanet_loss_evaluator
from ..anchor_generator import make_anchor_generator_retinanet
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
class RetinaNet... | 5,301 | 33.653595 | 88 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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):
"""
Combine... | 3,269 | 41.467532 | 96 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import torch
from torch import nn
from maskrcnn_benchmark.layers.misc import interpolate
from maskrcnn_benchmark.structures.bounding_box import BoxList
# TODO check if want to return a single BoxList or a composite
# object
cl... | 7,040 | 32.850962 | 113 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from ..box_head.roi_box_feature_extractors import ResNet50Conv5ROIFeatureExtractor
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.poolers import Pooler
fr... | 2,502 | 33.287671 | 82 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmar... | 5,421 | 36.652778 | 80 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.layers import ConvTranspose2d
from maskrcnn_benchmark.modeling import registry
@registry.ROI_MASK_PREDICTOR.register("... | 3,430 | 38.895349 | 83 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/mask_head/mask_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from maskrcnn_benchmark.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 imp... | 3,126 | 36.22619 | 86 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/box_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms
from maskrcnn_benchmark.structures.boxlist_ops impor... | 6,445 | 37.369048 | 88 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.backbone import resnet
from maskrcnn_benchmark.modeling.poolers import Pooler
from maskrcnn_be... | 5,404 | 34.559211 | 81 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/box_head/box_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from .roi_box_feature_extractors import make_roi_box_feature_extractor
from .roi_box_predictors import make_roi_box_predictor
from .inference import make_roi_box_post_processor
from .loss import make_roi_box_loss_... | 2,765 | 37.416667 | 96 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.struc... | 7,066 | 35.427835 | 90 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from maskrcnn_benchmark.modeling import registry
from torch import nn
@registry.ROI_BOX_PREDICTOR.register("FastRCNNPredictor")
class FastRCNNPredictor(nn.Module):
def __init__(self, config, in_channels):
super(FastRCNNPredictor, self... | 2,295 | 35.444444 | 87 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/inference.py | import torch
from torch import nn
class KeypointPostProcessor(nn.Module):
def __init__(self, keypointer=None):
super(KeypointPostProcessor, self).__init__()
self.keypointer = keypointer
def forward(self, x, boxes):
mask_prob = x
scores = None
if self.keypointer:
... | 4,468 | 34.468254 | 102 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/roi_keypoint_feature_extractors.py | from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.poolers import Pooler
from maskrcnn_benchmark.layers import Conv2d
@registry.ROI_KEYPOINT_FEATURE_EXTRACTORS.register("KeypointRCNNFeatureExtractor")
class KeypointRCNNFeatureE... | 1,892 | 36.117647 | 87 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/loss.py | import torch
from torch.nn import functional as F
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import (
BalancedPositiveNegativeSampler,
)
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmark.modeli... | 7,104 | 37.61413 | 90 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/keypoint_head.py | import torch
from .roi_keypoint_feature_extractors import make_roi_keypoint_feature_extractor
from .roi_keypoint_predictors import make_roi_keypoint_predictor
from .inference import make_roi_keypoint_post_processor
from .loss import make_roi_keypoint_loss_evaluator
class ROIKeypointHead(torch.nn.Module):
def __i... | 2,057 | 38.576923 | 86 | py |
PMTD | PMTD-master/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/roi_keypoint_predictors.py | from torch import nn
from maskrcnn_benchmark import layers
from maskrcnn_benchmark.modeling import registry
@registry.ROI_KEYPOINT_PREDICTOR.register("KeypointRCNNPredictor")
class KeypointRCNNPredictor(nn.Module):
def __init__(self, cfg, in_channels):
super(KeypointRCNNPredictor, self).__init__()
... | 1,273 | 31.666667 | 81 | py |
PMTD | PMTD-master/maskrcnn_benchmark/structures/image_list.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from __future__ import division
import torch
class ImageList(object):
"""
Structure that holds a list of images (of possibly
varying sizes) as a single tensor.
This works by padding the images to the same size,
and storing in... | 2,485 | 33.054795 | 87 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.