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
light-moco
light-moco-main/my_models/hrnet.py
""" HRNet Copied from https://github.com/HRNet/HRNet-Image-Classification Original header: Copyright (c) Microsoft Licensed under the MIT License. Written by Bin Xiao (Bin.Xiao@microsoft.com) Modified by Ke Sun (sunk@mail.ustc.edu.cn) """ import logging from typing import List import torch import torch.nn as...
29,304
34.222356
126
py
light-moco
light-moco-main/my_models/selecsls.py
"""PyTorch SelecSLS Net example for ImageNet Classification License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/legalcode) Author: Dushyant Mehta (@mehtadushy) SelecSLS (core) Network Architecture as proposed in "XNect: Real-time Multi-person 3D Human Pose Estimation with a Single RGB Camera, Mehta et al."...
13,103
35.4
121
py
light-moco
light-moco-main/my_models/regnet.py
"""RegNet Paper: `Designing Network Design Spaces` - https://arxiv.org/abs/2003.13678 Original Impl: https://github.com/facebookresearch/pycls/blob/master/pycls/models/regnet.py Based on original PyTorch impl linked above, but re-wrote to use my own blocks (adapted from ResNet here) and cleaned up with more descripti...
20,532
41.956067
137
py
light-moco
light-moco-main/my_models/efficientnet_builder.py
""" EfficientNet, MobileNetV3, etc Builder Assembles EfficieNet and related network feature blocks from string definitions. Handles stride, dilation calculations, and selects feature extraction points. Hacked together by / Copyright 2020 Ross Wightman """ import logging import math import re from copy import deepcop...
17,482
41.127711
124
py
light-moco
light-moco-main/my_models/features.py
""" PyTorch Feature Extraction Helpers A collection of classes, functions, modules to help extract features from models and provide a common interface for describing them. The return_layers, module re-writing idea inspired by torchvision IntermediateLayerGetter https://github.com/pytorch/vision/blob/d88d8961ae51507d0...
12,155
41.652632
111
py
light-moco
light-moco-main/my_models/inflate_from_2d_model.py
import torch from collections import OrderedDict def inflate_from_2d_model(state_dict_2d, state_dict_3d, skipped_keys=None, inflated_dim=2): if skipped_keys is None: skipped_keys = [] missed_keys = [] new_keys = [] for old_key in state_dict_2d.keys(): if old_key not in state_dict_3d....
1,899
35.538462
91
py
light-moco
light-moco-main/my_models/efficientnet.py
""" PyTorch EfficientNet Family An implementation of EfficienNet that covers variety of related models with efficient architectures: * EfficientNet (B0-B8, L2 + Tensorflow pretrained AutoAug/RandAug/AdvProp/NoisyStudent weight ports) - EfficientNet: Rethinking Model Scaling for CNNs - https://arxiv.org/abs/1905.119...
71,363
40.203233
139
py
light-moco
light-moco-main/my_models/pnasnet.py
""" pnasnet5large implementation grabbed from Cadene's pretrained models Additional credit to https://github.com/creafz https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/pnasnet.py """ from collections import OrderedDict import torch import torch.nn as nn import torch.nn.func...
14,839
41.643678
124
py
light-moco
light-moco-main/my_models/resnet.py
"""PyTorch ResNet This started as a copy of https://github.com/pytorch/vision 'resnet.py' (BSD-3-Clause) with additional dropout and dynamic global avg/max pool. ResNeXt, SE-ResNeXt, SENet, and MXNet Gluon stem/downsample variants, tiered stems added by Ross Wightman Copyright 2020 Ross Wightman """ import math impor...
58,771
43.02397
135
py
light-moco
light-moco-main/my_models/xception_aligned.py
"""Pytorch impl of Aligned Xception 41, 65, 71 This is a correct, from scratch impl of Aligned Xception (Deeplab) models compatible with TF weights at https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md Hacked together by / Copyright 2020 Ross Wightman """ from collections import Orde...
9,269
37.46473
124
py
light-moco
light-moco-main/my_models/rexnet.py
""" ReXNet A PyTorch impl of `ReXNet: Diminishing Representational Bottleneck on Convolutional Neural Network` - https://arxiv.org/abs/2007.00992 Adapted from original impl at https://github.com/clovaai/rexnet Copyright (c) 2020-present NAVER Corp. MIT license Changes for timm, feature extraction, and rounded channe...
10,135
37.539924
121
py
light-moco
light-moco-main/my_models/densenet.py
"""Pytorch Densenet implementation w/ tweaks This file is a copy of https://github.com/pytorch/vision 'densenet.py' (BSD-3-Clause) with fixed kwargs passthrough and addition of dynamic global avg/max pool. """ import re from collections import OrderedDict from functools import partial import torch import torch.nn as n...
15,598
39.411917
129
py
light-moco
light-moco-main/my_models/swav_resnet50.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch import torch.nn as nn def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): """3x3 convo...
11,064
30.169014
106
py
light-moco
light-moco-main/my_models/resnetv2.py
"""Pre-Activation ResNet v2 with GroupNorm and Weight Standardization. A PyTorch implementation of ResNetV2 adapted from the Google Big-Transfoer (BiT) source code at https://github.com/google-research/big_transfer to match timm interfaces. The BiT weights have been included here as pretrained models from their origin...
25,337
41.656566
117
py
light-moco
light-moco-main/my_models/mobilenetv3.py
""" MobileNet V3 A PyTorch impl of MobileNet-V3, compatible with TF weights from official impl. Paper: Searching for MobileNetV3 - https://arxiv.org/abs/1905.02244 Hacked together by / Copyright 2020 Ross Wightman """ import torch import torch.nn as nn import torch.nn.functional as F from typing import List from ...
17,610
38.575281
141
py
light-moco
light-moco-main/my_models/senet.py
""" SEResNet implementation from Cadene's pretrained models https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/senet.py Additional credit to https://github.com/creafz Original model: https://github.com/hujie-frank/SENet ResNet code gently borrowed from https://github.com/pytorch/v...
17,640
36.856223
127
py
light-moco
light-moco-main/my_models/vovnet.py
""" VoVNet (V1 & V2) Papers: * `An Energy and GPU-Computation Efficient Backbone Network` - https://arxiv.org/abs/1904.09730 * `CenterMask : Real-Time Anchor-Free Instance Segmentation` - https://arxiv.org/abs/1911.06667 Looked at https://github.com/youngwanLEE/vovnet-detectron2 & https://github.com/stigma0617/VoVNe...
13,824
33.220297
126
py
light-moco
light-moco-main/my_models/vision_transformer.py
""" Vision Transformer (ViT) in PyTorch A PyTorch implement of Vision Transformers as described in 'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale' - https://arxiv.org/abs/2010.11929 The official jax code is released and available at https://github.com/google-research/vision_transformer ...
36,684
45.554569
137
py
light-moco
light-moco-main/my_models/inception_v4.py
""" Pytorch Inception-V4 implementation Sourced from https://github.com/Cadene/tensorflow-model-zoo.torch (MIT License) which is based upon Google's Tensorflow implementation and pretrained weights (Apache 2.0 License) """ import torch import torch.nn as nn import torch.nn.functional as F from .data_config import IMAG...
10,726
33.16242
122
py
light-moco
light-moco-main/my_models/inception_v3.py
""" Inception-V3 Originally from torchvision Inception3 model Licensed BSD-Clause 3 https://github.com/pytorch/vision/blob/master/LICENSE """ import torch import torch.nn as nn import torch.nn.functional as F from .data_config import IMAGENET_DEFAULT_STD, IMAGENET_DEFAULT_MEAN, IMAGENET_INCEPTION_MEAN, IMAGENET_INCEP...
17,434
36.17484
127
py
light-moco
light-moco-main/my_models/gluon_xception.py
"""Pytorch impl of Gluon Xception This is a port of the Gluon Xception code and weights, itself ported from a PyTorch DeepLab impl. Gluon model: (https://gluon-cv.mxnet.io/_modules/gluoncv/model_zoo/xception.html) Original PyTorch DeepLab impl: https://github.com/jfzhang95/pytorch-deeplab-xception Hacked together by ...
9,533
35.528736
126
py
light-moco
light-moco-main/my_models/tresnet.py
""" TResNet: High Performance GPU-Dedicated Architecture https://arxiv.org/pdf/2003.13630.pdf Original model: https://github.com/mrT23/TResNet """ import copy from collections import OrderedDict from functools import partial import torch import torch.nn as nn import torch.nn.functional as F from .helpers import bui...
11,433
37.891156
125
py
light-moco
light-moco-main/my_models/resnest.py
""" ResNeSt Models Paper: `ResNeSt: Split-Attention Networks` - https://arxiv.org/abs/2004.08955 Adapted from original PyTorch impl w/ weights at https://github.com/zhanghang1989/ResNeSt by Hang Zhang Modified for torchscript compat, and consistency with timm by Ross Wightman """ import torch from torch import nn f...
10,197
42.029536
131
py
light-moco
light-moco-main/my_models/nasnet.py
""" """ import torch import torch.nn as nn import torch.nn.functional as F from .helpers import build_model_with_cfg from .layers import ConvBnAct, create_conv2d, create_pool2d, create_classifier from .registry import register_model __all__ = ['NASNetALarge'] default_cfgs = { 'nasnetalarge': { 'url': 'h...
25,683
44.619893
116
py
light-moco
light-moco-main/my_models/gluon_resnet.py
"""Pytorch impl of MxNet Gluon ResNet/(SE)ResNeXt variants This file evolved from https://github.com/pytorch/vision 'resnet.py' with (SE)-ResNeXt additions and ports of Gluon variations (https://github.com/dmlc/gluon-cv/blob/master/gluoncv/model_zoo/resnet.py) by Ross Wightman """ from .data_config import IMAGENET_DE...
11,351
45.146341
165
py
light-moco
light-moco-main/my_models/xception.py
""" Ported to pytorch thanks to [tstandley](https://github.com/tstandley/Xception-PyTorch) @author: tstandley Adapted by cadene Creates an Xception Model as defined in: Francois Chollet Xception: Deep Learning with Depthwise Separable Convolutions https://arxiv.org/pdf/1610.02357.pdf This weights ported from the Ke...
7,372
30.917749
120
py
light-moco
light-moco-main/my_models/inception_resnet_v2.py
""" Pytorch Inception-Resnet-V2 implementation Sourced from https://github.com/Cadene/tensorflow-model-zoo.torch (MIT License) which is based upon Google's Tensorflow implementation and pretrained weights (Apache 2.0 License) """ import torch import torch.nn as nn import torch.nn.functional as F from .data_config impo...
12,321
33.709859
139
py
light-moco
light-moco-main/my_models/dpn.py
""" PyTorch implementation of DualPathNetworks Based on original MXNet implementation https://github.com/cypw/DPNs with many ideas from another PyTorch implementation https://github.com/oyam/pytorch-DPNs. This implementation is compatible with the pretrained weights from cypw's MXNet implementation. Hacked together b...
12,331
38.399361
118
py
light-moco
light-moco-main/my_models/sknet.py
""" Selective Kernel Networks (ResNet base) Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586) This was inspired by reading 'Compounding the Performance Improvements...' (https://arxiv.org/abs/2001.06268) and a streamlined impl at https://github.com/clovaai/assembled-cnn but I ended up building somet...
8,712
38.785388
124
py
light-moco
light-moco-main/my_models/helpers.py
""" Model creation / weight loading / state_dict helpers Hacked together by / Copyright 2020 Ross Wightman """ import logging import os import math from collections import OrderedDict from copy import deepcopy from typing import Callable import torch import torch.nn as nn from torch.hub import load_state_dict_from_ur...
15,643
40.717333
115
py
light-moco
light-moco-main/my_models/res2net.py
""" Res2Net and Res2NeXt Adapted from Official Pytorch impl at: https://github.com/gasvn/Res2Net/ Paper: `Res2Net: A New Multi-scale Backbone Architecture` - https://arxiv.org/abs/1904.01169 """ import math import torch import torch.nn as nn from .data_config import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from .h...
7,852
35.525581
127
py
light-moco
light-moco-main/my_models/cspnet.py
"""PyTorch CspNet A PyTorch implementation of Cross Stage Partial Networks including: * CSPResNet50 * CSPResNeXt50 * CSPDarkNet53 * and DarkNet53 for good measure Based on paper `CSPNet: A New Backbone that can Enhance Learning Capability of CNN` - https://arxiv.org/abs/1911.11929 Reference impl via darknet cfg file...
17,907
38.444934
129
py
light-moco
light-moco-main/my_models/twod_models/resnet.py
from functools import partial from inspect import signature import numpy as np import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo from models.twod_models.common import TemporalPooling from models.twod_models.temporal_modeling import temporal_modeling_module __all__ = ['resnet'] model_urls ...
10,032
36.02214
106
py
light-moco
light-moco-main/my_models/twod_models/temporal_modeling.py
import torch import torch.nn.functional as F import torch.nn as nn class SEModule(nn.Module): def __init__(self, channels, dw_conv): super().__init__() ks = 1 pad = (ks - 1) // 2 self.fc1 = nn.Conv2d(channels, channels, kernel_size=ks, padding=pad, gr...
3,561
33.921569
111
py
light-moco
light-moco-main/my_models/twod_models/common.py
import torch.nn as nn class TemporalPooling(nn.Module): def __init__(self, frames, kernel_size=3, stride=2, mode='avg'): """ Parameters ---------- frames (int): number of input frames kernel_size stride mode """ super().__init__() s...
1,052
29.970588
92
py
light-moco
light-moco-main/my_models/twod_models/inception_v1.py
from functools import partial from inspect import signature import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo import numpy as np from models.twod_models.common import TemporalPooling from models.twod_models.temporal_modeling import temporal_modeling_module ...
10,783
38.072464
100
py
light-moco
light-moco-main/my_models/layers/split_batchnorm.py
""" Split BatchNorm A PyTorch BatchNorm layer that splits input batch into N equal parts and passes each through a separate BN layer. The first split is passed through the parent BN layers with weight/bias keys the same as the original BN. All other splits pass through BN sub-layers under the '.aux_bn' namespace. Thi...
3,441
44.289474
118
py
light-moco
light-moco-main/my_models/layers/blur_pool.py
""" BlurPool layer inspired by - Kornia's Max_BlurPool2d - Making Convolutional Networks Shift-Invariant Again :cite:`zhang2019shiftinvar` FIXME merge this impl with those in `anti_aliasing.py` Hacked together by Chris Ha and Ross Wightman """ import torch import torch.nn as nn import torch.nn.functional as F impo...
2,180
35.966102
117
py
light-moco
light-moco-main/my_models/layers/separable_conv.py
""" Depthwise Separable Conv Modules Basic DWS convs. Other variations of DWS exist with batch norm or activations between the DW and PW convs such as the Depthwise modules in MobileNetV2 / EfficientNet and Xception. Hacked together by / Copyright 2020 Ross Wightman """ from torch import nn as nn from .create_conv2d...
2,641
34.226667
110
py
light-moco
light-moco-main/my_models/layers/mixed_conv2d.py
""" PyTorch Mixed Convolution Paper: MixConv: Mixed Depthwise Convolutional Kernels (https://arxiv.org/abs/1907.09595) Hacked together by / Copyright 2020 Ross Wightman """ import torch from torch import nn as nn from .conv2d_same import create_conv2d_pad def _split_channels(num_chan, num_groups): split = [nu...
1,844
34.480769
99
py
light-moco
light-moco-main/my_models/layers/anti_aliasing.py
import torch import torch.nn.parallel import torch.nn as nn import torch.nn.functional as F class AntiAliasDownsampleLayer(nn.Module): def __init__(self, channels: int = 0, filt_size: int = 3, stride: int = 2, no_jit: bool = False): super(AntiAliasDownsampleLayer, self).__init__() if no_jit: ...
2,293
36.606557
118
py
light-moco
light-moco-main/my_models/layers/weight_init.py
import torch import math import warnings def _no_grad_trunc_normal_(tensor, mean, std, a, b): # Cut & paste from PyTorch official master until it's in a few official releases - RW # Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf def norm_cdf(x): # Computes ...
2,359
37.688525
93
py
light-moco
light-moco-main/my_models/layers/evo_norm.py
"""EvoNormB0 (Batched) and EvoNormS0 (Sample) in PyTorch An attempt at getting decent performing EvoNorms running in PyTorch. While currently faster than other impl, still quite a ways off the built-in BN in terms of memory usage and throughput (roughly 5x mem, 1/2 - 1/3x speed). Still very much a WIP, fiddling with ...
3,328
38.630952
111
py
light-moco
light-moco-main/my_models/layers/pool2d_same.py
""" AvgPool2d w/ Same Padding Hacked together by / Copyright 2020 Ross Wightman """ import torch import torch.nn as nn import torch.nn.functional as F from typing import List, Tuple, Optional from .helpers import to_2tuple from .padding import pad_same, get_padding_value def avg_pool2d_same(x, kernel_size: List[int...
2,969
40.25
118
py
light-moco
light-moco-main/my_models/layers/create_act.py
""" Activation Factory Hacked together by / Copyright 2020 Ross Wightman """ from .activations import * from .activations_jit import * from .activations_me import * from .config import is_exportable, is_scriptable, is_no_jit # PyTorch has an optimized, native 'silu' (aka 'swish') operator as of PyTorch 1.7. This code ...
3,904
28.141791
97
py
light-moco
light-moco-main/my_models/layers/classifier.py
""" Classifier head and layer factory Hacked together by / Copyright 2020 Ross Wightman """ from torch import nn as nn from torch.nn import functional as F from .adaptive_avgmax_pool import SelectAdaptivePool2d from .linear import Linear def _create_pool(num_features, num_classes, pool_type='avg', use_conv=False): ...
2,300
40.089286
111
py
light-moco
light-moco-main/my_models/layers/cond_conv2d.py
""" PyTorch Conditionally Parameterized Convolution (CondConv) Paper: CondConv: Conditionally Parameterized Convolutions for Efficient Inference (https://arxiv.org/abs/1904.04971) Hacked together by / Copyright 2020 Ross Wightman """ import math from functools import partial import numpy as np import torch from torc...
5,129
40.707317
119
py
light-moco
light-moco-main/my_models/layers/conv2d_same.py
""" Conv2d w/ Same Padding Hacked together by / Copyright 2020 Ross Wightman """ import torch import torch.nn as nn import torch.nn.functional as F from typing import Tuple, Optional from .padding import pad_same, get_padding_value def conv2d_same( x, weight: torch.Tensor, bias: Optional[torch.Tensor] = Non...
1,490
33.674419
108
py
light-moco
light-moco-main/my_models/layers/adaptive_avgmax_pool.py
""" PyTorch selectable adaptive pooling Adaptive pooling with the ability to select the type of pooling from: * 'avg' - Average pooling * 'max' - Max pooling * 'avgmax' - Sum of average and max pooling re-scaled by 0.5 * 'avgmaxc' - Concatenation of average and max pooling along feature dim, doubles fea...
3,903
31.533333
111
py
light-moco
light-moco-main/my_models/layers/conv_bn_act.py
""" Conv2d + BN + Act Hacked together by / Copyright 2020 Ross Wightman """ from torch import nn as nn from .create_conv2d import create_conv2d from .create_norm_act import convert_norm_act_type class ConvBnAct(nn.Module): def __init__(self, in_channels, out_channels, kernel_size=1, stride=1, padding='', dilati...
1,466
34.780488
108
py
light-moco
light-moco-main/my_models/layers/linear.py
""" Linear layer (alternate definition) """ import torch import torch.nn.functional as F from torch import nn as nn class Linear(nn.Linear): r"""Applies a linear transformation to the incoming data: :math:`y = xA^T + b` Wraps torch.nn.Linear to support AMP + torchscript usage by manually casting weight &...
743
36.2
89
py
light-moco
light-moco-main/my_models/layers/config.py
""" Model / Layer Config singleton state """ from typing import Any, Optional __all__ = [ 'is_exportable', 'is_scriptable', 'is_no_jit', 'set_exportable', 'set_scriptable', 'set_no_jit', 'set_layer_config' ] # Set to True if prefer to have layers with no jit optimization (includes activations) _NO_JIT = False...
3,069
25.465517
102
py
light-moco
light-moco-main/my_models/layers/cbam.py
""" CBAM (sort-of) Attention Experimental impl of CBAM: Convolutional Block Attention Module: https://arxiv.org/abs/1807.06521 WARNING: Results with these attention layers have been mixed. They can significantly reduce performance on some tasks, especially fine-grained it seems. I may end up removing this impl. Hack...
3,337
32.38
106
py
light-moco
light-moco-main/my_models/layers/activations_jit.py
""" Activations A collection of jit-scripted activations fn and modules with a common interface so that they can easily be swapped. All have an `inplace` arg even if not used. All jit scripted activations are lacking in-place variations on purpose, scripted kernel fusion does not currently work across in-place op bou...
2,529
26.802198
107
py
light-moco
light-moco-main/my_models/layers/activations_me.py
""" Activations (memory-efficient w/ custom autograd) A collection of activations fn and modules with a common interface so that they can easily be swapped. All have an `inplace` arg even if not used. These activations are not compatible with jit scripting or ONNX export of the model, please use either the JIT or bas...
5,339
24.550239
108
py
light-moco
light-moco-main/my_models/layers/split_attn.py
""" Split Attention Conv2d (for ResNeSt Models) Paper: `ResNeSt: Split-Attention Networks` - /https://arxiv.org/abs/2004.08955 Adapted from original PyTorch impl at https://github.com/zhanghang1989/ResNeSt Modified for torchscript compat, performance, and consistency with timm by Ross Wightman """ import torch impor...
3,013
32.865169
90
py
light-moco
light-moco-main/my_models/layers/activations.py
""" Activations A collection of activations fn and modules with a common interface so that they can easily be swapped. All have an `inplace` arg even if not used. Hacked together by / Copyright 2020 Ross Wightman """ import torch from torch import nn as nn from torch.nn import functional as F def swish(x, inplace:...
4,040
26.678082
107
py
light-moco
light-moco-main/my_models/layers/eca.py
""" ECA module from ECAnet paper: ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks https://arxiv.org/abs/1910.03151 Original ECA model borrowed from https://github.com/BangguWu/ECANet Modified circular ECA implementation and adaption for use in timm package by Chris Ha https://github.com/V...
4,701
42.537037
104
py
light-moco
light-moco-main/my_models/layers/space_to_depth.py
import torch import torch.nn as nn class SpaceToDepth(nn.Module): def __init__(self, block_size=4): super().__init__() assert block_size == 4 self.bs = block_size def forward(self, x): N, C, H, W = x.size() x = x.view(N, C, H // self.bs, self.bs, W // self.bs, self.bs)...
1,750
31.425926
102
py
light-moco
light-moco-main/my_models/layers/create_attn.py
""" Select AttentionFactory Method Hacked together by / Copyright 2020 Ross Wightman """ import torch from .se import SEModule, EffectiveSEModule from .eca import EcaModule, CecaModule from .cbam import CbamModule, LightCbamModule def create_attn(attn_type, channels, **kwargs): module_cls = None if attn_type...
1,222
31.184211
68
py
light-moco
light-moco-main/my_models/layers/median_pool.py
""" Median Pool Hacked together by / Copyright 2020 Ross Wightman """ import torch.nn as nn import torch.nn.functional as F from .helpers import to_2tuple, to_4tuple class MedianPool2d(nn.Module): """ Median pool (usable as median filter when stride=1) module. Args: kernel_size: size of pooling kern...
1,737
33.76
87
py
light-moco
light-moco-main/my_models/layers/test_time_pool.py
""" Test Time Pooling (Average-Max Pool) Hacked together by / Copyright 2020 Ross Wightman """ import logging from torch import nn import torch.nn.functional as F from .adaptive_avgmax_pool import adaptive_avgmax_pool2d _logger = logging.getLogger(__name__) class TestTimePoolHead(nn.Module): def __init__(sel...
1,851
36.04
97
py
light-moco
light-moco-main/my_models/layers/selective_kernel.py
""" Selective Kernel Convolution/Attention Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586) Hacked together by / Copyright 2020 Ross Wightman """ import torch from torch import nn as nn from .conv_bn_act import ConvBnAct def _kernel_valid(k): if isinstance(k, (list, tuple)): for ki i...
5,282
43.394958
116
py
light-moco
light-moco-main/my_models/layers/norm_act.py
""" Normalization + Activation Layers """ import torch from torch import nn as nn from torch.nn import functional as F from .create_act import get_act_layer class BatchNormAct2d(nn.BatchNorm2d): """BatchNorm + Activation This module performs BatchNorm + Activation in a manner that will remain backwards ...
3,542
39.724138
109
py
light-moco
light-moco-main/my_models/layers/create_conv2d.py
""" Create Conv2d Factory Method Hacked together by / Copyright 2020 Ross Wightman """ from .mixed_conv2d import MixedConv2d from .cond_conv2d import CondConv2d from .conv2d_same import create_conv2d_pad def create_conv2d(in_channels, out_channels, kernel_size, **kwargs): """ Select a 2d convolution implementat...
1,399
44.16129
98
py
light-moco
light-moco-main/my_models/layers/helpers.py
""" Layer/Module Helpers Hacked together by / Copyright 2020 Ross Wightman """ from itertools import repeat # from torch._six import container_abcs import collections.abc as container_abcs # From PyTorch internals def _ntuple(n): def parse(x): if isinstance(x, container_abcs.Iterable): return...
494
16.068966
50
py
light-moco
light-moco-main/my_models/layers/create_norm_act.py
""" NormAct (Normalizaiton + Activation Layer) Factory Create norm + act combo modules that attempt to be backwards compatible with separate norm + act isntances in models. Where these are used it will be possible to swap separate BN + act layers with combined modules like IABN or EvoNorms. Hacked together by / Copyr...
3,327
43.373333
118
py
light-moco
light-moco-main/my_models/layers/padding.py
""" Padding Helpers Hacked together by / Copyright 2020 Ross Wightman """ import math from typing import List, Tuple import torch.nn.functional as F # Calculate symmetric padding for a convolution def get_padding(kernel_size: int, stride: int = 1, dilation: int = 1, **_) -> int: padding = ((stride - 1) + dilati...
2,167
37.035088
99
py
light-moco
light-moco-main/my_models/layers/se.py
from torch import nn as nn from .create_act import create_act_layer class SEModule(nn.Module): def __init__(self, channels, reduction=16, act_layer=nn.ReLU, min_channels=8, reduction_channels=None, gate_layer='sigmoid'): super(SEModule, self).__init__() reduction_channels = reduc...
1,406
37.027027
106
py
light-moco
light-moco-main/my_models/layers/drop.py
""" DropBlock, DropPath PyTorch implementations of DropBlock and DropPath (Stochastic Depth) regularization layers. Papers: DropBlock: A regularization method for convolutional networks (https://arxiv.org/abs/1810.12890) Deep Networks with Stochastic Depth (https://arxiv.org/abs/1603.09382) Code: DropBlock impl ins...
6,938
40.059172
118
py
light-moco
light-moco-main/my_models/layers/inplace_abn.py
import torch from torch import nn as nn try: from inplace_abn.functions import inplace_abn, inplace_abn_sync has_iabn = True except ImportError: has_iabn = False def inplace_abn(x, weight, bias, running_mean, running_var, training=True, momentum=0.1, eps=1e-05, activation="leaky_re...
3,353
37.113636
111
py
light-moco
light-moco-main/my_models/threed_models/c3d.py
import torch import torch.nn as nn ''' https://github.com/jfzhang95/pytorch-video-recognition/blob/master/network/C3D_model.py ''' __all__ = ['c3d'] defaultcfg = { '11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512], '11pruned_aa' : [64, 'M', 128, 'M', 256, 256, 'M', 256, 256, 'M', 256, 256] ...
7,850
35.013761
113
py
light-moco
light-moco-main/my_models/threed_models/s3d_resnet.py
import numpy as np import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo import torch.nn.functional as F from models.inflate_from_2d_model import inflate_from_2d_model __all__ = ['s3d_resnet'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resn...
10,015
37.972763
107
py
light-moco
light-moco-main/my_models/threed_models/i3d.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo from models.inflate_from_2d_model import inflate_from_2d_model __all__ = ['i3d'] model_urls = { 'googlenet': 'https://download.pytorch.org/models/googlenet-1378be20.pth', } class I3D(nn.Module): def...
6,808
37.039106
99
py
light-moco
light-moco-main/my_models/threed_models/s3d.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo from models.inflate_from_2d_model import inflate_from_2d_model __all__ = ['s3d'] model_urls = { 'googlenet': 'https://download.pytorch.org/models/googlenet-1378be20.pth', } ''' A pytorch implementation ...
8,403
37.728111
102
py
light-moco
light-moco-main/my_models/threed_models/i3d_resnet.py
import numpy as np import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo import torch.nn.functional as F from models.inflate_from_2d_model import inflate_from_2d_model __all__ = ['i3d_resnet'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resn...
8,498
35.792208
107
py
light-moco
light-moco-main/detection/convert-pretrain-to-detectron2.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import pickle as pkl import sys import torch if __name__ == "__main__": input = sys.argv[1] obj = torch.load(input, map_location="cpu") obj = obj["state_dict"] newmodel = {} for k, v in obj.items(): ...
1,021
28.2
80
py
segmentation_models
segmentation_models-master/segmentation_models/utils.py
""" Utility functions for segmentation models """ from keras_applications import get_submodules_from_kwargs from . import inject_global_submodules def set_trainable(model, recompile=True, **kwargs): """Set all layers of model trainable and recompile it Note: Model is recompiled using same optimizer,...
3,002
32.366667
87
py
segmentation_models
segmentation_models-master/segmentation_models/__init__.py
import os import functools from .__version__ import __version__ from . import base _KERAS_FRAMEWORK_NAME = 'keras' _TF_KERAS_FRAMEWORK_NAME = 'tf.keras' _DEFAULT_KERAS_FRAMEWORK = _KERAS_FRAMEWORK_NAME _KERAS_FRAMEWORK = None _KERAS_BACKEND = None _KERAS_LAYERS = None _KERAS_MODELS = None _KERAS_UTILS = None _KERAS_L...
4,041
27.464789
103
py
segmentation_models
segmentation_models-master/segmentation_models/models/pspnet.py
from keras_applications import get_submodules_from_kwargs from ._common_blocks import Conv2dBn from ._utils import freeze_model, filter_keras_submodules from ..backbones.backbones_factory import Backbones backend = None layers = None models = None keras_utils = None # -----------------------------------------------...
8,499
33.552846
113
py
segmentation_models
segmentation_models-master/segmentation_models/models/_utils.py
from keras_applications import get_submodules_from_kwargs def freeze_model(model, **kwargs): """Set all layers non trainable, excluding BatchNormalization layers""" _, layers, _, _ = get_submodules_from_kwargs(kwargs) for layer in model.layers: if not isinstance(layer, layers.BatchNormalization): ...
616
35.294118
77
py
segmentation_models
segmentation_models-master/segmentation_models/models/linknet.py
from keras_applications import get_submodules_from_kwargs from ._common_blocks import Conv2dBn from ._utils import freeze_model, filter_keras_submodules from ..backbones.backbones_factory import Backbones backend = None layers = None models = None keras_utils = None # -----------------------------------------------...
9,762
34.118705
125
py
segmentation_models
segmentation_models-master/segmentation_models/models/unet.py
from keras_applications import get_submodules_from_kwargs from ._common_blocks import Conv2dBn from ._utils import freeze_model, filter_keras_submodules from ..backbones.backbones_factory import Backbones backend = None layers = None models = None keras_utils = None # -----------------------------------------------...
8,414
32.26087
121
py
segmentation_models
segmentation_models-master/segmentation_models/models/fpn.py
from keras_applications import get_submodules_from_kwargs from ._common_blocks import Conv2dBn from ._utils import freeze_model, filter_keras_submodules from ..backbones.backbones_factory import Backbones backend = None layers = None models = None keras_utils = None # -----------------------------------------------...
9,094
34.666667
125
py
segmentation_models
segmentation_models-master/segmentation_models/models/_common_blocks.py
from keras_applications import get_submodules_from_kwargs def Conv2dBn( filters, kernel_size, strides=(1, 1), padding='valid', data_format=None, dilation_rate=(1, 1), activation=None, kernel_initializer='glorot_uniform', bias_initializer='zeros',...
2,133
29.485714
82
py
segmentation_models
segmentation_models-master/segmentation_models/base/functional.py
SMOOTH = 1e-5 # ---------------------------------------------------------------- # Helpers # ---------------------------------------------------------------- def _gather_channels(x, indexes, **kwargs): """Slice tensor along channels axis by given indexes""" backend = kwargs['backend'] if backend.image_...
11,668
36.763754
118
py
segmentation_models
segmentation_models-master/segmentation_models/backbones/inception_v3.py
"""Inception V3 model for Keras. Note that the input image format for this model is different than for the VGG16 and ResNet models (299x299 instead of 224x224), and that the input preprocessing function is also different (same as Xception). # Reference - [Rethinking the Inception Architecture for Computer Vision]( ...
14,611
36.180662
80
py
segmentation_models
segmentation_models-master/segmentation_models/backbones/inception_resnet_v2.py
"""Inception-ResNet V2 model for Keras. Model naming and structure follows TF-slim implementation (which has some additional layers and different number of filters from the original arXiv paper): https://github.com/tensorflow/models/blob/master/research/slim/nets/inception_resnet_v2.py Pre-trained ImageNet weights are ...
14,925
41.645714
90
py
segmentation_models
segmentation_models-master/tests/test_models.py
import os import pytest import random import six import numpy as np import segmentation_models as sm from segmentation_models import Unet from segmentation_models import Linknet from segmentation_models import PSPNet from segmentation_models import FPN from segmentation_models import get_available_backbone_names if s...
3,550
24.919708
80
py
segmentation_models
segmentation_models-master/tests/test_metrics.py
import pytest import numpy as np import segmentation_models as sm from segmentation_models.metrics import IOUScore, FScore from segmentation_models.losses import JaccardLoss, DiceLoss if sm.framework() == sm._TF_KERAS_FRAMEWORK_NAME: from tensorflow import keras elif sm.framework() == sm._KERAS_FRAMEWORK_NAME: ...
4,481
19.280543
95
py
segmentation_models
segmentation_models-master/tests/test_utils.py
import pytest import numpy as np import segmentation_models as sm from segmentation_models.utils import set_regularization from segmentation_models import Unet if sm.framework() == sm._TF_KERAS_FRAMEWORK_NAME: from tensorflow import keras elif sm.framework() == sm._KERAS_FRAMEWORK_NAME: import keras else: ...
3,143
26.823009
91
py
segmentation_models
segmentation_models-master/docs/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
5,775
28.620513
80
py
PySyft
PySyft-master/packages/syft/examples/duet/dcgan/original/main.py
# future from __future__ import print_function # stdlib import argparse import os import random # third party import torch import torch.backends.cudnn as cudnn import torch.nn as nn import torch.nn.parallel import torch.optim as optim import torch.utils.data import torchvision.datasets as dset import torchvision.tran...
11,189
30.432584
88
py
PySyft
PySyft-master/packages/syft/examples/duet/snli/original/model.py
# third party import torch import torch.nn as nn class Bottle(nn.Module): def forward(self, input): if len(input.size()) <= 2: return super(Bottle, self).forward(input) size = input.size()[:2] out = super(Bottle, self).forward(input.view(size[0] * size[1], -1)) return o...
2,753
31.785714
76
py
PySyft
PySyft-master/packages/syft/examples/duet/snli/original/util.py
# stdlib from argparse import ArgumentParser import os def makedirs(name): """helper function for python 2 and 3 to call os.makedirs() avoiding an error if the directory to be created already exists""" # stdlib import errno import os try: os.makedirs(name) except OSError as ex: ...
4,348
28.385135
102
py
PySyft
PySyft-master/packages/syft/examples/duet/snli/original/train.py
# stdlib import glob import os import time # third party from model import SNLIClassifier import torch import torch.nn as nn import torch.optim as O from torchtext import data from torchtext import datasets from util import get_args from util import makedirs args = get_args() if torch.cuda.is_available(): torch.c...
6,231
30.16
102
py
PySyft
PySyft-master/packages/syft/examples/duet/time_sequence_prediction/original/generate_sine_wave.py
# third party import numpy as np import torch np.random.seed(2) T = 20 L = 1000 N = 100 x = np.empty((N, L), "int64") x[:] = np.array(range(L)) + np.random.randint(-4 * T, 4 * T, N).reshape(N, 1) data = np.sin(x / 1.0 / T).astype("float64") torch.save(data, open("traindata.pt", "wb"))
289
18.333333
77
py
PySyft
PySyft-master/packages/syft/examples/duet/time_sequence_prediction/original/train.py
# future from __future__ import print_function # stdlib import argparse # third party import matplotlib import numpy as np import torch import torch.nn as nn import torch.optim as optim matplotlib.use("Agg") # third party import matplotlib.pyplot as plt class Sequence(nn.Module): def __init__(self): su...
3,566
28.237705
89
py
PySyft
PySyft-master/packages/syft/examples/duet/reinforcement_learning/original/reinforce.py
# stdlib import argparse from itertools import count # third party import gym import numpy as np import torch from torch.distributions import Categorical import torch.nn as nn import torch.nn.functional as F import torch.optim as optim parser = argparse.ArgumentParser(description="PyTorch REINFORCE example") parser.a...
3,344
25.975806
83
py
PySyft
PySyft-master/packages/syft/examples/duet/reinforcement_learning/original/actor_critic.py
# stdlib import argparse from collections import namedtuple from itertools import count # third party import gym import numpy as np import torch from torch.distributions import Categorical import torch.nn as nn import torch.nn.functional as F import torch.optim as optim # Cart Pole parser = argparse.ArgumentParser(de...
5,421
25.841584
83
py