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 |
|---|---|---|---|---|---|---|
RobustForensics | RobustForensics-master/video_based/models/slowfast.py | """SlowFast_Network model for Pytorch.
# Reference:
- [SlowFast Networks for Video Recognition](https://arxiv.org/abs/1812.03982)
Adapted code from:
@inproceedings{hara3dcnns,
author={Kensho Hara and Hirokatsu Kataoka and Yutaka Satoh},
title={Can Spatiotemporal 3D CNNs Retrace the History of 2D CNNs an... | 9,532 | 37.439516 | 143 | py |
RobustForensics | RobustForensics-master/inference/ensemble-align-face2-frame-all-rob-policy-flip.py | from __future__ import print_function
import torch
import torch.backends.cudnn as cudnn
import numpy as np
import cv2
import os
import pandas as pd
import copy
import time
import torchvision
from face_detect_lib.models.retinaface import RetinaFace
from face_detect_lib.layers.functions.prior_box import PriorBox
from fa... | 73,137 | 39.927812 | 163 | py |
RobustForensics | RobustForensics-master/inference/face_detect_lib/models/retinaface.py | import torch
import torch.nn as nn
import torchvision.models.detection.backbone_utils as backbone_utils
import torchvision.models._utils as _utils
import torch.nn.functional as F
from collections import OrderedDict
from face_detect_lib.models.net import MobileNetV1 as MobileNetV1
from face_detect_lib.models.net import... | 4,922 | 37.76378 | 125 | py |
RobustForensics | RobustForensics-master/inference/face_detect_lib/models/net.py | import time
import torch
import torch.nn as nn
import torchvision.models._utils as _utils
import torchvision.models as models
import torch.nn.functional as F
from torch.autograd import Variable
def conv_bn(inp, oup, stride = 1, leaky = 0):
return nn.Sequential(
nn.Conv2d(inp, oup, 3, stride, 1, bias=False)... | 4,598 | 32.326087 | 95 | py |
RobustForensics | RobustForensics-master/inference/face_detect_lib/layers/functions/prior_box.py | import torch
from itertools import product as product
import numpy as np
from math import ceil
class PriorBox(object):
def __init__(self, cfg, image_size=None, phase='train'):
super(PriorBox, self).__init__()
self.min_sizes = cfg['min_sizes']
self.steps = cfg['steps']
self.clip = c... | 1,327 | 36.942857 | 115 | py |
RobustForensics | RobustForensics-master/inference/face_detect_lib/layers/modules/multibox_loss.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from face_detect_lib.utils.box_utils import match, log_sum_exp
from face_detect_lib.models.config import cfg_mnet
GPU = cfg_mnet['gpu_train']
class MultiBoxLoss(nn.Module):
"""SSD Weighted Loss Function
Compu... | 5,314 | 41.18254 | 132 | py |
RobustForensics | RobustForensics-master/inference/face_detect_lib/utils/box_utils.py | import torch
import numpy as np
def point_form(boxes):
""" Convert prior_boxes to (xmin, ymin, xmax, ymax)
representation for comparison to point form ground truth data.
Args:
boxes: (tensor) center-size default boxes from priorbox layers.
Return:
boxes: (tensor) Converted xmin, ymin, ... | 14,828 | 38.649733 | 93 | py |
spv2 | spv2-master/with_labels.py | import numpy as np
import itertools
import logging
import typing
import re
import time
import os
import random
import math
import scipy.stats
import multiset
import collections
from keras.layers import Embedding, Input, LSTM, Dense, Masking
from keras.layers.merge import Concatenate
from keras.layers.wrappers import T... | 49,506 | 38.796624 | 168 | py |
spv2 | spv2-master/dataprep2.py | import mmh3
import logging
import numpy as np
import json
import os
import token_statistics
import re
import xml.etree.ElementTree as ET
import unicodedata
import stringmatch
import h5py
import collections
import gzip
import bz2
import typing
import sys
import html
import time
from enum import Enum
from queue import Qu... | 86,033 | 42.49545 | 233 | py |
LHDR | LHDR-main/test.py | import os
import time
from os import path
import argparse
import numpy as np
import torch
import cv2
from network import LiteHDRNet
### System utilities ###
def process_path(directory, create=False):
directory = path.expanduser(directory)
directory = path.normpath(directory)
directory = path.abspath(direc... | 5,795 | 33.295858 | 115 | py |
LHDR | LHDR-main/network.py | import functools
import torch
import torch.nn as nn
import torch.nn.functional as F
### Architecture utilities ###
def which_act(act_type):
if act_type == 'relu':
act = nn.ReLU(inplace=True)
elif act_type == 'relu6':
act = nn.ReLU6(inplace=True)
elif act_type == 'leakyrelu':
act = ... | 14,995 | 36.7733 | 120 | py |
resefa | resefa-main/manipulate.py | # python3.7
"""Manipulates synthesized or real images with existing boundary.
Support StyleGAN2 and StyleGAN3.
"""
import os.path
import argparse
import numpy as np
from tqdm import tqdm
import torch
from models import build_model
from utils.visualizers.html_visualizer import HtmlVisualizer
from utils.image_utils im... | 12,329 | 47.543307 | 80 | py |
resefa | resefa-main/synthesis.py | # python3.7
"""Script that synthesizes images with pre-trained models.
Support StyleGAN2 and StyleGAN3.
"""
import os
import argparse
from tqdm import tqdm
import numpy as np
import torch
from models import build_model
from utils.visualizers.html_visualizer import HtmlVisualizer
from utils.image_utils import save_im... | 8,359 | 45.703911 | 79 | py |
resefa | resefa-main/compute_jacobian.py | # python3.7
"""Functions to compute Jacobian based on pre-trained GAN generator.
Support StyleGAN2 or StyleGAN3
"""
import os
import argparse
import warnings
from tqdm import tqdm
import numpy as np
import torch
import torch.nn.functional as F
from torch.autograd.functional import jacobian
from models import build_m... | 8,672 | 42.149254 | 79 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/custom_ops.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 6,650 | 40.56875 | 146 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/bias_act.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 10,330 | 44.311404 | 178 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/grid_sample_gradfix.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 3,735 | 36.737374 | 138 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/conv2d_gradfix.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 8,322 | 42.805263 | 197 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/upfirdn2d.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 16,742 | 40.649254 | 157 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/misc.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 11,521 | 39.858156 | 133 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/conv2d_resample.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 8,128 | 47.100592 | 141 | py |
resefa | resefa-main/third_party/stylegan2_official_ops/fma.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this sof... | 2,341 | 30.648649 | 105 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/custom_ops.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 7,691 | 39.0625 | 146 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/bias_act.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 10,025 | 43.959641 | 178 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/grid_sample_gradfix.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 3,444 | 36.043011 | 132 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/conv2d_gradfix.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 10,179 | 45.272727 | 197 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/upfirdn2d.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 16,752 | 40.365432 | 120 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/misc.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 11,537 | 39.626761 | 133 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/filtered_lrelu.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 13,642 | 44.781879 | 164 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/conv2d_resample.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 7,240 | 45.716129 | 141 | py |
resefa | resefa-main/third_party/stylegan3_official_ops/fma.py | # python3.7
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distributio... | 2,342 | 30.662162 | 105 | py |
resefa | resefa-main/models/test.py | # python3.7
"""Unit test for loading pre-trained models.
Basically, this file tests whether the perceptual model (VGG16) and the
inception model (InceptionV3), which are commonly used for loss computation and
evaluation, have the expected behavior after loading pre-trained weights. In
particular, we compare with the m... | 6,646 | 44.217687 | 116 | py |
resefa | resefa-main/models/ghfeat_encoder.py | # python3.7
"""Contains the implementation of encoder used in GH-Feat (including IDInvert).
ResNet is used as the backbone.
GH-Feat paper: https://arxiv.org/pdf/2007.10379.pdf
IDInvert paper: https://arxiv.org/pdf/2004.00049.pdf
NOTE: Please use `latent_num` and `num_latents_per_head` to control the
inversion space,... | 22,232 | 38.420213 | 80 | py |
resefa | resefa-main/models/stylegan2_discriminator.py | # python3.7
"""Contains the implementation of discriminator described in StyleGAN2.
Compared to that of StyleGAN, the discriminator in StyleGAN2 mainly adds skip
connections, increases model size and disables progressive growth. This script
ONLY supports config F in the original paper.
Paper: https://arxiv.org/pdf/19... | 31,868 | 42.656164 | 80 | py |
resefa | resefa-main/models/stylegan2_generator.py | # python3.7
"""Contains the implementation of generator described in StyleGAN2.
Compared to that of StyleGAN, the generator in StyleGAN2 mainly introduces style
demodulation, adds skip connections, increases model size, and disables
progressive growth. This script ONLY supports config F in the original paper.
Paper: ... | 60,241 | 42.184229 | 80 | py |
resefa | resefa-main/models/pggan_generator.py | # python3.7
"""Contains the implementation of generator described in PGGAN.
Paper: https://arxiv.org/pdf/1710.10196.pdf
Official TensorFlow implementation:
https://github.com/tkarras/progressive_growing_of_gans
"""
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
__all__ = ['PG... | 16,042 | 38.90796 | 80 | py |
resefa | resefa-main/models/stylegan3_generator.py | # python3.7
"""Contains the implementation of generator described in StyleGAN3.
Compared to that of StyleGAN2, the generator in StyleGAN3 controls the frequency
flow along with the convolutional layers growing.
Paper: https://arxiv.org/pdf/2106.12423.pdf
Official implementation: https://github.com/NVlabs/stylegan3
"... | 56,563 | 41.433608 | 80 | py |
resefa | resefa-main/models/stylegan_discriminator.py | # python3.7
"""Contains the implementation of discriminator described in StyleGAN.
Paper: https://arxiv.org/pdf/1812.04948.pdf
Official TensorFlow implementation: https://github.com/NVlabs/stylegan
"""
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.cuda.amp import a... | 25,269 | 39.432 | 108 | py |
resefa | resefa-main/models/perceptual_model.py | # python3.7
"""Contains the VGG16 model, which is used for inference ONLY.
VGG16 is commonly used for perceptual feature extraction. The model implemented
in this file can be used for evaluation (like computing LPIPS, perceptual path
length, etc.), OR be used in training for loss computation (like perceptual
loss, etc... | 20,849 | 39.096154 | 93 | py |
resefa | resefa-main/models/inception_model.py | # python3.7
"""Contains the Inception V3 model, which is used for inference ONLY.
This file is mostly borrowed from `torchvision/models/inception.py`.
Inception model is widely used to compute FID or IS metric for evaluating
generative models. However, the pre-trained models from torchvision is slightly
different fro... | 21,905 | 37.909414 | 117 | py |
resefa | resefa-main/models/pggan_discriminator.py | # python3.7
"""Contains the implementation of discriminator described in PGGAN.
Paper: https://arxiv.org/pdf/1710.10196.pdf
Official TensorFlow implementation:
https://github.com/tkarras/progressive_growing_of_gans
"""
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
__all__ = ... | 17,833 | 37.270386 | 80 | py |
resefa | resefa-main/models/stylegan_generator.py | # python3.7
"""Contains the implementation of generator described in StyleGAN.
Paper: https://arxiv.org/pdf/1812.04948.pdf
Official TensorFlow implementation: https://github.com/NVlabs/stylegan
"""
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.cuda.amp import autoc... | 42,501 | 41.502 | 112 | py |
resefa | resefa-main/models/utils/ops.py | # python3.7
"""Contains operators for neural networks."""
import torch
import torch.distributed as dist
__all__ = ['all_gather']
def all_gather(tensor):
"""Gathers tensor from all devices and executes averaging."""
if not dist.is_initialized():
return tensor
world_size = dist.get_world_size()
... | 502 | 25.473684 | 70 | py |
resefa | resefa-main/utils/tf_utils.py | # python3.7
"""Contains the utility functions to handle import TensorFlow modules.
Basically, TensorFlow may not be supported in the current environment, or may
cause some warnings. This file provides functions to help ease TensorFlow
related imports, such as TensorBoard.
"""
import warnings
__all__ = ['import_tf', ... | 1,665 | 33.708333 | 100 | py |
resefa | resefa-main/utils/custom_utils.py | # python3.7
"""Utility functions for image editing."""
import numpy as np
import cv2
import torch
__all__ = ['to_numpy', 'linear_interpolate', 'make_transform',
'get_ind', 'mask2image']
def to_numpy(data):
"""Converts the input data to `numpy.ndarray`."""
if isinstance(data, (int, float)):
... | 2,735 | 30.448276 | 79 | py |
resefa | resefa-main/utils/dist_utils.py | # python3.7
"""Contains utility functions used for distribution."""
import contextlib
import os
import subprocess
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
__all__ = ['init_dist', 'exit_dist', 'ddp_sync', 'get_ddp_module']
def init_dist(launcher, backend='nccl', **kwargs):
... | 2,202 | 31.397059 | 80 | py |
resefa | resefa-main/utils/misc.py | # python3.7
"""Misc utility functions."""
import os
import hashlib
from torch.hub import download_url_to_file
__all__ = [
'REPO_NAME', 'Infix', 'print_and_execute', 'check_file_ext',
'IMAGE_EXTENSIONS', 'VIDEO_EXTENSIONS', 'MEDIA_EXTENSIONS',
'parse_file_format', 'set_cache_dir', 'get_cache_dir', 'downlo... | 7,351 | 31.245614 | 80 | py |
SDGCCA | SDGCCA-main/utils.py | import torch
import random
import numpy as np
from sklearn.model_selection import train_test_split, StratifiedKFold
from sklearn.metrics import f1_score, accuracy_score, roc_auc_score, matthews_corrcoef
# Calculate performance metric
def calculate_metric(y_true, y_pred, y_pred_proba):
acc = accuracy_score(y_true, ... | 4,982 | 37.330769 | 118 | py |
SDGCCA | SDGCCA-main/SDGCCA.py | import torch
import torch.nn as nn
import torch.nn.init as init
# Weight & Bias Initialization
def initialization(net):
if isinstance(net, nn.Linear):
init.xavier_uniform(net.weight)
init.zeros_(net.bias)
# SDGCCA with 3 Modality
class SDGCCA_3_M(nn.Module):
def __init__(self, m1_embedding_lis... | 5,469 | 32.353659 | 101 | py |
Jittor-MLP | Jittor-MLP-main/compare.py | import jittor as jt
from models_jittor import gMLPForImageClassification as gMLP_jt
from models_jittor import ResMLPForImageClassification as ResMLP_jt
from models_jittor import MLPMixerForImageClassification as MLPMixer_jt
from models_jittor import ViP as ViP_jt
from models_jittor import S2MLPv2 as S2MLPv2_jt
from mod... | 5,285 | 27.419355 | 102 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/dyna_mlp.py | import torch
from torch import nn
from timm.models.layers import DropPath
from einops.layers.torch import Rearrange, Reduce
# helpers
def pair(t):
return t if isinstance(t, tuple) else (t, t)
# classes
class PreNorm(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.norm = nn.L... | 6,406 | 33.820652 | 144 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/mlp_mixer.py | from torch import nn
from functools import partial
from einops.layers.torch import Rearrange, Reduce
from .utils import pair, check_sizes
class PreNormResidual(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.fn = fn
self.norm = nn.LayerNorm(dim)
def forward(self, x):
... | 2,452 | 30.857143 | 120 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/swin_mlp.py | # --------------------------------------------------------
# Swin Transformer
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ze Liu
# --------------------------------------------------------
import torch
import torch.nn as nn
import torch.nn.functional as F
impor... | 18,500 | 39.132321 | 118 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/ms_mlp.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as checkpoint
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
'''
https://github.com/JegZheng/MS-MLP/blob/main/models/ms_mlp.py
'''
class MixShiftBlock(nn.Module):
r""" Mix-Shifting Block.
Args:
... | 15,769 | 40.941489 | 216 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/morph_mlp.py | import torch
from torch import nn, Tensor
from torch.nn import functional as F
from timm.models.layers import DropPath
from einops.layers.torch import Rearrange
'''
Use BN instead of LN, keep consistent with WaveMLP
'''
class MLP(nn.Module):
def __init__(self, dim, hidden_dim, out_dim=None) -> None:
super... | 7,171 | 35.779487 | 187 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/sparse_mlp.py | import torch
from torch import nn
from functools import partial
from einops.layers.torch import Rearrange, Reduce
from .utils import pair
class PreNormResidual(nn.Module):
def __init__(self, dim, fn, norm = nn.LayerNorm):
super().__init__()
self.fn = fn
self.norm = norm(dim)
def forwa... | 5,668 | 32.744048 | 173 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/wave_mlp.py | import torch
from torch import nn, Tensor
from torch.nn import functional as F
from timm.models.layers import DropPath
'''
https://github.com/sithu31296/image-classification/blob/999ff3f14830df684440d95f3696e0b4bea3095a/models/wavemlp.py
'''
class MLP(nn.Module):
def __init__(self, dim, hidden_dim, out_dim=None) ... | 6,203 | 32.176471 | 120 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/gfnet.py | import math
import logging
from functools import partial
from collections import OrderedDict
from numpy.lib.arraypad import pad
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.models.layers import DropPath, to_2tuple, trunc_... | 16,452 | 37.622066 | 132 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/vip.py | import torch
from torch import nn
from functools import partial
from einops.layers.torch import Rearrange, Reduce
from .utils import pair, check_sizes
class PreNormResidual(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.fn = fn
self.norm = nn.LayerNorm(dim)
def forwar... | 6,509 | 36.848837 | 117 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/cycle_mlp.py | import os
import torch
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.models.layers import DropPath, trunc_normal_
from timm.models.registry import register_model
from timm.models.layers.helpers import to_2tuple
import math
from torch import Tensor
from torch.nn impo... | 15,113 | 35.773723 | 121 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/as_mlp.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as checkpoint
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
from .utils import Shift
class Mlp(nn.Module):
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU,... | 16,915 | 36.424779 | 118 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/g_mlp.py | from torch import nn
from torch.nn import functional as F
from .utils import pair, check_sizes
'''
https://github.com/jaketae/g-mlp/blob/master/g_mlp/core.py
'''
class SpatialGatingUnit(nn.Module):
def __init__(self, d_ffn, seq_len):
super().__init__()
self.norm = nn.LayerNorm(d_ffn)
self... | 2,758 | 28.666667 | 86 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/res_mlp.py | import torch
import numpy as np
from torch import nn
from einops.layers.torch import Rearrange
from .utils import pair, check_sizes
'''
https://github.com/rishikksh20/ResMLP-pytorch/blob/master/resmlp.py
'''
class Aff(nn.Module):
def __init__(self, dim):
super().__init__()
self.alpha = nn.Paramete... | 3,092 | 29.93 | 106 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/conv_mlp.py | from torch.hub import load_state_dict_from_url
import torch.nn as nn
import torch
# https://github.com/SHI-Labs/Convolutional-MLPs/blob/258f0df703566779c5c3ae552e6a33b07e119f3b/src/convmlp.py
__all__ = ['ConvMLP', 'convmlp_s', 'convmlp_m', 'convmlp_l']
model_urls = {
'convmlp_s': 'http://ix.cs.uoregon.edu/~alih... | 12,651 | 40.346405 | 135 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/s2_mlp_v2.py | import torch
from torch import nn
from einops.layers.torch import Reduce
from .utils import pair
class PreNormResidual(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.fn = fn
self.norm = nn.LayerNorm(dim)
def forward(self, x):
return self.fn(self.norm(x)) + x
... | 4,532 | 33.082707 | 147 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/repmlpnet.py | # --------------------------------------------------------
# RepMLPNet
# Licensed under The MIT License [see LICENSE for details]
# Written by Xiaohan Ding
# https://arxiv.org/abs/2112.11081
# https://github.com/DingXiaoH/RepMLP
# --------------------------------------------------------
import torch.nn.functional ... | 12,072 | 39.649832 | 150 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/raft_mlp.py | import math
from functools import reduce
from typing import List, Dict
from abc import ABC
from einops.layers.torch import Rearrange, Reduce
import torch
from torch import nn
from torch.nn import functional as F
# https://github.com/okojoalg/raft-mlp/blob/main/libs/models.py
PATCH_SIZE = "patch_size"
RAFT_SIZE = "ra... | 18,706 | 33.136861 | 87 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/active_mlp.py | # https://github.com/microsoft/ActiveMLP/blob/main/models/activemlp.py
import torch
import torch.nn as nn
import math
from torch.nn import init
from torch.nn.modules.utils import _pair
from torchvision.ops.deform_conv import deform_conv2d
from timm.models.layers import DropPath, trunc_normal_
from timm.models.registr... | 13,499 | 31.846715 | 140 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/hire_mlp.py | import torch
from torch import nn
from functools import partial
from einops.layers.torch import Rearrange, Reduce
from .utils import pair
class PreNormResidual(nn.Module):
def __init__(self, dim, fn, norm = nn.LayerNorm):
super().__init__()
self.fn = fn
self.norm = norm(dim)
def forwa... | 8,173 | 34.53913 | 186 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/sequencer.py | import torch
from torch import nn
from einops.layers.torch import Reduce
sequencer_settings = {
'S': [[4, 3, 8, 3], [192, 384, 384, 384], [48, 96, 96, 96], 3],
'M': [[4, 3, 14, 3], [192, 384, 384, 384], [48, 96, 96, 96], 3],
'L': [[8, 8, 16, 4], [192, 384, 384, 384], [48, 96, 96, 96], 3]
}
class PatchEmb... | 4,081 | 35.774775 | 146 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/conv_mixer.py | import torch.nn as nn
from einops.layers.torch import Rearrange
from .utils import pair, check_sizes
class Residual(nn.Module):
def __init__(self, fn):
super().__init__()
self.fn = fn
def forward(self, x):
return self.fn(x) + x
class ConvMixer(nn.Module):
def __init__(self, dim, d... | 1,414 | 29.106383 | 96 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/s2_mlp_v1.py | import torch
from torch import nn
from einops.layers.torch import Reduce
from .utils import pair
class PreNormResidual(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.fn = fn
self.norm = nn.LayerNorm(dim)
def forward(self, x):
return self.fn(self.norm(x)) + x
... | 4,155 | 32.248 | 147 | py |
Jittor-MLP | Jittor-MLP-main/models_pytorch/utils/shift_cuda.py | # the code is modified from https://github.com/d-li14/involution/blob/main/cls/mmcls/models/utils/involution_cuda.py
from torch.autograd import Function
import torch
from torch.nn.modules.utils import _pair
import torch.nn.functional as F
import torch.nn as nn
from collections import namedtuple
import cupy
from string... | 6,553 | 30.970732 | 116 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/dyna_mlp.py | import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
from .utils import pair
from .einops_my.layers.jittor import Rearrange, Reduce
############################################## Drop Path ##############################################
def drop_path(x, drop_prob: float = 0., t... | 7,938 | 35.417431 | 144 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/swin_mlp.py | # --------------------------------------------------------
# Swin Transformer
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ze Liu
# --------------------------------------------------------
import jittor as jt
from jittor import nn
from jittor import Module
fro... | 19,887 | 39.422764 | 118 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/ms_mlp.py | import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
from .utils import trunc_normal_, pair
############################################## Drop Path ##############################################
def drop_path(x, drop_prob: float = 0., training: bool = False):
"""
Obtain... | 16,952 | 41.171642 | 216 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/morph_mlp.py | import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
from .einops_my.layers.jittor import Rearrange
############################################## Drop Path ##############################################
def drop_path(x, drop_prob: float = 0., training: bool = False):
"""
... | 8,400 | 36.172566 | 187 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/wave_mlp.py | import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
from .utils import trunc_normal_
############################################## Drop Path ##############################################
def drop_path(x, drop_prob: float = 0., training: bool = False):
"""
Obtained fr... | 7,419 | 32.727273 | 120 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/cycle_mlp.py | import os
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from .utils import trunc_normal_
import math
from .utils import deform_conv2d_jt
from .utils import pair
import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
import collections
from itertools import ... | 17,408 | 35.420502 | 121 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/as_mlp.py | from .utils import trunc_normal_
import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
from .utils import pair
############################################## Drop Path ##############################################
def drop_path(x, drop_prob: float = 0., training: bool = False):... | 19,060 | 35.585413 | 119 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/conv_mlp.py | from torch.hub import load_state_dict_from_url
import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
__all__ = ['ConvMLP', 'convmlp_s', 'convmlp_m', 'convmlp_l']
model_urls = {
'convmlp_s': 'http://ix.cs.uoregon.edu/~alih/conv-mlp/checkpoints/convmlp_s_imagenet.pth',
'c... | 12,260 | 39.87 | 135 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/einops_my/einops.py | import functools
import itertools
import typing
from collections import OrderedDict
from typing import Tuple, List, Dict, Union, Callable, Optional, TypeVar
if typing.TYPE_CHECKING:
import numpy as np
from . import EinopsError
from ._backends import get_backend
from .parsing import ParsedExpression, _ellipsis, An... | 27,879 | 43.46571 | 120 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/einops_my/_backends.py | """
Backends in `einops` are organized to meet the following requirements
- backends are not imported unless those are actually needed, because
- backends may not be installed
- importing all available backends will drive to significant memory footprint
- backends may by present but installed with errors (b... | 21,099 | 29.535456 | 119 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/einops_my/_torch_specific.py | """
Specialization of einops for torch.
Unfortunately, torch's jit scripting mechanism isn't strong enough,
and to have scripting supported at least for layers,
a number of changes is required, and this layer helps.
Importantly, whole lib is designed so that you can't use it
"""
from typing import Dict, List
import... | 2,798 | 31.929412 | 115 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/einops_my/layers/torch.py | from typing import Optional, Dict
import torch
from . import RearrangeMixin, ReduceMixin
from ._einmix import _EinmixMixin
from .._torch_specific import apply_for_scriptable_torch
__author__ = 'Alex Rogozhnikov'
class Rearrange(RearrangeMixin, torch.nn.Module):
def forward(self, input):
return apply_fo... | 2,379 | 36.777778 | 105 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/einops_my/layers/keras.py | __author__ = 'Alex Rogozhnikov'
from ..layers.tensorflow import Rearrange, Reduce, EinMix
keras_custom_objects = {
Rearrange.__name__: Rearrange,
Reduce.__name__: Reduce,
EinMix.__name__: EinMix,
}
| 212 | 20.3 | 57 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/einops_my/layers/gluon.py | from typing import Optional, Dict
import mxnet
from . import RearrangeMixin, ReduceMixin
from ._einmix import _EinmixMixin
__author__ = 'Alex Rogozhnikov'
class Rearrange(RearrangeMixin, mxnet.gluon.HybridBlock):
def hybrid_forward(self, F, x):
return self._apply_recipe(x)
class Reduce(ReduceMixin, m... | 2,101 | 40.215686 | 101 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/einops_my/layers/tensorflow.py | from typing import List, Optional, Dict
import tensorflow as tf
from tensorflow.keras.layers import Layer
from .._backends import UnknownSize
from . import RearrangeMixin, ReduceMixin
from ._einmix import _EinmixMixin
from ..einops import TransformRecipe, _reconstruct_from_shape_uncached
__author__ = 'Alex Rogozhnik... | 3,269 | 37.023256 | 113 | py |
Jittor-MLP | Jittor-MLP-main/models_jittor/utils/init.py | import math
import warnings
import jittor as jt
def trunc_normal_(var, mean=0., std=1., a=-2., b=2.):
# type: (jt.jittor_core.Var, float, float, float, float) -> jt.jittor_core.Var
r"""Fills the input jt.jittor_core.Var with values drawn from a truncated
normal distribution. The values are effectively... | 2,403 | 38.409836 | 93 | py |
SEAL_OGB | SEAL_OGB-main/utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import sys
import math
from tqdm import tqdm
import random
import numpy as np
import scipy.sparse as ssp
from scipy.sparse.csgraph import shorte... | 14,462 | 37.060526 | 89 | py |
SEAL_OGB | SEAL_OGB-main/seal_link_pred.py | # Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import time
import os, sys
import os.path as osp
from shutil import copy
import copy as cp
from tqdm import tqdm
import pdb
imp... | 30,151 | 39.581427 | 95 | py |
SEAL_OGB | SEAL_OGB-main/models.py | # Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import numpy as np
import torch
from torch.nn import (ModuleList, Linear, Conv1d, MaxPool1d, Embedding, ReLU,
... | 11,317 | 37.893471 | 86 | py |
dsve-loc | dsve-loc-master/eval_retrieval.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 3,821 | 38.402062 | 159 | py |
dsve-loc | dsve-loc-master/text_features_extraction.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 3,377 | 37.386364 | 149 | py |
dsve-loc | dsve-loc-master/pointing_game.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 4,664 | 36.926829 | 153 | py |
dsve-loc | dsve-loc-master/train.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 9,467 | 38.949367 | 168 | py |
dsve-loc | dsve-loc-master/image_features_extraction.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 3,706 | 36.444444 | 147 | py |
dsve-loc | dsve-loc-master/semantic_seg.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 4,493 | 35.836066 | 147 | py |
dsve-loc | dsve-loc-master/misc/loss.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 3,016 | 37.679487 | 106 | py |
dsve-loc | dsve-loc-master/misc/utils.py | """
****************** COPYRIGHT AND CONFIDENTIALITY INFORMATION ******************
Copyright (c) 2018 [Thomson Licensing]
All Rights Reserved
This program contains proprietary information which is a trade secret/business \
secret of [Thomson Licensing] and is protected, even if unpublished, under \
applicable Copyrigh... | 5,609 | 29.994475 | 109 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.