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 |
|---|---|---|---|---|---|---|
FGSM-PGI | FGSM-PGI-master/ImageNet_models/dpn.py | '''Dual Path Networks in PyTorch.'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class Bottleneck(nn.Module):
def __init__(self, last_planes, in_planes, out_planes, dense_depth, stride, first_layer):
super(Bottleneck, self).__init__()
sel... | 3,609 | 34.742574 | 116 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/shufflenetv2.py | '''ShuffleNetV2 in PyTorch.
See the paper "ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class ShuffleBlock(nn.Module):
def __init__(self, groups=2):
super(ShuffleBlock, self).__init__()
... | 5,530 | 32.932515 | 107 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/regnet.py | '''RegNet in PyTorch.
Paper: "Designing Network Design Spaces".
Reference: https://github.com/keras-team/keras-applications/blob/master/keras_applications/efficientnet.py
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class SE(nn.Module):
'''Squeeze-and-Excitation block.'''
def __in... | 4,548 | 28.160256 | 106 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/efficientnet.py | '''EfficientNet in PyTorch.
Paper: "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks".
Reference: https://github.com/keras-team/keras-applications/blob/master/keras_applications/efficientnet.py
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
def swish(x):
return x ... | 5,719 | 31.5 | 106 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/pnasnet.py | '''PNASNet in PyTorch.
Paper: Progressive Neural Architecture Search
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class SepConv(nn.Module):
'''Separable Convolution.'''
def __init__(self, in_planes, out_planes, kernel_size, stride):
super(SepConv, self).__init__()
se... | 4,258 | 32.801587 | 105 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/resnet.py | '''ResNet in PyTorch.
For Pre-activation ResNet, see 'preact_resnet.py'.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. arXiv:1512.03385
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansi... | 4,219 | 30.729323 | 83 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/mobilenetv2.py | '''MobileNetV2 in PyTorch.
See the paper "Inverted Residuals and Linear Bottlenecks:
Mobile Networks for Classification, Detection and Segmentation" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''expand + depthwise + pointwise'''
def __init... | 3,092 | 34.551724 | 114 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/vgg.py | '''VGG11/13/16/19 in Pytorch.'''
import torch
import torch.nn as nn
cfg = {
'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
'VGG16': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512... | 1,442 | 29.0625 | 117 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/densenet.py | '''DenseNet in PyTorch.'''
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Bottleneck(nn.Module):
def __init__(self, in_planes, growth_rate):
super(Bottleneck, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)
self.conv1 = nn.Conv2d(in_planes, 4*gr... | 3,542 | 31.805556 | 96 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/preact_resnet.py | '''Pre-activation ResNet in PyTorch.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Identity Mappings in Deep Residual Networks. arXiv:1603.05027
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class PreActBlock(nn.Module):
'''Pre-activation version of the BasicBlock.... | 4,078 | 33.277311 | 102 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/googlenet.py | '''GoogLeNet with PyTorch.'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Inception(nn.Module):
def __init__(self, in_planes, n1x1, n3x3red, n3x3, n5x5red, n5x5, pool_planes):
super(Inception, self).__init__()
# 1x1 conv branch
self.b1 = nn.Sequential(
... | 3,221 | 28.833333 | 83 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/resnext.py | '''ResNeXt in PyTorch.
See the paper "Aggregated Residual Transformations for Deep Neural Networks" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''Grouped convolution block.'''
expansion = 2
def __init__(self, in_planes, cardinality=32... | 3,478 | 35.239583 | 129 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/senet.py | '''SENet in PyTorch.
SENet is the winner of ImageNet-2017. The paper is not released yet.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(... | 4,027 | 32.016393 | 102 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/shufflenet.py | '''ShuffleNet in PyTorch.
See the paper "ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class ShuffleBlock(nn.Module):
def __init__(self, groups):
super(ShuffleBlock, self).__init... | 3,542 | 31.209091 | 126 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/wide_resnet.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
super(BasicBlock, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)
self.relu1 = nn.ReLU(inplace=True)
se... | 3,898 | 41.380435 | 116 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/lenet.py | '''LeNet in PyTorch.'''
import torch.nn as nn
import torch.nn.functional as F
class LeNet(nn.Module):
def __init__(self):
super(LeNet, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16*5*5, 120)
self.fc2 = nn.Linear... | 699 | 28.166667 | 43 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/mobilenet.py | '''MobileNet in PyTorch.
See the paper "MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications"
for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Block(nn.Module):
'''Depthwise conv + Pointwise conv'''
def __init__(self, in_planes, out_... | 2,025 | 31.677419 | 123 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/dpn.py | '''Dual Path Networks in PyTorch.'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Bottleneck(nn.Module):
def __init__(self, last_planes, in_planes, out_planes, dense_depth, stride, first_layer):
super(Bottleneck, self).__init__()
self.out_planes = out_planes
sel... | 3,562 | 34.989899 | 116 | py |
FGSM-PGI | FGSM-PGI-master/Cifar100_models/DRN.py | import torch
import torch.nn as nn
from torch.nn import functional as F
class DSN(nn.Module):
"""Deep Summarization Network"""
def __init__(self, in_dim=1024, hid_dim=256, num_layers=1, cell='lstm'):
super(DSN, self).__init__()
assert cell in ['lstm', 'gru'], "cell must be either 'lstm' or 'gr... | 729 | 33.761905 | 108 | py |
gaussian-ram | gaussian-ram-master/inference.py | import torch.utils.data
from torchvision import datasets, transforms
from model import GDRAM
from dataloader import MnistClutteredDataset
import time
import argparse
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() ... | 3,516 | 29.582609 | 131 | py |
gaussian-ram | gaussian-ram-master/modules.py | import torch
import torch.nn as nn
from torch.nn import functional as F
import cv2
import numpy as np
class GlimpseNetwork(nn.Module):
def __init__(self, input_channel, glimpse_size, location_size, internal_size, output_size):
super(GlimpseNetwork, self).__init__()
self.fc_g = nn.Sequential(
... | 5,479 | 25.731707 | 99 | py |
gaussian-ram | gaussian-ram-master/dataloader.py | import numpy as np
import matplotlib.pyplot as plt
from torch.utils.data import Dataset, DataLoader
import torch
from skimage import io
from torchvision import transforms
from PIL import Image
import pandas as pd
class MnistClutteredDataset(Dataset):
def __init__(self, data_path, type, transform=None):
s... | 848 | 23.257143 | 68 | py |
gaussian-ram | gaussian-ram-master/utils.py | import matplotlib
matplotlib.use('agg')
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import torch
from torch.nn import functional as F
from torchvision.utils import save_image
import numpy as np
import os
def get_glimpse(x, l, ou... | 2,697 | 28.010753 | 89 | py |
gaussian-ram | gaussian-ram-master/model.py | import torch
from torch import nn
from modules import *
from utils import get_glimpse
import math
class GDRAM(nn.Module):
def __init__(self, device=None, dataset=None, Fast=False):
super(GDRAM, self).__init__()
self.glimpse_size = 12
self.num_scales = 4
self.img_size = 128
... | 3,910 | 29.554688 | 137 | py |
gaussian-ram | gaussian-ram-master/train.py | import argparse
import numpy as np
import torch
from torch import nn, optim
from torch.nn import functional as F
import torch.utils.data
from torchvision import datasets, transforms
from torch.utils.data.sampler import SubsetRandomSampler
import torchvision
from model import GDRAM
from utils import draw_locations
from ... | 7,916 | 35.483871 | 137 | py |
mmdeploy | mmdeploy-master/setup.py | import os
from setuptools import find_packages, setup
EXT_TYPE = ''
try:
from torch.utils.cpp_extension import BuildExtension
cmd_class = {'build_ext': BuildExtension}
EXT_TYPE = 'torch'
except ModuleNotFoundError:
cmd_class = {}
print('Skip building ext ops due to the absence of torch.')
pwd = os... | 7,731 | 35.819048 | 125 | py |
mmdeploy | mmdeploy-master/tools/torch2onnx.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import logging
import os
import os.path as osp
from mmdeploy.apis import (extract_model, get_predefined_partition_cfg,
torch2onnx)
from mmdeploy.utils import (get_ir_config, get_partition_config,
get_... | 2,794 | 31.5 | 73 | py |
mmdeploy | mmdeploy-master/tools/generate_md_table.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import yaml
from easydict import EasyDict as edict
from mmdeploy.utils import get_backend, get_task_type, load_config
def parse_args():
parser = argparse.ArgumentParser(
description='from yaml export markdown... | 2,778 | 32.890244 | 78 | py |
mmdeploy | mmdeploy-master/tools/deploy.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import logging
import os
import os.path as osp
from functools import partial
import mmcv
import torch.multiprocessing as mp
from torch.multiprocessing import Process, set_start_method
from mmdeploy.apis import (create_calib_input_data, extract_model,
... | 10,432 | 32.763754 | 97 | py |
mmdeploy | mmdeploy-master/tools/regression_test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import logging
import os
import subprocess
from pathlib import Path
from typing import List
import mmcv
import openpyxl
import pandas as pd
import yaml
from torch.hub import download_url_to_file
from torch.multiprocessing import set_start_method
import m... | 37,285 | 35.990079 | 79 | py |
mmdeploy | mmdeploy-master/tools/quant_image_dataset.py | # Copyright (c) OpenMMLab. All rights reserved.
from typing import Optional, Sequence
import mmcv
from mmcv import FileClient
from torch.utils.data import Dataset
from mmdeploy.utils import Codebase, get_codebase
class QuantizationImageDataset(Dataset):
def __init__(
self,
path: str,
de... | 3,407 | 36.866667 | 77 | py |
mmdeploy | mmdeploy-master/tools/profiler.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import glob
import os.path as osp
import numpy as np
import torch
from mmcv import DictAction
from prettytable import PrettyTable
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import get_root_logger
from mmdeploy.utils.config_utils i... | 5,738 | 33.572289 | 79 | py |
mmdeploy | mmdeploy-master/tools/onnx2ncnn_quant_table.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import logging
from mmcv import Config
from mmdeploy.utils import Task, get_root_logger, get_task_type, load_config
def get_table(onnx_path: str,
deploy_cfg: Config,
model_cfg: Config,
output_onnx_path: str,
... | 4,577 | 34.215385 | 79 | py |
mmdeploy | mmdeploy-master/tools/package_tools/mmdeploy_builder.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import logging
import os
import os.path as osp
import platform
import re
import shutil
import sys
from glob import glob
from subprocess import check_output, run
from typing import Dict
import yaml
from packaging import version
logger = loggin... | 16,427 | 32.942149 | 79 | py |
mmdeploy | mmdeploy-master/tools/scripts/build_ubuntu_x64_torchscript.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import sys
import time
from pathlib import Path
from ubuntu_utils import (cmd_result, cu_version_name, ensure_base_env,
get_job, pytorch_version)
g_jobs = 2
def install_libtorch(dep_dir):
print('-' * 10 + 'install libtorch' + '-... | 4,034 | 30.27907 | 169 | py |
mmdeploy | mmdeploy-master/tools/scripts/ubuntu_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import re
import time
def pytorch_version():
version = None
try:
import torch
raw = torch.__version__
pattern = re.compile(r'[0-9]+\.[0-9]+\.[0-9]+')
version = pattern.findall(raw)[0]
except Exception:
pass
... | 7,441 | 29.008065 | 105 | py |
mmdeploy | mmdeploy-master/tools/scripts/build_ubuntu_x64_tvm.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import sys
import time
from ubuntu_utils import cmd_result, ensure_base_env, get_job
def install_llvm(dep_dir):
print('-' * 10 + 'install llvm' + '-' * 10)
os.chdir(dep_dir)
os.system(
'wget --no-check-certificate -O... | 4,936 | 29.103659 | 169 | py |
mmdeploy | mmdeploy-master/tools/scripts/build_ubuntu_x64_ncnn.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import sys
import time
from pathlib import Path
from ubuntu_utils import cmd_result, ensure_base_env, get_job
g_jobs = 2
def install_protobuf(dep_dir) -> int:
"""build and install protobuf. protobuf seems not support repeated install,
so clean build ... | 6,055 | 31.55914 | 169 | py |
mmdeploy | mmdeploy-master/tools/scripts/build_ubuntu_x64_ort.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import sys
import time
from pathlib import Path
from ubuntu_utils import ensure_base_env, get_job
g_jobs = 2
def install_ort(dep_dir):
print('-' * 10 + 'install ort' + '-' * 10)
time.sleep(2)
# generate unzip and build dir
os.chdir(dep_dir)
... | 3,118 | 28.704762 | 169 | py |
mmdeploy | mmdeploy-master/tools/scripts/build_ubuntu_x64_pplnn.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import sys
import time
from pathlib import Path
from ubuntu_utils import cmd_result, ensure_base_env, get_job
g_jobs = 2
def install_pplcv(dep_dir, build_cuda):
print('-' * 10 + 'install pplcv' + '-' * 10)
time.sleep(2)
os.chdir(dep_dir)
pp... | 4,808 | 28.869565 | 169 | py |
mmdeploy | mmdeploy-master/tests/test_backend/test_wrapper.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import subprocess
import tempfile
import pytest
import torch
import torch.nn as nn
from mmdeploy.utils.constants import Backend
from mmdeploy.utils.test import check_backend
onnx_file = tempfile.NamedTemporaryFile(suffix='.onnx').name
ts_file = te... | 7,512 | 32.540179 | 76 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmpose/test_pose_detection.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import DummyModel, SwitchBackendWrapper
model_cfg_path = 'tests/test_codebase/test_mmpose/... | 4,450 | 31.021583 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmpose/test_mmpose_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, Codebase, Task
from mmdeploy.utils.test import WrapModel, check_backend, get_rewrite_outputs
@pytest.fixture
def top_down_heatmap_simple_head_model():
from mmpose.models.h... | 11,579 | 38.121622 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmpose/test_pose_detection_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, Codebase
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
IMAGE_H = 192
IMAGE_W = 256
@backend_checker(Backend.ONNXRUNTIME)
class ... | 3,604 | 35.414141 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmedit/test_super_resolution.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import tempfile
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import SwitchBackendWrapper
@pytest.fixture(scope='module')
def model_cfg... | 4,157 | 30.5 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmedit/test_inpainting_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, load_config
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
@backend_checker(Backend.ONNXRUNTIME)
class TestEnd2EndModel:
@pytest.fixture(scope='cla... | 1,739 | 34.510204 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmedit/test_mmedit_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
from typing import Dict
import mmcv
import onnx
import pytest
import torch
from mmdeploy.core import RewriterContext
from mmdeploy.utils import Backend, get_onnx_config
@pytest.fixture
def img():
return torch.rand(1, 3, 4, 4)
@pytest.fixtur... | 2,461 | 28.309524 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmedit/test_inpainting.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import tempfile
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import SwitchBackendWrapper
@pytest.fixture(scope='module')
def model_cfg... | 4,261 | 32.03876 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmedit/test_super_resolution_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, load_config
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
@backend_checker(Backend.ONNXRUNTIME)
class TestEnd2EndModel:
@pytest.fixture(scope='cla... | 1,618 | 33.446809 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmrotate/test_mmrotate_core.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.test import (WrapFunction, WrapModel, backend_checker,
check_backend, get_onnx_model,
get_re... | 14,615 | 34.823529 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmrotate/test_mmrotate_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import os
import random
from typing import Dict, List
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.config_utils import get_ir_config
from mmdeploy.utils.test import (WrapModel, check_backend... | 23,057 | 32.661314 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmrotate/test_rotated_detection_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, load_config
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
IMAGE_SIZE = 32
@backend_checker(Backend.ONNXRUNTIME)
class TestEnd2E... | 3,476 | 35.21875 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmrotate/test_rotated_detection.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import mmcv
import numpy as np
import pytest
import torch
from torch.utils.data import DataLoader
from torch.utils.data.dataset import Dataset
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import... | 4,958 | 29.801242 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmrotate/data/model.py | # Copyright (c) OpenMMLab. All rights reserved.
model = dict(
type='RotatedRetinaNet',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
zero_init_residual=False,
norm_cfg=dict(type='BN', requires_grad=True),
... | 2,876 | 28.659794 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet/test_mmdet_utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import torch
from mmdeploy.codebase.mmdet.deploy import (clip_bboxes,
get_post_processing_params,
pad_with_value,
... | 1,942 | 31.383333 | 72 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet/test_object_detection_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
from typing import Sequence
import mmcv
import numpy as np
import pytest
import torch
import mmdeploy.backend.onnxruntime as ort_apis
from mmdeploy.codebase.mmdet.deploy.object_detection_model import End2EndModel
from mmdeploy.utils import Backend
... | 20,679 | 35.344464 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet/test_mmdet_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import os
import random
from typing import Dict, List
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.config_utils import get_ir_config
from mmdeploy.utils.test import (WrapModel, backend_check... | 67,293 | 35.572826 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet/test_object_detection.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import os
from typing import Any
import mmcv
import numpy as np
import pytest
import torch
from torch.utils.data import DataLoader
from torch.utils.data.dataset import Dataset
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_con... | 7,648 | 33.61086 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet/test_mmdet_core.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.core.rewriters.rewriter_manager import RewriterContext
from mmdeploy.utils import Backend
from mmdeploy.utils.test import (WrapFunction, WrapModel, backend_checker,
... | 13,329 | 33.35567 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmcls/test_classification.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import os
from typing import Any
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import DummyModel, SwitchBackendWrapper
model_cfg_path ... | 5,245 | 32.414013 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmcls/test_mmcls_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.core import RewriterContext
from mmdeploy.utils import Backend
from mmdeploy.utils.test import WrapModel, check_backend, get_rewrite_outputs
input = torch.rand(1)
@pytest.fixture(scope='module')
d... | 10,146 | 33.75 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmcls/test_classification_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
NUM_CLASS = 1000
IMAGE_SIZE = 64
@backend_checker(Backend.ONNXRUNTIME)
class TestE... | 5,370 | 33.429487 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmcls/data/model.py | # Copyright (c) OpenMMLab. All rights reserved.
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(3, ),
style='pytorch'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='Linea... | 1,212 | 28.585366 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmseg/test_mmseg_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmcv import ConfigDict
from mmseg.models import BACKBONES, HEADS
from mmseg.models.decode_heads.decode_head import BaseDecodeHead
from mmdeploy.utils import Backend, Codebase, Task
from ... | 10,621 | 32.720635 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmseg/test_segmentation_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
NUM_CLASS = 19
IMAGE_SIZE = 32
@backend_checker(Backend.ONNXRUNTIME)
class TestEnd... | 5,876 | 33.982143 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmseg/test_segmentation.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import os
from typing import Any
import mmcv
import numpy as np
import pytest
import torch
from torch.utils.data import DataLoader
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import DummyMode... | 5,142 | 32.180645 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet3d/test_mmdet3d_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, Codebase, Task, load_config
from mmdeploy.utils.test import WrapModel, check_backend, get_rewrite_outputs
@pytest.fixture(scope='module')
def model_cfg():
ret... | 9,078 | 36.36214 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet3d/test_monocular_detection_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import pytest
import torch
from mmdeploy.codebase.mmdet3d.deploy.monocular_detection_model import (
MonocularDetectionModel, build_monocular_detection_model)
from mmdeploy.utils import Backend, Codebase
from mmdeploy.utils.test impo... | 4,074 | 36.385321 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet3d/test_monocular_detection.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import mmcv
import pytest
import torch
from torch.utils.data import DataLoader
from torch.utils.data.dataset import Dataset
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import DummyModel, Switch... | 6,068 | 32.163934 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet3d/test_voxel_detection_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import pytest
import torch
from mmdeploy.codebase.mmdet3d.deploy.voxel_detection import VoxelDetection
from mmdeploy.utils import Backend, Codebase
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
pcd_path = 'tests... | 3,536 | 37.445652 | 76 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet3d/test_voxel_detection.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import mmcv
import pytest
import torch
from torch.utils.data import DataLoader
from torch.utils.data.dataset import Dataset
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import DummyModel, Switch... | 5,437 | 31.562874 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmdet3d/data/monodet_model_cfg.py | # Copyright (c) OpenMMLab. All rights reserved.
dataset_type = 'NuScenesMonoDataset'
data_root = 'tests/test_codebase/test_mmdet3d/data/nuscenes/'
class_names = [
'car', 'truck', 'trailer', 'bus', 'construction_vehicle', 'bicycle',
'motorcycle', 'pedestrian', 'traffic_cone', 'barrier'
]
input_modality = dict(
... | 10,260 | 33.665541 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmocr/test_mmocr_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pytest
import torch
from mmocr.models.textdet.necks import FPNC
from mmdeploy.core import RewriterContext, patch_model
from mmdeploy.utils import Backend
from mmdeploy.utils.test import (WrapModel, check_backend, get_model_outputs,
... | 17,287 | 31.557439 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmocr/test_text_recognition.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import mmcv
import numpy as np
import pytest
import torch
from torch.utils.data import DataLoader
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import DummyModel, SwitchBackendWrapper
model_cfg_... | 3,965 | 29.744186 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmocr/test_text_detection.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import mmcv
import numpy as np
import pytest
import torch
from torch.utils.data import DataLoader
from mmdeploy.apis import build_task_processor
from mmdeploy.utils import load_config
from mmdeploy.utils.test import DummyModel, SwitchBackendWrapper
model_cfg_... | 4,016 | 29.9 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmocr/test_text_detection_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, load_config
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
IMAGE_SIZE = 32
@backend_checker(Backend.ONNXRUNTIME)
class TestEnd2E... | 3,458 | 35.410526 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmocr/test_text_recognition_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import numpy as np
import pytest
import torch
from mmdeploy.utils import Backend, load_config
from mmdeploy.utils.test import SwitchBackendWrapper, backend_checker
IMAGE_SIZE = 32
@backend_checker(Backend.ONNXRUNTIME)
class TestEnd2E... | 3,443 | 35.252632 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_codebase/test_mmocr/data/dbnet.py | # Copyright (c) OpenMMLab. All rights reserved.
model = dict(
type='DBNet',
backbone=dict(
type='mmdet.ResNet',
depth=18,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=-1,
norm_cfg=dict(type='BN', requires_grad=True),
init_cfg=dict(type='Pretrained... | 1,660 | 31.568627 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_mmcv/test_mmcv_ops.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import onnx
import pytest
import torch
from mmdeploy.core import RewriterContext
from mmdeploy.utils import Backend
from mmdeploy.utils.test import WrapFunction, check_backend
try:
from torch.testing import assert_close as torch_assert_close
except ... | 5,355 | 36.194444 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_mmcv/test_mmcv_cnn.py | # Copyright (c) OpenMMLab. All rights reserved.
from __future__ import division
import mmcv
import torch
from mmdeploy.utils import Backend
from mmdeploy.utils.test import check_backend, get_rewrite_outputs
def test_multiheadattention_ncnn():
check_backend(Backend.NCNN)
from mmcv.cnn.bricks.transformer impo... | 3,692 | 28.544 | 71 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_torch2torchscript.py | # Copyright (c) OpenMMLab. All rights reserved.
import importlib
import os.path as osp
import tempfile
import mmcv
import pytest
from mmdeploy.apis import torch2torchscript
from mmdeploy.utils import IR, Backend
from mmdeploy.utils.test import get_random_name
ts_file = tempfile.NamedTemporaryFile(suffix='.pt').name
... | 2,782 | 30.269663 | 72 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_torch2onnx.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import mmcv
import onnx
import pytest
import torch
import torch.nn as nn
from mmdeploy.apis.onnx import export
from mmdeploy.utils.config_utils import (get_backend, get_dynamic_axes,
get_onnx... | 3,115 | 28.961538 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_onnx2rknn.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import mmcv
import pytest
import torch
import torch.nn as nn
from mmdeploy.utils import Backend
from mmdeploy.utils.test import backend_checker
onnx_file = tempfile.NamedTemporaryFile(suffix='.onnx').name
test_img = torch.rand([1, ... | 1,688 | 23.838235 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_onnx2tvm.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import pytest
import torch
import torch.nn as nn
from mmdeploy.utils import Backend
from mmdeploy.utils.test import backend_checker
onnx_file = tempfile.NamedTemporaryFile(suffix='.onnx').name
test_img = torch.rand([1, 3, 8, 8])
... | 2,949 | 26.830189 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_onnx2tensorrt.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import mmcv
import pytest
import torch
import torch.nn as nn
from mmdeploy.utils import Backend
from mmdeploy.utils.test import backend_checker
onnx_file = tempfile.NamedTemporaryFile(suffix='.onnx').name
engine_file = tempfile.Nam... | 2,383 | 25.488889 | 70 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_extract.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import onnx
import torch
from mmdeploy.apis.onnx import extract_partition
from mmdeploy.core import mark
output_file = tempfile.NamedTemporaryFile(suffix='.onnx').name
def test_extract():
@mark('add', outputs='z')
def add(x, y):
retur... | 970 | 22.119048 | 72 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_calibration.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
from multiprocessing import Process
import mmcv
import pytest
from mmdeploy.apis import create_calib_input_data
calib_file = tempfile.NamedTemporaryFile(suffix='.h5').name
ann_file = 'tests/data/annotation.json'
@pytest.fixture
d... | 8,149 | 32.817427 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_onnx_passes.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
from typing import Any, List, Tuple
import onnx
import pytest
import torch
import torch.nn as nn
from mmdeploy.apis.onnx.optimizer import \
model_to_graph__custom_optimizer # noqa
from mmdeploy.core import RewriterContext
onnx_file = tempfile.Named... | 7,799 | 25.712329 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_onnx2openvino.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import tempfile
import mmcv
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmdeploy.utils import Backend
from mmdeploy.utils.test import backend_checker, get_random_name
@pytest.mark.skip(reason='This a not tes... | 5,873 | 31.815642 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_onnx2ascend.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import mmcv
import pytest
import torch
import torch.nn as nn
from mmdeploy.utils import Backend
from mmdeploy.utils.test import backend_checker
onnx_file = tempfile.NamedTemporaryFile(suffix='.onnx').name
test_img = torch.rand([1, ... | 1,779 | 23.722222 | 70 | py |
mmdeploy | mmdeploy-master/tests/test_apis/test_onnx2ncnn.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import pytest
import torch
import torch.nn as nn
from mmdeploy.backend.ncnn.onnx2ncnn import get_output_model_file
from mmdeploy.utils import Backend
from mmdeploy.utils.test import backend_checker
onnx_file = tempfile.NamedTempora... | 1,751 | 24.391304 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_utils/test_util.py | # Copyright (c) OpenMMLab. All rights reserved.
import importlib
import logging
import os
import tempfile
from functools import partial
import mmcv
import pytest
import torch.multiprocessing as mp
import mmdeploy.utils as util
from mmdeploy.backend.sdk.export_info import export2SDK
from mmdeploy.utils import target_w... | 14,889 | 30.281513 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_ops/utils.py | # Copyright (c) OpenMMLab. All rights reserved.
import os
import subprocess
import tempfile
import mmcv
import onnx
import torch
import mmdeploy.apis.tensorrt as trt_apis
from mmdeploy.utils import Backend
from mmdeploy.utils.test import assert_allclose, check_backend
class TestOnnxRTExporter:
__test__ = False
... | 9,828 | 37.096899 | 78 | py |
mmdeploy | mmdeploy-master/tests/test_ops/test_ops.py | # Copyright (c) OpenMMLab. All rights reserved.
import onnx
import pytest
import torch
import torch.nn as nn
from mmcv import Config
from onnx.helper import (make_graph, make_model, make_node,
make_tensor_value_info)
from mmdeploy.core import RewriterContext
from mmdeploy.utils.test import Wra... | 42,678 | 42.461303 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_pytorch/test_pytorch_ops.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import onnx
import pytest
import torch
from mmcv import Config
from mmdeploy.core import RewriterContext
onnx_file = tempfile.NamedTemporaryFile(suffix='onnx').name
@pytest.fixture(autouse=False, scope='function')
def prepare_symbolics():
with Rew... | 5,230 | 29.236994 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_pytorch/test_pytorch_functions.py | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import mmcv
import numpy as np
import pytest
import torch
import torch.nn.functional as F
from packaging.version import parse
from mmdeploy.utils import Backend
from mmdeploy.utils.test import (WrapFunction, backend_checker,
... | 17,557 | 31.394834 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_core/test_module_rewriter.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmdeploy.core import MODULE_REWRITER, patch_model
try:
from torch.testing import assert_close as torch_assert_close
except Exception:
from torch.testing import assert_allclose as torch_assert_close
def test_module_rewriter():
from torchvi... | 2,063 | 29.80597 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_core/test_symbolic_register.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import onnx
import pytest
import torch
from torch.autograd import Function
import mmdeploy
from mmdeploy.core import SYMBOLIC_REWRITER, RewriterContext
from mmdeploy.core.rewriters.symbolic_rewriter import SymbolicRewriter
output_file = tempfile.NamedTe... | 5,366 | 30.385965 | 77 | py |
mmdeploy | mmdeploy-master/tests/test_core/test_mark.py | # Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import onnx
import torch
from mmdeploy.core import RewriterContext, mark
from mmdeploy.core.optimizers import attribute_to_dict
from mmdeploy.utils.constants import IR, Backend
output_file = tempfile.NamedTemporaryFile(suffix='.onnx').name
def test_ma... | 1,904 | 23.423077 | 79 | py |
mmdeploy | mmdeploy-master/tests/test_core/test_function_rewriter.py | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmdeploy.core import FUNCTION_REWRITER, RewriterContext
from mmdeploy.core.rewriters.function_rewriter import FunctionRewriter
from mmdeploy.core.rewriters.rewriter_utils import collect_env
from mmdeploy.utils.constants import IR, Backend
... | 5,595 | 27.55102 | 78 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.