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 |
|---|---|---|---|---|---|---|
wgenpatex | wgenpatex-main/run_cnn_synthesis.py | import argparse
import wgenpatex
import model
import torch
parser = argparse.ArgumentParser()
parser.add_argument('target_image_path', help='paths of target texture image')
parser.add_argument('-w', '--patch_size', type=int,default=4, help="patch size (default: 4)")
parser.add_argument('-nmax', '--n_iter_max', type=in... | 1,562 | 54.821429 | 188 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/combination_energy.py | import torch as tc
import torch.nn as nn
import matplotlib.pyplot as plt
from tqdm import tqdm
from utils import set_random_seed
import pdb
import sklearn
import sklearn.decomposition
from matplotlib.patches import ConnectionPatch
set_random_seed(233)
def F_norm(Y):
return (Y ** 2).sum()
n = 500
d = 128
W1 = tc.... | 3,850 | 24.335526 | 125 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/divergence.py | import torch as tc
import torch.nn as nn
import matplotlib.pyplot as plt
from tqdm import tqdm
from utils import set_random_seed
import pdb
import sklearn
import sklearn.decomposition
import scipy.spatial as spt
import itertools
set_random_seed(23333)
def norm(x):
return (x ** 2).sum(-1) ** 0.5
W = tc.randn(2,2)... | 1,504 | 19.902778 | 67 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/utils.py | import random
import torch as tc
import numpy as np
def set_random_seed(seed):
random.seed(seed)
np.random.seed(seed)
tc.manual_seed(seed)
tc.cuda.manual_seed_all(seed)
tc.backends.cudnn.deterministic = True
tc.backends.cudnn.benchmark = False
| 269 | 21.5 | 42 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/apollo_circle.py | import torch as tc
import torch.nn as nn
import matplotlib.pyplot as plt
from tqdm import tqdm
from utils import set_random_seed
import pdb
import sklearn
import sklearn.decomposition
import scipy.spatial as spt
import itertools
set_random_seed(23333)
def norm(x):
return (x ** 2).sum(-1) ** 0.5
def paint(xf,xh,C... | 1,370 | 25.365385 | 81 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/energy_curve/main.py | from model import Transformer
import torch as tc
import torch.nn as nn
import torch.nn.functional as F
from fastNLP.io import IMDBLoader
from fastNLP.io import IMDBPipe
from fastNLP.embeddings import StaticEmbedding
import pdb
import pickle
from pathlib import Path
import matplotlib.pyplot as plt
from load_data import ... | 1,428 | 24.517857 | 64 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/energy_curve/paint.py | from model import Transformer
import torch as tc
import torch.nn as nn
import torch.nn.functional as F
from fastNLP.io import IMDBLoader
from fastNLP.io import IMDBPipe
from fastNLP.embeddings import StaticEmbedding
import pdb
import pickle
from pathlib import Path
import matplotlib.pyplot as plt
from load_data import ... | 2,092 | 28.069444 | 85 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/energy_curve/model.py | import torch as tc
import torch.nn as nn
import torch.nn.functional as F
import pdb
alpha_1 = 1
alpha_2 = 1
def norm2(X):
return (X ** 2).sum()
def inner(x,y):
return (x.view(-1) * y.view(-1)).sum()
idxs_cache = {}
class Attention(nn.Module):
def __init__(self , d):
super().__init__()
... | 4,459 | 21.989691 | 90 | py |
Transformers-From-Optimization | Transformers-From-Optimization-main/energy_curve/load_data.py | from model import Transformer
import torch as tc
import torch.nn as nn
import torch.nn.functional as F
from fastNLP.io import IMDBLoader , SST2Loader
from fastNLP.io import IMDBPipe , SST2Pipe
from fastNLP.embeddings import StaticEmbedding
import pdb
import pickle
from pathlib import Path
import matplotlib.pyplot as pl... | 1,638 | 29.351852 | 82 | py |
pybullet-gym | pybullet-gym-master/pybulletgym/agents/agents_kerasrl.py | # with some extra arg parsing
from keras.models import Sequential, Model # The Sequential model is a sequential, feed-forward stack of layers.
from keras.layers import Dense, Activation, Flatten, Input, merge # Different types of layers
from keras.optimizers import Adam # A special type of optimizer
from rl.agents.ce... | 12,858 | 36.272464 | 194 | py |
pybullet-gym | pybullet-gym-master/pybulletgym/agents/__init__.py | # ---- register agents ----------
import agent_register
# agent_register.register(
# id='BaselinesDQNAgent-v0',
# entry_point='agents_baselines:BaselinesDQNAgent'
# )
agent_register.register(
id='KerasCEMAgent-v0',
entry_point='pybullet_envs.agents.agents_kerasrl:KerasCEMAgent'
)
agent_register.register(
id='Ke... | 912 | 24.361111 | 102 | py |
dilran | dilran-main/inference.py | # inference fused image
import os
import argparse
import torch
import torch.nn as nn
import sys
from torchmetrics import PeakSignalNoiseRatio
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
from models.model_v5 import *
from our_utils import *
from eval import psnr, ssim, mutual_information
fr... | 4,455 | 29.944444 | 119 | py |
dilran | dilran-main/val.py | # Validation script for the project
# Validate a trained medical image fusion model
# Author: Reacher, last modify Nov. 28, 2022
'''
Change log:
Reacher: file created
'''
from evaluation_metrics import *
# run validation for every epoch
import os
import argparse
import torch
import torch.nn as nn
from torchmetrics... | 3,651 | 30.756522 | 92 | py |
dilran | dilran-main/evaluation_metrics.py | # Evaluation Metrics and get results
# Author: Reacher Z., last modify Nov. 26, 2022
"""
Change log:
- Reacher: file created, implement PSNR, SSIM, NMI, MI
"""
import numpy as np
import torch
from skimage.metrics import peak_signal_noise_ratio, normalized_mutual_information
from scipy.stats import entropy
from torch... | 7,123 | 37.717391 | 117 | py |
dilran | dilran-main/train_with_val.py | # Training script for the project
# Author: Simon Zhou, last modify Nov. 18, 2022
'''
Change log:
-Simon: file created, write some training code
-Simon: refine training script
-Reacher: train v3
'''
import argparse
import os
import sys
sys.path.append("../")
from tqdm import trange
import numpy as np
import torch
i... | 8,409 | 35.885965 | 109 | py |
dilran | dilran-main/train_with_pair.py | # Training script for the project
# Author: Simon Zhou, last modify Nov. 18, 2022
'''
Change log:
-Simon: file created, write some training code
-Simon: refine training script
-Reacher: train v3
-Reacher: add model choice
-Simon: train with paired images, use FL1N fusion strategy
'''
import argparse
import sys
sys.p... | 9,453 | 34.810606 | 112 | py |
dilran | dilran-main/loss.py | # Loss functions for the project
# Author: Reacher Z., last modify Nov. 18, 2022
"""
Change log:
- Reacher: file created, implement L1 loss and L2 loss function
- Reacher: update image gradient calculation
- Simon: update image gradient loss
- Simon: add loss_func2, and L1_Charbonnier_loss
"""
import numpy as np
imp... | 5,123 | 32.272727 | 105 | py |
dilran | dilran-main/model.py |
# Model Architecture
# Author: Landy Xu, created on Nov. 12, 2022
# Last modified by Simon on Nov. 13
'''
Change log:
- Landy: create feature extractor and DILRAN
- Simon: revise some writing style of module configs (e.g., replace = True),
refine the FE module, add recon module
- Simon: create full model pipeline
-... | 7,479 | 35.847291 | 124 | py |
dilran | dilran-main/model_v5.py |
# Model Architecture
# Author: Landy Xu, created on Nov. 12, 2022
# Last modified by Simon on Nov. 13
# Version 2: add attention to shallow feature, change first conv to 1x1 kernal
'''
Change log:
- Landy: create feature extractor and DILRAN
- Simon: revise some writing style of module configs (e.g., replace = True)... | 8,819 | 37.017241 | 126 | py |
dilran | dilran-main/dataset_loader.py | # Get dataloader for MRI-CT data
# Author: Simon Zhou, last modify Nov. 11, 2022
'''
Change log:
- Simon: file created, implement dataset loader
'''
import os
import sys
import numpy as np
import torch
from torch.utils.data import DataLoader, random_split, Dataset
import skimage.io as io
class getIndex(Dataset):
... | 4,508 | 31.207143 | 101 | py |
dilran | dilran-main/eval.py | # Evaluation Metrics and get results
# Author: Reacher Z., last modify Nov. 26, 2022
"""
Change log:
- Reacher: file created, implement PSNR, SSIM, NMI, MI
"""
import numpy as np
import sklearn.metrics as skm
import torch
from skimage.metrics import peak_signal_noise_ratio, normalized_mutual_information
from torchme... | 3,094 | 35.411765 | 110 | py |
dilran | dilran-main/our_utils.py | # helper functions for the project
# Author: Simon Zhou, last modify Nov. 15, 2022
'''
Change log:
- Simon: file created, implement edge detector
- Simon: create helper function for perceptual loss
- Reacher: create fusion strategy function
- Simon: add random seed func for seeding
'''
import torch
import torch.nn ... | 6,597 | 28.855204 | 125 | py |
dilran | dilran-main/train.py | # Training script for the project
# Author: Simon Zhou, last modify Nov. 18, 2022
'''
Change log:
-Simon: file created, write some training code
-Simon: refine training script
'''
import argparse
import os
import sys
sys.path.append("../")
from tqdm import trange
import numpy as np
import torch
import torch.nn as nn... | 7,150 | 36.439791 | 144 | py |
audio-text_retrieval | audio-text_retrieval-main/train.py | #!/usr/bin/env python3
# coding: utf-8
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
import os
import argparse
import torch
from trainer.trainer import train
from tools.config_loader import get_config
if __name__ == '__main__':
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
... | 1,980 | 35.685185 | 73 | py |
audio-text_retrieval | audio-text_retrieval-main/trainer/trainer.py | #!/usr/bin/env python3
# coding: utf-8
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
import platform
import sys
import time
import numpy as np
import torch
from tqdm import tqdm
from pathlib import Path
from loguru import logger
from pprint import PrettyPrinter
from torch.utils.t... | 7,788 | 36.628019 | 120 | py |
audio-text_retrieval | audio-text_retrieval-main/tools/loss.py | #!/usr/bin/env python3
# coding: utf-8
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
import torch
import torch.nn as nn
from sentence_transformers import util
import torch.nn.functional as F
class TripletLoss(nn.Module):
def __init__(self, margin=0.2):
super(Triple... | 5,474 | 29.248619 | 95 | py |
audio-text_retrieval | audio-text_retrieval-main/tools/utils.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
"""
Evaluation tools adapted from https://github.com/fartashf/vsepp/blob/master/evaluation.py
"""
import numpy as np
import torch
import random
from sentence_transformers import util
fro... | 4,670 | 28.751592 | 89 | py |
audio-text_retrieval | audio-text_retrieval-main/data_handling/DataLoader.py | #!/usr/bin/env python3
# coding: utf-8
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
import torch
import random
import numpy as np
import h5py
from torch.utils.data import Dataset
from torch.utils.data.dataloader import DataLoader
class AudioCaptionDataset(Dataset):
def _... | 3,778 | 31.86087 | 93 | py |
audio-text_retrieval | audio-text_retrieval-main/models/TextEncoder.py | #!/usr/bin/env python3
# coding: utf-8
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
import math
import torch
import torch.nn as nn
import numpy as np
from models.BERT_Config import MODELS
class BertEncoder(nn.Module):
def __init__(self, config):
super(BertEncoder... | 1,812 | 36 | 106 | py |
audio-text_retrieval | audio-text_retrieval-main/models/ASE_model.py | #!/usr/bin/env python3
# coding: utf-8
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
import math
import torch
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
from tools.utils import l2norm
from models.AudioEncoder import Cnn10, ResNet38, Cnn14
from model... | 3,846 | 33.348214 | 97 | py |
audio-text_retrieval | audio-text_retrieval-main/models/AudioEncoder.py | #!/usr/bin/env python3
# coding: utf-8
# @Author : Xinhao Mei @CVSSP, University of Surrey
# @E-mail : x.mei@surrey.ac.uk
"""
Adapted from PANNs (Pre-trained Audio Neural Networks).
https://github.com/qiuqiangkong/audioset_tagging_cnn/blob/master/pytorch/models.py
"""
import torch
import torch.nn as nn
import torch... | 17,859 | 37.081023 | 100 | py |
PseCo | PseCo-master/tools/test.py | import argparse
import os
import os.path as osp
import time
import warnings
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import get_dist_info, init_dist, load_checkpoint, wrap_fp16_mod... | 9,642 | 35.665399 | 85 | py |
PseCo | PseCo-master/tools/train.py | import argparse
import copy
import os
import os.path as osp
import time
import warnings
from logging import log
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.runner import get_dist_info, init_dist
from mmcv.utils import get_git_hash
from mmdet import __version__
from mmdet.models import build_... | 7,046 | 34.41206 | 87 | py |
PseCo | PseCo-master/tools/misc/browse_dataset.py | import argparse
import os
from pathlib import Path
import mmcv
import torch
from mmcv import Config, DictAction
from mmdet.core.utils import mask2ndarray
from mmdet.core.visualization import imshow_det_bboxes
from ssod.datasets import build_dataset
from ssod.models.utils import Transform2D
def parse_args():
par... | 5,583 | 31.091954 | 83 | py |
PseCo | PseCo-master/ssod/apis/train.py | import random
import warnings
import numpy as np
import torch
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (
HOOKS,
DistSamplerSeedHook,
EpochBasedRunner,
Fp16OptimizerHook,
OptimizerHook,
build_optimizer,
build_runner,
)
from mmcv.runner.hooks... | 7,063 | 32.961538 | 92 | py |
PseCo | PseCo-master/ssod/core/masks/structures.py | """
Designed for pseudo masks.
In a `TrimapMasks`, it allow some part of the mask is ignored when computing loss.
"""
import numpy as np
import torch
from mmcv.ops.roi_align import roi_align
from mmdet.core import BitmapMasks
class TrimapMasks(BitmapMasks):
def __init__(self, masks, height, width, ignore_value=25... | 2,157 | 34.377049 | 82 | py |
PseCo | PseCo-master/ssod/models/PseCo_frcnn.py | import copy
import os.path as osp
import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import mmcv
from mmcv.runner.fp16_utils import force_fp32
from mmcv.cnn import normal_init
from mmcv.ops import batched_nms
from mmdet.core import bbox2roi, multi_appl... | 27,527 | 40.645991 | 129 | py |
PseCo | PseCo-master/ssod/models/utils/gather.py | import torch
import torch.distributed as dist
@torch.no_grad()
def concat_all_gather(tensor):
# gather all tensor shape
shape_tensor = torch.tensor(tensor.shape, device='cuda')
shape_list = [shape_tensor.clone() for _ in range(dist.get_world_size())]
dist.all_gather(shape_list, shape_tensor)
... | 1,111 | 36.066667 | 97 | py |
PseCo | PseCo-master/ssod/models/utils/bbox_utils.py | import warnings
from collections.abc import Sequence
from typing import List, Optional, Tuple, Union
import numpy as np
import torch
from mmdet.core.mask.structures import BitmapMasks
from torch.nn import functional as F
from mmcv.runner.fp16_utils import force_fp32
import ipdb
def resize_image(inputs, resize_ratio=0... | 12,472 | 32.084881 | 115 | py |
PseCo | PseCo-master/ssod/datasets/builder.py | from collections.abc import Mapping, Sequence
from functools import partial
import torch
from mmcv.parallel import DataContainer
from mmcv.runner import get_dist_info
from mmcv.utils import Registry, build_from_cfg
from mmdet.datasets.builder import worker_init_fn
from mmdet.datasets.samplers import (
DistributedG... | 6,383 | 34.664804 | 88 | py |
PseCo | PseCo-master/ssod/datasets/samplers/semi_sampler.py | from __future__ import division
import numpy as np
import torch
from mmcv.runner import get_dist_info
from torch.utils.data import Sampler, WeightedRandomSampler
from ..builder import SAMPLERS
import ipdb
@SAMPLERS.register_module()
class GroupSemiBalanceSampler(Sampler):
def __init__(
self,
data... | 13,142 | 38.587349 | 88 | py |
PseCo | PseCo-master/ssod/datasets/pipelines/rand_aug.py | """
Modified from https://github.com/google-research/ssl_detection/blob/master/detection/utils/augmentation.py.
"""
import copy
import os
import os.path as osp
import cv2
import mmcv
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
from mmcv.image.colorspace import bgr2rgb, rgb2bgr
from mmdet.core.mask ... | 35,191 | 34.475806 | 166 | py |
PseCo | PseCo-master/ssod/utils/logger.py | import logging
import os
import sys
from collections import Counter
from typing import Tuple
import mmcv
import numpy as np
import torch
from mmcv.runner.dist_utils import get_dist_info
from mmcv.utils import get_logger
from mmdet.core.visualization import imshow_det_bboxes
try:
import wandb
except:
wandb = N... | 5,179 | 28.942197 | 86 | py |
PseCo | PseCo-master/ssod/utils/structure_utils.py | import warnings
from collections import Counter, Mapping, Sequence
from numbers import Number
from typing import Dict, List
import numpy as np
import torch
from mmdet.core.mask.structures import BitmapMasks
from torch.nn import functional as F
import ipdb
_step_counter = Counter()
def list_concat(data_list: List[lis... | 4,372 | 27.212903 | 88 | py |
PseCo | PseCo-master/ssod/utils/exts/optimizer_constructor.py | import warnings
import torch
from torch.nn import GroupNorm, LayerNorm
from mmcv.utils import _BatchNorm, _InstanceNorm, build_from_cfg
from mmcv.utils.ext_loader import check_ops_exist
from mmcv.runner.optimizer.builder import OPTIMIZER_BUILDERS, OPTIMIZERS
from mmcv.runner.optimizer import DefaultOptimizerConstruct... | 5,163 | 44.298246 | 87 | py |
PseCo | PseCo-master/ssod/utils/hooks/weights_summary.py | import os.path as osp
import torch.distributed as dist
from mmcv.parallel import is_module_wrapper
from mmcv.runner.hooks import HOOKS, Hook
from ..logger import get_root_logger
from prettytable import PrettyTable
def bool2str(input):
if input:
return "Y"
else:
return "N"
def unknown():
... | 2,954 | 27.970588 | 86 | py |
PseCo | PseCo-master/ssod/utils/hooks/submodules_evaluation.py | import os.path as osp
import torch.distributed as dist
from mmcv.parallel import is_module_wrapper
from mmcv.runner.hooks import HOOKS, LoggerHook, WandbLoggerHook
from mmdet.core import DistEvalHook
from torch.nn.modules.batchnorm import _BatchNorm
@HOOKS.register_module()
class SubModulesDistEvalHook(DistEvalHook)... | 4,468 | 35.631148 | 81 | py |
PseCo | PseCo-master/ssod/utils/hooks/evaluation.py | import os.path as osp
import torch.distributed as dist
from mmcv.runner.hooks import LoggerHook, WandbLoggerHook
from mmdet.core import DistEvalHook as BaseDistEvalHook
from torch.nn.modules.batchnorm import _BatchNorm
class DistEvalHook(BaseDistEvalHook):
def after_train_iter(self, runner):
"""Called af... | 2,247 | 37.758621 | 86 | py |
PseCo | PseCo-master/thirdparty/mmdetection/setup.py | #!/usr/bin/env python
# Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import shutil
import sys
import warnings
from setuptools import find_packages, setup
import torch
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
CUDAExtensi... | 7,838 | 34.958716 | 125 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import time
import warnings
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (get_dis... | 9,363 | 38.179916 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/train.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import os
import os.path as osp
import time
import warnings
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.runner import get_dist_info, init_dist
from mmcv.utils import get_git_hash
from mmdet import __version__
from m... | 6,962 | 35.647368 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/deployment/test_torchserver.py | from argparse import ArgumentParser
import numpy as np
import requests
from mmdet.apis import inference_detector, init_detector, show_result_pyplot
from mmdet.core import bbox2result
def parse_args():
parser = ArgumentParser()
parser.add_argument('img', help='Image file')
parser.add_argument('config', h... | 2,357 | 30.44 | 77 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/deployment/mmdet2torchserve.py | # Copyright (c) OpenMMLab. All rights reserved.
from argparse import ArgumentParser, Namespace
from pathlib import Path
from tempfile import TemporaryDirectory
import mmcv
try:
from model_archiver.model_packaging import package_model
from model_archiver.model_packaging_utils import ModelExportUtils
except Imp... | 3,693 | 32.279279 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/deployment/onnx2tensorrt.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import warnings
import numpy as np
import onnx
import torch
from mmcv import Config
from mmcv.tensorrt import is_tensorrt_plugin_loaded, onnx2trt, save_trt_engine
from mmdet.core.export import preprocess_example_input
from... | 8,515 | 32.396078 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/deployment/mmdet_handler.py | # Copyright (c) OpenMMLab. All rights reserved.
import base64
import os
import mmcv
import torch
from ts.torch_handler.base_handler import BaseHandler
from mmdet.apis import inference_detector, init_detector
class MMdetHandler(BaseHandler):
threshold = 0.5
def initialize(self, context):
properties ... | 2,560 | 34.569444 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/deployment/pytorch2onnx.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os.path as osp
import warnings
from functools import partial
import numpy as np
import onnx
import torch
from mmcv import Config, DictAction
from mmdet.core.export import build_model_from_cfg, preprocess_example_input
from mmdet.core.export.model_... | 11,474 | 32.949704 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/model_converters/selfsup2mmdet.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
from collections import OrderedDict
import torch
def moco_convert(src, dst):
"""Convert keys in pycls pretrained moco models to mmdet style."""
# load caffe model
moco_model = torch.load(src)
blobs = moco_model['state_dict']
# conver... | 1,243 | 27.930233 | 74 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/model_converters/publish_model.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import subprocess
import torch
def parse_args():
parser = argparse.ArgumentParser(
description='Process a checkpoint to be published')
parser.add_argument('in_file', help='input checkpoint filename')
parser.add_argument('out_file', h... | 1,301 | 28.590909 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/model_converters/regnet2mmdet.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
from collections import OrderedDict
import torch
def convert_stem(model_key, model_weight, state_dict, converted_names):
new_key = model_key.replace('stem.conv', 'conv1')
new_key = new_key.replace('stem.bn', 'bn1')
state_dict[new_key] = mode... | 3,063 | 32.67033 | 77 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/model_converters/upgrade_model_version.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import re
import tempfile
from collections import OrderedDict
import torch
from mmcv import Config
def is_head(key):
valid_head_list = [
'bbox_head', 'mask_head', 'semantic_head', 'grid_head', 'mask_iou_head'
]
return any(key.starts... | 6,848 | 31.459716 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/model_converters/upgrade_ssd_version.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import tempfile
from collections import OrderedDict
import torch
from mmcv import Config
def parse_config(config_strings):
temp_file = tempfile.NamedTemporaryFile()
config_path = f'{temp_file.name}.py'
with open(config_path, 'w') as f:
... | 1,789 | 29.338983 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/model_converters/detectron2pytorch.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
from collections import OrderedDict
import mmcv
import torch
arch_settings = {50: (3, 4, 6, 3), 101: (3, 4, 23, 3)}
def convert_bn(blobs, state_dict, caffe_name, torch_name, converted_names):
# detectron replace bn with affine channel layer
sta... | 3,578 | 41.607143 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/analysis_tools/benchmark.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import time
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDistributedDataParallel
from mmcv.runner import init_dist, load_checkpoint, wrap_fp16_model
from mmdet.datasets import (b... | 4,843 | 32.638889 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/analysis_tools/optimize_anchors.py | # Copyright (c) OpenMMLab. All rights reserved.
"""Optimize anchor settings on a specific dataset.
This script provides two method to optimize YOLO anchors including k-means
anchor cluster and differential evolution. You can use ``--algorithm k-means``
and ``--algorithm differential_evolution`` to switch two method.
... | 13,161 | 34.477089 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/analysis_tools/get_flops.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import numpy as np
import torch
from mmcv import Config, DictAction
from mmdet.models import build_detector
try:
from mmcv.cnn import get_model_complexity_info
except ImportError:
raise ImportError('Please upgrade mmcv to >0.6.2')
def parse_ar... | 3,194 | 30.323529 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/tools/analysis_tools/test_robustness.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import os
import os.path as osp
import mmcv
import torch
from mmcv import DictAction
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (get_dist_info, init_dist, load_checkpoint,
... | 15,421 | 38.341837 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/.dev_scripts/benchmark_filter.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
def parse_args():
parser = argparse.ArgumentParser(description='Filter configs to train')
parser.add_argument(
'--basic-arch',
action='store_true',
help='to train models in basic arch')
... | 7,096 | 41.244048 | 92 | py |
PseCo | PseCo-master/thirdparty/mmdetection/.dev_scripts/gather_models.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import glob
import json
import os.path as osp
import shutil
import subprocess
from collections import OrderedDict
import mmcv
import torch
import yaml
def ordered_yaml_dump(data, stream=None, Dumper=yaml.SafeDumper, **kwds):
class OrderedDumper(Dum... | 9,899 | 34.869565 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/.dev_scripts/benchmark_inference_fps.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
import os.path as osp
import mmcv
from mmcv import Config, DictAction
from mmcv.runner import init_dist
from tools.analysis_tools.benchmark import measure_inferense_speed
def parse_args():
parser = argparse.ArgumentParser(
descript... | 3,626 | 37.178947 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/.dev_scripts/batch_test_list.py | # Copyright (c) OpenMMLab. All rights reserved.
# yapf: disable
atss = dict(
config='configs/atss/atss_r50_fpn_1x_coco.py',
checkpoint='atss_r50_fpn_1x_coco_20200209-985f7bd0.pth',
eval='bbox',
metric=dict(bbox_mAP=39.4),
)
autoassign = dict(
config='configs/autoassign/autoassign_r50_fpn_8x2_1x_coco... | 12,707 | 34.3 | 117 | py |
PseCo | PseCo-master/thirdparty/mmdetection/demo/webcam_demo.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import cv2
import torch
from mmdet.apis import inference_detector, init_detector
def parse_args():
parser = argparse.ArgumentParser(description='MMDetection webcam demo')
parser.add_argument('config', help='test config file path')
parser.ad... | 1,308 | 26.270833 | 78 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/ghm/retinanet_ghm_x101_32x4d_fpn_1x_coco.py | _base_ = './retinanet_ghm_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
style='pytorch... | 423 | 27.266667 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/ghm/retinanet_ghm_r101_fpn_1x_coco.py | _base_ = './retinanet_ghm_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
| 201 | 27.857143 | 61 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/ghm/retinanet_ghm_x101_64x4d_fpn_1x_coco.py | _base_ = './retinanet_ghm_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
type='ResNeXt',
depth=101,
groups=64,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
style='pytorch... | 423 | 27.266667 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/dcn/faster_rcnn_x101_32x4d_fpn_dconv_c3-c5_1x_coco.py | _base_ = '../faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
sty... | 557 | 31.823529 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/htc/htc_x101_64x4d_fpn_16x1_20e_coco.py | _base_ = './htc_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
type='ResNeXt',
depth=101,
groups=64,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
... | 591 | 28.6 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/htc/htc_without_semantic_r50_fpn_1x_coco.py | _base_ = [
'../_base_/datasets/coco_instance.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
type='HybridTaskCascade',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen... | 8,333 | 34.164557 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/htc/htc_x101_32x4d_fpn_16x1_20e_coco.py | _base_ = './htc_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
... | 591 | 28.6 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/htc/htc_x101_64x4d_fpn_dconv_c3-c5_mstrain_400_1400_16x1_20e_coco.py | _base_ = './htc_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
type='ResNeXt',
depth=101,
groups=64,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
... | 1,489 | 32.863636 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/htc/htc_r101_fpn_20e_coco.py | _base_ = './htc_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
# learning policy
lr_config = dict(step=[16, 19])
runner = dict(type='EpochBasedRunner', max_epochs=20)
| 295 | 28.6 | 61 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/reppoints/reppoints_moment_r101_fpn_dconv_c3-c5_gn-neck+head_2x_coco.py | _base_ = './reppoints_moment_r50_fpn_gn-neck+head_2x_coco.py'
model = dict(
backbone=dict(
depth=101,
dcn=dict(type='DCN', deform_groups=1, fallback_on_stride=False),
stage_with_dcn=(False, True, True, True),
init_cfg=dict(type='Pretrained',
checkpoint='torchvis... | 340 | 36.888889 | 72 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/reppoints/reppoints_moment_r101_fpn_gn-neck+head_2x_coco.py | _base_ = './reppoints_moment_r50_fpn_gn-neck+head_2x_coco.py'
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
| 217 | 30.142857 | 61 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/reppoints/reppoints_moment_r50_fpn_1x_coco.py | _base_ = [
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
model = dict(
type='RepPointsDetector',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
... | 2,065 | 29.382353 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/reppoints/reppoints_moment_x101_fpn_dconv_c3-c5_gn-neck+head_2x_coco.py | _base_ = './reppoints_moment_r50_fpn_gn-neck+head_2x_coco.py'
model = dict(
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
... | 562 | 32.117647 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/gfl/gfl_x101_32x4d_fpn_dconv_c4-c5_mstrain_2x_coco.py | _base_ = './gfl_r50_fpn_mstrain_2x_coco.py'
model = dict(
type='GFL',
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
... | 585 | 29.842105 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/gfl/gfl_x101_32x4d_fpn_mstrain_2x_coco.py | _base_ = './gfl_r50_fpn_mstrain_2x_coco.py'
model = dict(
type='GFL',
backbone=dict(
type='ResNeXt',
depth=101,
groups=32,
base_width=4,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
... | 461 | 26.176471 | 76 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/gfl/gfl_r101_fpn_mstrain_2x_coco.py | _base_ = './gfl_r50_fpn_mstrain_2x_coco.py'
model = dict(
backbone=dict(
type='ResNet',
depth=101,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch',
init_cfg=... | 406 | 28.071429 | 61 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/gfl/gfl_r50_fpn_1x_coco.py | _base_ = [
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
model = dict(
type='GFL',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=di... | 1,739 | 29 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/gfl/gfl_r101_fpn_dconv_c3-c5_mstrain_2x_coco.py | _base_ = './gfl_r50_fpn_mstrain_2x_coco.py'
model = dict(
backbone=dict(
type='ResNet',
depth=101,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
dcn=dict(type='DCN', deform_groups=1, fallback_on_stride=F... | 529 | 32.125 | 72 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/tridentnet/tridentnet_r50_caffe_mstrain_1x_coco.py | _base_ = 'tridentnet_r50_caffe_1x_coco.py'
# use caffe img_norm
img_norm_cfg = dict(
mean=[103.530, 116.280, 123.675], std=[1.0, 1.0, 1.0], to_rgb=False)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Resize',
img_scale=[(133... | 756 | 31.913043 | 72 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/tridentnet/tridentnet_r50_caffe_mstrain_3x_coco.py | _base_ = 'tridentnet_r50_caffe_mstrain_1x_coco.py'
lr_config = dict(step=[28, 34])
runner = dict(type='EpochBasedRunner', max_epochs=36)
| 138 | 26.8 | 53 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/tridentnet/tridentnet_r50_caffe_1x_coco.py | _base_ = [
'../_base_/models/faster_rcnn_r50_caffe_c4.py',
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
model = dict(
type='TridentFasterRCNN',
backbone=dict(
type='TridentResNet',
trident_dilations=(1, 2, 3),
... | 1,868 | 32.375 | 74 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/nas_fpn/retinanet_r50_fpn_crop640_50e_coco.py | _base_ = [
'../_base_/models/retinanet_r50_fpn.py',
'../_base_/datasets/coco_detection.py', '../_base_/default_runtime.py'
]
cudnn_benchmark = True
norm_cfg = dict(type='BN', requires_grad=True)
model = dict(
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(... | 2,488 | 29.728395 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/nas_fpn/retinanet_r50_nasfpn_crop640_50e_coco.py | _base_ = [
'../_base_/models/retinanet_r50_fpn.py',
'../_base_/datasets/coco_detection.py', '../_base_/default_runtime.py'
]
cudnn_benchmark = True
# model settings
norm_cfg = dict(type='BN', requires_grad=True)
model = dict(
type='RetinaNet',
backbone=dict(
type='ResNet',
depth=50,
... | 2,478 | 29.9875 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/paa/paa_r50_fpn_1x_coco.py | _base_ = [
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
model = dict(
type='PAA',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=di... | 2,120 | 28.873239 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/paa/paa_r101_fpn_mstrain_3x_coco.py | _base_ = './paa_r50_fpn_mstrain_3x_coco.py'
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
| 199 | 27.571429 | 61 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/paa/paa_r101_fpn_1x_coco.py | _base_ = './paa_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
| 191 | 26.428571 | 61 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/yolact/yolact_r50_1x8_coco.py | _base_ = '../_base_/default_runtime.py'
# model settings
img_size = 550
model = dict(
type='YOLACT',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=-1, # do not freeze stem
norm_cfg=dict(type='BN', requires_grad=Tru... | 5,103 | 30.701863 | 79 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/yolact/yolact_r101_1x8_coco.py | _base_ = './yolact_r50_1x8_coco.py'
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
| 192 | 23.125 | 61 | py |
PseCo | PseCo-master/thirdparty/mmdetection/configs/point_rend/point_rend_r50_caffe_fpn_mstrain_1x_coco.py | _base_ = '../mask_rcnn/mask_rcnn_r50_caffe_fpn_mstrain_1x_coco.py'
# model settings
model = dict(
type='PointRend',
roi_head=dict(
type='PointRendRoIHead',
mask_roi_extractor=dict(
type='GenericRoIExtractor',
aggregation='concat',
roi_layer=dict(
... | 1,453 | 31.311111 | 75 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.