repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/InvertedPendulumSwingupPyBulletEnv_v0_2017may.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it. import inspect import os currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(os.path.dirname(currentdir)) os.sys.path.insert(0,parentdir) import numpy as np ...
23,288
183.833333
606
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/InvertedPendulumPyBulletEnv_v0_2017may.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it. import inspect import os currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(os.path.dirname(currentdir)) os.sys.path.insert(0,parentdir) import numpy as np ...
23,693
185.566929
606
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/AtlasPyBulletEnv_v0_2017jul.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it. import inspect import os currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(os.path.dirname(currentdir)) os.sys.path.insert(0,parentdir) import numpy as np ...
174,944
608.56446
1,182
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/HumanoidFlagrunHarderPyBulletEnv_v0_2017may.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it. import inspect import os currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(os.path.dirname(currentdir)) os.sys.path.insert(0,parentdir) import numpy as np ...
421,277
928.97351
2,334
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/policies.py
import numpy as np def relu(x): return np.maximum(x, 0) class SmallReactivePolicy: """Simple multi-layer perceptron policy, no internal state""" def __init__(self, observation_space, action_space, weights, biases): self.weights = weights self.biases = biases def act(self, ob): ...
527
25.4
73
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/Walker2DPyBulletEnv_v0_2017may.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it. import inspect import os currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(os.path.dirname(currentdir)) os.sys.path.insert(0,parentdir) import numpy as np ...
105,464
440.276151
1,182
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/HumanoidFlagrunPyBulletEnv_v0_2017may.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it. import inspect import os currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(os.path.dirname(currentdir)) os.sys.path.insert(0,parentdir) import numpy as np ...
421,278
926.927313
2,334
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/__init__.py
0
0
0
py
pybullet-gym
pybullet-gym-master/pybulletgym/tests/roboschool/agents/InvertedDoublePendulumPyBulletEnv_v0_2017may.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it. import inspect import os currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(os.path.dirname(currentdir)) os.sys.path.insert(0,parentdir) import numpy as np ...
25,604
195.961538
606
py
pybullet-gym
pybullet-gym-master/pybulletgym/utils/kerasrl_utils.py
import re from gym import error import glob # checkpoints/KerasDDPG-InvertedPendulum-v0-20170701190920_actor.h5 weight_save_re = re.compile(r'^(?:\w+\/)+?(\w+-v\d+)-(\w+-v\d+)-(\d+)(?:_\w+)?\.(\w+)$') def get_fields(weight_save_name): match = weight_save_re.search(weight_save_name) if not match: raise err...
1,135
38.172414
158
py
pybullet-gym
pybullet-gym-master/pybulletgym/utils/__init__.py
0
0
0
py
pybullet-gym
pybullet-gym-master/pybulletgym/utils/robot_dev_util.py
from pybulletgym.envs.roboschool.robots.locomotors import Ant import gym.utils.seeding import numpy as np import pybullet as p import time from importlib import import_module import sys if __name__ == "__main__": physicsClient = p.connect(p.GUI) path, class_str = sys.argv[1].rsplit('.', 1) module = impo...
790
25.366667
124
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
dilran
dilran-main/meta_config.py
# configuration file for training # Author: Simon Zhou, last modify Nov.18 2022 ''' Do not need a change log, you can always change to your own directory ''' import os data_dir = os.getcwd() res_dir = os.getcwd() + "/res" test_data_dir = os.getcwd() + "/testset" test_num = 20 train_val_ratio = 0.8 # lambdas in loss...
406
18.380952
69
py
audio-text_retrieval
audio-text_retrieval-main/data_prep.py
#!/usr/bin/env python3 # coding: utf-8 # @Author : Xinhao Mei @CVSSP, University of Surrey # @E-mail : [email protected] from tools.dataset import pack_dataset_to_hdf5 from loguru import logger if __name__ == '__main__': logger.info('Packing dataset to hdf5 files.') logger.info('Packing AudioCaps...') ...
494
26.5
52
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 : [email protected] 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 : [email protected] 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 : [email protected] 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 : [email protected] """ 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/tools/dataset.py
#!/usr/bin/env python3 # coding: utf-8 # @Author : Xinhao Mei @CVSSP, University of Surrey # @E-mail : [email protected] import time from itertools import chain import h5py import numpy as np import librosa from re import sub from loguru import logger from pathlib import Path from tqdm import tqdm from tools.file_...
5,198
31.291925
111
py
audio-text_retrieval
audio-text_retrieval-main/tools/file_io.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Author : Xinhao Mei @CVSSP, University of Surrey # @E-mail : [email protected] from pathlib import Path import os import csv import pickle def write_csv_file(csv_obj, file_name): with open(file_name, 'w') as f: writer = csv.DictWriter(f, csv_obj[0].ke...
980
22.357143
71
py
audio-text_retrieval
audio-text_retrieval-main/tools/config_loader.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # @Author : Xinhao Mei @CVSSP, University of Surrey # @E-mail : [email protected] import yaml from dotmap import DotMap def get_config(config_name='settings'): with open('settings/{}.yaml'.format(config_name), 'r') as f: config = yaml.load(f, Loader=ya...
381
20.222222
64
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 : [email protected] 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/BERT_Config.py
#!/usr/bin/env python3 # coding: utf-8 # @Author : Xinhao Mei @CVSSP, University of Surrey # @E-mail : [email protected] from transformers import BertModel, BertTokenizer, GPT2Model, GPT2Tokenizer,\ RobertaModel, RobertaTokenizer, DistilBertModel, DistilBertTokenizer,\ CLIPTokenizer, CLIPTextModel MODELS =...
1,116
43.68
77
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 : [email protected] 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 : [email protected] 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 : [email protected] """ 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/setup.py
import re from setuptools import find_packages, setup def get_version(): version_file = "ssod/version.py" with open(version_file, "r") as f: exec(compile(f.read(), version_file, "exec")) return locals()["__version__"] def parse_requirements(fname="requirements.txt", with_version=True): """P...
3,554
34.55
125
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/dataset/semi_coco.py
# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
4,726
35.083969
156
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/version.py
__version__ = "0.0.1" __all__ = ["__version__"]
49
11.5
25
py
PseCo
PseCo-master/ssod/__init__.py
from .models import *
22
10.5
21
py
PseCo
PseCo-master/ssod/apis/inference.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import mmcv from mmcv.runner import load_checkpoint from mmdet.core import get_classes from mmdet.models import build_detector def init_detector(config, checkpoint=None, device="cuda:0", cfg_options=None): """Initialize a detector from config file....
2,762
32.695122
84
py
PseCo
PseCo-master/ssod/apis/__init__.py
from .train import get_root_logger, set_random_seed, train_detector __all__ = ["get_root_logger", "set_random_seed", "train_detector"]
136
33.25
67
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/__init__.py
from .masks import TrimapMasks
31
15
30
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/core/masks/__init__.py
from .structures import TrimapMasks
36
17.5
35
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/__init__.py
from .PseCo_frcnn import PseCo_FRCNN
36
36
36
py
PseCo
PseCo-master/ssod/models/multi_stream_detector.py
from typing import Dict from mmdet.models import BaseDetector, TwoStageDetector class MultiSteamDetector(BaseDetector): def __init__( self, model: Dict[str, TwoStageDetector], train_cfg=None, test_cfg=None ): super(MultiSteamDetector, self).__init__() self.submodules = list(model.keys(...
2,233
36.233333
83
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/__init__.py
from .bbox_utils import (Transform2D, filter_invalid, filter_invalid_classwise, filter_invalid_scalewise, resize_image, evaluate_pseudo_label, get_pseudo_label_quality) from .gather import concat_all_gather
259
51
88
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/dataset_wrappers.py
from mmdet.datasets import DATASETS, ConcatDataset, build_dataset import ipdb @DATASETS.register_module() class SemiDataset(ConcatDataset): """Wrapper for semisupervised od.""" def __init__(self, sup: dict, unsup: dict, **kwargs): super().__init__([build_dataset(sup), build_dataset(unsup)], **kwargs...
456
23.052632
78
py
PseCo
PseCo-master/ssod/datasets/__init__.py
from mmdet.datasets import build_dataset from .builder import build_dataloader from .dataset_wrappers import SemiDataset from .pipelines import * from .pseudo_coco import PseudoCocoDataset from .samplers import DistributedGroupSemiBalanceSampler __all__ = [ "PseudoCocoDataset", "build_dataloader", "build_...
393
23.625
56
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/pseudo_coco.py
import copy import json from mmdet.datasets import DATASETS, CocoDataset from mmdet.datasets.api_wrappers import COCO @DATASETS.register_module() class PseudoCocoDataset(CocoDataset): def __init__( self, ann_file, pseudo_ann_file, pipeline, confidence_threshold=0.9, ...
2,516
27.931034
89
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/samplers/__init__.py
from .semi_sampler import DistributedGroupSemiBalanceSampler, GroupSemiBalanceSampler __all__ = [ "DistributedGroupSemiBalanceSampler", "GroupSemiBalanceSampler" ]
168
32.8
85
py
PseCo
PseCo-master/ssod/datasets/pipelines/formatting.py
import numpy as np from mmdet.datasets import PIPELINES from mmdet.datasets.pipelines.formating import Collect from ssod.core import TrimapMasks @PIPELINES.register_module() class ExtraAttrs(object): def __init__(self, **attrs): self.attrs = attrs def __call__(self, results): for k, v in sel...
2,644
32.481013
109
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/datasets/pipelines/__init__.py
from .formatting import * from .rand_aug import *
50
16
25
py
PseCo
PseCo-master/ssod/datasets/pipelines/geo_utils.py
""" Record the geometric transformation information used in the augmentation in a transformation matrix. """ import numpy as np class GeometricTransformationBase(object): @classmethod def inverse(cls, results): # compute the inverse return results["transform_matrix"].I # 3x3 @classmethod...
3,319
33.947368
100
py
PseCo
PseCo-master/ssod/utils/vars.py
import re from typing import Union pattern = re.compile("\$\{[a-zA-Z\d_.]*\}") def get_value(cfg: dict, chained_key: str): keys = chained_key.split(".") if len(keys) == 1: return cfg[keys[0]] else: return get_value(cfg[keys[0]], ".".join(keys[1:])) def resolve(cfg: Union[dict, list], ba...
1,076
28.916667
70
py
PseCo
PseCo-master/ssod/utils/signature.py
import inspect def parse_method_info(method): sig = inspect.signature(method) params = sig.parameters return params
130
15.375
35
py
PseCo
PseCo-master/ssod/utils/patch.py
import glob import os import os.path as osp import shutil import types import ipdb from mmcv.runner import BaseRunner, EpochBasedRunner, IterBasedRunner from mmcv.utils import Config from .signature import parse_method_info from .vars import resolve def find_latest_checkpoint(path, ext="pth"): if not osp.exists...
2,508
29.228916
74
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/__init__.py
from .exts import NamedOptimizerConstructor from .hooks import Weighter, MeanTeacher, WeightSummary, SubModulesDistEvalHook from .logger import get_root_logger, log_every_n, log_image_with_boxes from .patch import patch_config, patch_runner, find_latest_checkpoint __all__ = [ "get_root_logger", "log_every_n",...
540
26.05
79
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/exts/__init__.py
from .optimizer_constructor import NamedOptimizerConstructor
61
30
60
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/mean_teacher.py
from mmcv.parallel import is_module_wrapper from mmcv.runner.hooks import HOOKS, Hook from bisect import bisect_right from ..logger import log_every_n import logging import ipdb @HOOKS.register_module() class MeanTeacher(Hook): def __init__( self, momentum=0.999, interval=1, warm_up...
2,461
33.676056
84
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/__init__.py
from .weight_adjust import Weighter, GetCurrentIter from .mean_teacher import MeanTeacher from .weights_summary import WeightSummary from .evaluation import DistEvalHook from .submodules_evaluation import SubModulesDistEvalHook __all__ = [ "Weighter", "MeanTeacher", "DistEvalHook", "SubModulesDistEva...
372
23.866667
59
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/ssod/utils/hooks/weight_adjust.py
from mmcv.parallel import is_module_wrapper from mmcv.runner.hooks import HOOKS, Hook from bisect import bisect_right @HOOKS.register_module() class Weighter(Hook): def __init__( self, steps=None, vals=None, name=None, ): self.steps = steps self.vals = vals ...
1,406
28.93617
79
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/eval.py
import argparse import pickle import mmcv from mmcv import Config, DictAction, PickleHandler from mmdet.datasets import build_dataloader, build_dataset from mmdet.datasets.coco import CocoDataset import ipdb def parse_args(): parser = argparse.ArgumentParser( description='Eval Script' ) parser...
1,501
32.377778
87
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/test.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse import mmcv from mmcv import Config, DictAction from mmcv.parallel import MMDataParallel from mmdet.apis import single_gpu_test from mmdet.datasets import (build_dataloader, build_dataset, replace_ImageToTensor) def parse_ar...
5,481
37.069444
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/misc/print_config.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse import warnings from mmcv import Config, DictAction def parse_args(): parser = argparse.ArgumentParser(description='Print the whole config') parser.add_argument('config', help='config file path') parser.add_argument( '--options', ...
1,896
32.875
78
py
PseCo
PseCo-master/thirdparty/mmdetection/tools/misc/browse_dataset.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse import os from collections import Sequence from pathlib import Path import mmcv from mmcv import Config, DictAction from mmdet.core.utils import mask2ndarray from mmdet.core.visualization import imshow_det_bboxes from mmdet.datasets.builder import build_...
3,460
30.463636
78
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/dataset_converters/images2coco.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse import os import mmcv from PIL import Image def parse_args(): parser = argparse.ArgumentParser( description='Convert images to coco format without annotations') parser.add_argument('img_path', help='The root path of images') parser.a...
3,109
29.490196
77
py