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
StARformer
StARformer-main/gym/models/decision_transformer.py
import numpy as np import torch import torch.nn as nn import transformers from models.model import TrajectoryModel from models.trajectory_gpt2 import GPT2Model class DecisionTransformer(TrajectoryModel): """ This model uses GPT to model (Return_1, state_1, action_1, Return_2, state_2, ...) """ def...
7,017
42.8625
172
py
StARformer
StARformer-main/atari_and_dmc/run_star_atari.py
import argparse import future, pickle, blosc, os from datetime import datetime from collections import deque import math, random import numpy as np import cv2 from PIL import Image import torch import torch.nn as nn from torch.nn import functional as F from torch.utils.data import Dataset import torch.optim as optim...
17,160
39.665877
270
py
StARformer
StARformer-main/atari_and_dmc/utils.py
import random import numpy as np import torch import torch.nn as nn import os # source: https://github.com/google-research/batch_rl/blob/master/batch_rl/fixed_replay/replay_memory/fixed_replay_buffer.py import collections from concurrent import futures from dopamine.replay_memory import circular_replay_buffer import ...
8,230
36.930876
146
py
StARformer
StARformer-main/atari_and_dmc/starformer.py
from einops import rearrange, repeat from einops.layers.torch import Rearrange import math import torch import torch.nn as nn import torch.nn.functional as F from timm.models.layers import trunc_normal_ class GELU(nn.Module): def __init__(self): super().__init__() def forward(self, input): ...
17,722
43.418546
141
py
StARformer
StARformer-main/atari_and_dmc/run_star_dmc.py
import argparse import future, pickle, blosc, os from datetime import datetime from collections import deque import math, random import numpy as np import cv2 from PIL import Image import torch import torch.nn as nn from torch.nn import functional as F import torch.optim as optim from torch.optim.lr_scheduler import...
16,627
38.216981
270
py
NAOMI
NAOMI-master/model_utils.py
import numpy as np import torch import torch.nn.functional as F from torch.autograd import Variable ###################################################################### ########################## MISCELLANEOUS ############################# ###################################################################### def...
4,992
30.012422
96
py
NAOMI
NAOMI-master/model.py
import numpy as np import math import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import torch.nn.init as init from model_utils import * def num_trainable_params(model): total = 0 for p in model.parameters(): count = 1 for s in p.size(): ...
11,065
36.511864
101
py
NAOMI
NAOMI-master/helpers.py
from torch.autograd import Variable from torch import nn import torch import numpy as np import os import struct import pickle import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.patches as patches from matplotlib import animation from skimage.transform import resize use_gpu = tor...
9,940
35.413919
165
py
NAOMI
NAOMI-master/train.py
import argparse import os import math import sys import pickle import time import numpy as np import shutil sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from model import * from torch.autograd import Variable from torch import nn import torch import torch.utils import torch.utils.dat...
14,011
44.054662
138
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/setup.py
import setuptools with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setuptools.setup( name="irnlm", version="0.0.1", author="Alexandre Pasquiou", author_email="alexandre.pasquiou@inria.fr", description="Python code to reproduce the analyses of the paper: `Inform...
1,001
39.08
195
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/utils.py
import os import re import glob import torch import random import datetime import numpy as np from transformers import GPT2LMHeadModel, WEIGHTS_NAME, CONFIG_NAME from irnlm.models.gpt2.modeling_hacked_gpt2_integral import GPT2LMHeadModel from irnlm.models.gpt2.modeling_hacked_gpt2_semantic import GPT2LMHeadModel as G...
5,601
39.890511
131
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/modeling_hacked_gpt2_semantic_no_relative_pos.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
60,611
40.232653
168
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/language_modeling.py
""" """ import warnings warnings.simplefilter(action="ignore") import os import torch import pickle from torch.utils.data import TensorDataset from torch.utils.data import ( DataLoader, RandomSampler, SequentialSampler, DistributedSampler, ) from irnlm.models.gpt2.dataset import Dataset from irnlm....
4,340
32.651163
168
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/modeling_hacked_gpt2_semantic.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
59,120
42.343842
168
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/modeling_hacked_gpt2_syntactic.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
59,145
42.36217
168
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/modeling_hacked_gpt2_integral.py
# coding=utf-8 # Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
59,145
42.36217
168
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/extract_features_gpt2_syntactic.py
import re import numpy as np import pandas as pd from tqdm import tqdm import benepar from spacy.symbols import ORTH import torch from irnlm.data.utils import set_nlp_pipeline, get_ids_syntax from irnlm.data.extract_syntactic_features import integral2syntactic from irnlm.models.gpt2.extract_features_gpt2_integral im...
5,558
33.74375
159
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/processors.py
import os import gc import time import math import torch import logging import pandas as pd from tqdm import tqdm from torch.nn import CrossEntropyLoss from torch.utils.data import TensorDataset from torch.utils.data import DataLoader, RandomSampler from irnlm.models.utils import save_checkpoint, format_time from irn...
27,960
44.465041
211
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/extract_features_gpt2_integral.py
import os import re import numpy as np import pandas as pd from tqdm import tqdm import torch from transformers import AutoTokenizer from irnlm.models.tokenizer import read_bpe from irnlm.data.text_tokenizer import tokenize from irnlm.models.gpt2.modeling_hacked_gpt2_integral import GPT2LMHeadModel from irnlm.models....
11,428
32.127536
196
py
Information-Restricted-NLMs
Information-Restricted-NLMs-main/src/irnlm/models/gpt2/extract_features_gpt2_semantic.py
import os import re import numpy as np import pandas as pd from tqdm import tqdm import torch from irnlm.data.extract_semantic_features import integral2semantic from irnlm.models.gpt2.extract_features_gpt2_integral import batchify_to_truncated_input def extract_features( path, model, nlp_tokenizer, ...
3,664
32.018018
92
py
diver-rt
diver-rt-main/run.py
import torch torch.backends.cudnn.enabled=True torch.backends.cudnn.benchmark = False from argparse import ArgumentParser import moderngl from scene import DIVeRScene from orbit_camera import OrbitCamera import moderngl_window as mglw from diver import DIVeR """ camera viewer code""" class Viewer(mglw.WindowConfig...
2,820
31.056818
91
py
diver-rt
diver-rt-main/diver.py
import torch import torch.nn as nn import torch.nn.functional as NF from ray_march import aabb_intersect,ray_march from mlp_evaluation import mlp_eval, upload_weight """ real-time DIVeR code""" class DIVeR(nn.Module): def __init__(self, hparams): super(DIVeR, self).__init__() self.voxel_num = hpara...
3,956
43.965909
128
py
diver-rt
diver-rt-main/orbit_camera.py
import numpy as np import math import torch """ orbit camera model """ class OrbitCamera: def __init__(self, pivot=[0,0,0], azimuth=0, elevation=60, zoom=400): """ Args: pivot: initial obit center (in voxel grid coordinate system) azimuth: initial azimuth elevati...
3,864
27.007246
85
py
diver-rt
diver-rt-main/ray_march/__init__.py
from torch.utils.cpp_extension import load from pathlib import Path _ext_src_root = Path(__file__).parent / 'src' _ext_include = Path(__file__).parent / 'include' exts = ['.cpp', '.cu'] _ext_src_files = [ str(f) for f in _ext_src_root.iterdir() if any([f.name.endswith(ext) for ext in exts]) ] _ext = load(nam...
496
28.235294
52
py
diver-rt
diver-rt-main/mlp_evaluation/__init__.py
from torch.utils.cpp_extension import load import torch from torch.autograd import Function from pathlib import Path _ext_src_root = Path(__file__).parent / 'src' _ext_include = Path(__file__).parent / 'include' exts = ['.cpp', '.cu'] _ext_src_files = [ str(f) for f in _ext_src_root.iterdir() if any([f.name.e...
1,158
25.340909
52
py
MASTER-electric_vehicle_charging_recommendation
MASTER-electric_vehicle_charging_recommendation-main/env.py
import numpy as np import torch TorchFloat = None TorchLong = None class RunningStat(object): def __init__(self, shape): self._n = np.int64(0) self._M = np.zeros(shape) self._S = np.zeros(shape) def push(self, x): x = np.asarray(x) n_sample, n_feat = x.shape as...
23,320
43.085066
185
py
facenet
facenet-master/src/align/detect_face.py
""" Tensorflow implementation of the face detection / alignment algorithm found at https://github.com/kpzhang93/MTCNN_face_detection_alignment """ # MIT License # # Copyright (c) 2016 David Sandberg # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated docu...
31,695
39.531969
150
py
facenet
facenet-master/tmp/mtcnn_test_pnet_dbg.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf import numpy as np import scipy.io as io import align.detect_face #ref = io.loadmat('pnet_dbg.mat') with tf.Graph().as_default(): sess = tf.Session() with sess.as_default(): ...
4,550
35.408
144
py
facenet
facenet-master/tmp/mtcnn_test.py
# MIT License # # Copyright (c) 2016 David Sandberg # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, me...
4,376
35.173554
119
py
hrq-vae
hrq-vae-master/scripts/generate_training_triples.py
import jsonlines, os, json import numpy as np from flair.models import SequenceTagger from flair.data import Sentence from collections import defaultdict, Counter from tqdm import tqdm from copy import deepcopy import torch # predictor = Predictor.from_archive(load_archive("https://storage.googleapis.com/allennlp-p...
15,891
37.293976
1,024
py
FacialGAN
FacialGAN-main/Toolbox/demo.py
import os import sys import cv2 import time import numpy as np from PIL import Image import torch from torchvision import transforms from torchvision.utils import save_image # OUR import copy import kornia from munch import Munch from os.path import join as ospj import torch import torch.nn.functional as F from co...
13,786
34.351282
120
py
FacialGAN
FacialGAN-main/Toolbox/core/checkpoint.py
import os import torch class CheckpointIO(object): def __init__(self, fname_template, **kwargs): print(fname_template) os.makedirs(os.path.dirname(fname_template), exist_ok=True) self.fname_template = fname_template self.module_dict = kwargs def register(self, **kwargs): ...
1,121
33
77
py
FacialGAN
FacialGAN-main/Toolbox/core/model.py
import copy import math from munch import Munch import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import kornia import torchvision import cv2 class ResBlk(nn.Module): def __init__(self, dim_in, dim_out, actv=nn.LeakyReLU(0.2), normalize=False, downsample=Fal...
11,490
33.927052
108
py
FacialGAN
FacialGAN-main/Toolbox/util/image_pool.py
import random import torch from torch.autograd import Variable class ImagePool(): def __init__(self, pool_size): self.pool_size = pool_size if self.pool_size > 0: self.num_imgs = 0 self.images = [] def query(self, images): if self.pool_size == 0: retu...
1,090
33.09375
67
py
FacialGAN
FacialGAN-main/Toolbox/util/util.py
from __future__ import print_function print ('?') import torch import numpy as np from PIL import Image import numpy as np import os # Converts a Tensor into a Numpy array # |imtype|: the desired type of the converted numpy array def tensor2im(image_tensor, imtype=np.uint8, normalize=True): if isinstance(image_te...
4,130
37.25
129
py
FacialGAN
FacialGAN-main/Training/main.py
import os import argparse from munch import Munch from torch.backends import cudnn import torch from core.data_loader import get_train_loader from core.data_loader import get_test_loader from core.solver import Solver def str2bool(v): return v.lower() in ('true') def subdirs(dname): return [d for d in os....
7,689
47.36478
113
py
FacialGAN
FacialGAN-main/Training/core/checkpoint.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
1,419
32.809524
77
py
FacialGAN
FacialGAN-main/Training/core/data_loader.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
9,902
34.367857
88
py
FacialGAN
FacialGAN-main/Training/core/utils.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
5,458
33.770701
95
py
FacialGAN
FacialGAN-main/Training/core/model.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
14,050
34.662437
112
py
FacialGAN
FacialGAN-main/Training/core/own_data_loader.py
#from torchvision.datasets.vision import VisionDataset from core.VisionDataset import VisionDataset from PIL import Image import os import os.path import imageio import numpy as np import random from torchvision import transforms import torch def has_file_allowed_extension(filename, extensions): """Checks if...
10,969
35.688963
113
py
FacialGAN
FacialGAN-main/Training/core/unet.py
from collections import OrderedDict import torch import torch.nn as nn class UNet(nn.Module): def __init__(self, in_channels=3, out_channels=1, init_features=32): super(UNet, self).__init__() features = init_features self.encoder1 = UNet._block(in_channels, features, name="enc1") ...
3,740
36.787879
85
py
FacialGAN
FacialGAN-main/Training/core/VisionDataset.py
import os import torch import torch.utils.data as data from typing import Any, Callable, List, Optional, Tuple class VisionDataset(data.Dataset): _repr_indent = 7 def __init__( self, root: str, root_masks: str, attribute: str, training: bool, ...
3,518
36.83871
114
py
FacialGAN
FacialGAN-main/Training/core/solver.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
14,571
39.365651
145
py
FacialGAN
FacialGAN-main/Training/metrics/lpips.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
3,385
33.55102
81
py
FacialGAN
FacialGAN-main/Training/metrics/fid.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
3,219
34.777778
101
py
FacialGAN
FacialGAN-main/Training/metrics/eval.py
""" StarGAN v2 Copyright (c) 2020-present NAVER Corp. This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, US...
6,537
39.608696
92
py
ClassDistributionPrediction
ClassDistributionPrediction-main/dataset/example_config.py
dataset_name = 'C2B' gpu = 1 total_num = 64000 samples_per_gpu = 16 workers_per_gpu = 1 total_iter = 64000 test_interval = 2000 save_interval = 1000 img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='Lo...
8,540
34.736402
207
py
ClassDistributionPrediction
ClassDistributionPrediction-main/examples/eval/visualise_inf.py
import torch, torchvision import mmdet from mmdet.apis import inference_detector, init_detector, show_result_pyplot import json import os import cv2 # os.chdir("/mnt/hpccs01/home/n11223243/ssod") os.chdir("/home/nicolas/hpc-home/ssod/") # Choose to use a config and initialize the detector config='work_dirs/baseline_s...
1,220
30.307692
78
py
ClassDistributionPrediction
ClassDistributionPrediction-main/examples/eval/eval.py
import argparse import os 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_model) from...
9,075
38.290043
87
py
ClassDistributionPrediction
ClassDistributionPrediction-main/examples/train/train.py
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 mmdet.models import build_detector from mmdet.dat...
7,212
35.614213
83
py
ClassDistributionPrediction
ClassDistributionPrediction-main/configs/labelmatch/labelmatch_uda_cluster.py
dataset_name = data_template gpu = gpu_template total_num = 48000 * 16 samples_per_gpu = 8 workers_per_gpu = 1 total_iter = int(total_num / (samples_per_gpu * gpu)) test_interval = 2000 save_interval = 1000 update_interval = 500 target_thr = 0.6 cluster_method = 'manual_prior' # # -------------------------dataset------...
10,563
35.302405
209
py
ClassDistributionPrediction
ClassDistributionPrediction-main/configs/labelmatch/labelmatch_uda.py
dataset_name = data_template gpu = gpu_template # we desire a batch size of 16 # learning rate is 0.001*16 # run for 32,000 iterations total_num = 72000 * 16 samples_per_gpu = 8 workers_per_gpu = 1 total_iter = int(total_num / (samples_per_gpu * gpu)) test_interval = 2000 save_interval = 1000 update_interval = 500 # ...
9,815
33.442105
209
py
ClassDistributionPrediction
ClassDistributionPrediction-main/configs/baseline/baseline_uda.py
# hyper-parameter: replace in "bash" dataset_name = data_template gpu = gpu_template total_num = 64000 # 1 GPUs x 16 samples per GPU = 16 batch size. This requires 40Gb memory. # learning rate then calculated at 0.001*batchsize # total_iter for pretraining is 64000/batch_size = 4000 # run for longer to assess supervis...
7,405
33.446512
209
py
ClassDistributionPrediction
ClassDistributionPrediction-main/configs/baseline/ema_config/baseline_uda_cls1.py
classes = ('car',) # # -------------------------model------------------------------ model = dict( type='FasterRCNN', pretrained='./pretrained_model/backbone/vgg16_caffe.pth', backbone=dict( type='VGG', depth=16, out_indices=(4,), # stride=16 with_last_pool=False, ), ...
3,460
32.601942
77
py
ClassDistributionPrediction
ClassDistributionPrediction-main/configs/baseline/ema_config/baseline_uda_cls8.py
classes = ('truck', 'car', 'rider', 'person', 'train', 'motorcycle', 'bicycle', 'bus') # # -------------------------model------------------------------ model = dict( type='FasterRCNN', init_cfg='./pretrained_model/backbone/vgg16_caffe.pth', backbone=dict( type='VGG', depth=16, out_in...
3,526
33.242718
86
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/apis/test.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ modify from mmdet.apis.test: use PrintBar rather than ProgressBar (for AI platform) """ import os.path as osp import time from shutil import get_terminal_size import torch ...
5,688
35.235669
84
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/apis/train.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ modify from mmdet.apis.train: 1. support ema model """ import warnings import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner imp...
6,403
37.812121
85
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/bbox/samplers/random_sampler_lm.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection import torch from mmdet.core.bbox.builder import BBOX_SAMPLERS from mmdet.core.bbox.samplers import RandomSampler, SamplingResult from mmdet_extension.core.bbox.samplers.samplin...
6,499
46.794118
92
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/bbox/samplers/sampling_result_lm.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection import torch from mmdet.core.bbox.samplers import SamplingResult class SamplingResultLM(SamplingResult): def __init__(self, pos_inds, ig_inds, neg_inds, bboxes, gt_bboxes,...
2,678
42.209677
107
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/bbox/assigner/assign_result_lm.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection import torch from mmdet.core.bbox.assigners import AssignResult class AssignResultLM(AssignResult): def add_ig_(self, gt_labels): # assign as -1 for ignore ...
683
39.235294
94
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/bbox/assigner/max_iou_assigner_lm.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection import torch from mmdet.core.bbox.builder import BBOX_ASSIGNERS from mmdet.core.bbox.assigners import MaxIoUAssigner from mmdet_extension.core.bbox.assigner.assign_result_lm im...
4,318
43.071429
84
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/hooks/semi_eval_hooks.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ eval hook for semi-supervised: 1. without ema: same as normal evaluation 2. with ema: 1) only_ema=True: only do evaluation on ema_model 2) only_ema=False: do ev...
5,701
39.728571
109
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/hooks/labelmatch_cluster_hooks.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ hooks for LabelMatchCluster """ import shutil import os.path as osp import numpy as np import pickle import torch.distributed as dist from torch.nn.modules.batchnorm import...
28,514
45.899671
174
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/hooks/stac_hooks.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ hooks for STAC """ import os.path as osp import numpy as np import torch.distributed as dist from torch.nn.modules.batchnorm import _BatchNorm import mmcv from mmcv.runner...
8,358
38.804762
114
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/hooks/labelmatch_hooks.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ hooks for LabelMatch """ import shutil import os.path as osp import numpy as np import torch.distributed as dist from torch.nn.modules.batchnorm import _BatchNorm import m...
10,970
43.417004
130
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/core/utils/dist_utils.py
import torch @torch.no_grad() def concat_all_gather(tensor, dim=0): """Performs all_gather operation on the provided tensors. *** Warning ***: torch.distributed.all_gather has no gradient. """ tensors_gather = [ torch.ones_like(tensor) for _ in range(torch.distributed.get_world_size()...
468
25.055556
72
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/detectors/semi_base.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. """ Base-Detector for semi-supervised learning """ import cv2 import os from collections import OrderedDict import matplotlib.pyplot as plt import numpy as np import torch from torch import nn import mmcv from mmcv.runner import load...
7,566
41.751412
110
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/detectors/labelmatch_cluster.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ LabelMatchCluster """ import numpy as np import pickle import torch from mmcv.runner.dist_utils import get_dist_info from mmdet.utils import get_root_logger from mmdet.cor...
14,434
49.296167
118
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/detectors/labelmatch.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ LabelMatch """ import numpy as np import torch from mmcv.runner.dist_utils import get_dist_info from mmdet.utils import get_root_logger from mmdet.core.bbox.iou_calculator...
13,339
50.505792
118
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/detectors/semi_two_stage.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ semi-supervised two stage detector """ import torch from mmdet.core import bbox2result from mmdet.models.detectors import TwoStageDetector from mmdet_extension.models.dete...
1,835
37.25
103
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/roi_head/standard_roi_head_lm.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ standard roi_head for LabelMatch """ import torch from mmdet.models.builder import HEADS from mmdet.core import bbox2roi from mmdet_extension.models.roi_head import Stand...
2,417
39.3
85
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/roi_head/standard_roi_head_base.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection """ standard roi_head for LabelMatch """ import torch from mmdet.models.builder import HEADS from mmdet.core import bbox2roi from mmdet.models.roi_heads import StandardRoIHead...
1,586
37.707317
84
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/roi_head/bbox_heads/convfc_bbox_head_st.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection import torch from mmdet.core import multi_apply from mmdet.models.roi_heads.bbox_heads import Shared2FCBBoxHead from mmdet.models.builder import HEADS @HEADS.register_module(...
3,892
42.741573
90
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/roi_head/bbox_heads/convfc_bbox_head_lm.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection import torch from mmdet.core import multi_apply from mmdet.models.roi_heads.bbox_heads import Shared2FCBBoxHead from mmdet.models.builder import HEADS @HEADS.register_module(...
4,092
44.988764
87
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/models/loss/focal_loss.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/facebookresearch/unbiased-teacher """ CE version of Focal Loss """ import torch import torch.nn as nn import torch.nn.functional as F from mmdet.models.builder import LOSSES from mmdet.models.losses....
1,659
37.604651
95
py
ClassDistributionPrediction
ClassDistributionPrediction-main/mmdet_extension/datasets/semi_dataset.py
# Copyright (c) Hangzhou Hikvision Digital Technology Co., Ltd. All rights reserved. # Modified from https://github.com/open-mmlab/mmdetection import copy import random from torch.utils.data import Dataset from mmdet.datasets.builder import DATASETS from mmdet.datasets.pipelines import Compose from mmdet.datasets impor...
2,992
36.886076
91
py
ClassDistributionPrediction
ClassDistributionPrediction-main/cluster_priors/save_clip_embeddings.py
import os from multiprocessing import Process import csv from PIL import Image from transformers import CLIPProcessor, CLIPVisionModel # TODO edit scenario, dataset and DIR DIR = '/home/nicolas/hpc-home/class_distribution_prediction/' scenario = 'C2B' dataset = 'labeled_data' def run_clip(images, image_names, dataset...
2,868
32.752941
166
py
ClassDistributionPrediction
ClassDistributionPrediction-main/cluster_priors/clip_distances.py
from lib2to3.pytree import LeafPattern from logging.config import stopListening from pydoc import cli from re import L from tkinter.font import names import umap from sklearn.datasets import load_digits import numpy as np import pandas as pd import plotly.express as px import os import pickle import torch from torch.ut...
9,686
39.701681
222
py
ClassDistributionPrediction
ClassDistributionPrediction-main/cluster_priors/distance_prior_regression.py
from ast import parse from lib2to3.pytree import LeafPattern from logging.config import stopListening from pydoc import cli from re import L, X from sklearn.linear_model import LinearRegression, LogisticRegression from sklearn.multioutput import MultiOutputClassifier from tkinter.font import names from xmlrpc.client im...
11,815
43.089552
251
py
polish-sentence-evaluation
polish-sentence-evaluation-master/evaluate.py
import logging import os from collections import namedtuple from pathlib import Path import fire import json from typing import Union from sentevalpl.tasks import get_task_names from utils.analyzer import PolishAnalyzer from methods.base import EmbeddingBase from methods.utils import cached from sentevalpl.engine im...
7,103
40.788235
111
py
polish-sentence-evaluation
polish-sentence-evaluation-master/methods/huggingface.py
from typing import List import numpy as np import torch.cuda import torch.nn.functional as F from transformers import AutoConfig, AutoTokenizer, AutoModel from methods.base import EmbeddingBase class HuggingfaceModelEmbedding(EmbeddingBase): def __init__(self, model_name_or_path: str, layers:str="top", mini_bat...
2,173
41.627451
119
py
polish-sentence-evaluation
polish-sentence-evaluation-master/methods/roberta.py
import os import numpy as np from typing import List from torch import Tensor, hub from methods.base import EmbeddingBase from fairseq.models.roberta import RobertaModel, RobertaHubInterface from fairseq import hub_utils class RobertaEmbedding(EmbeddingBase): def __init__(self, path: str, layers:str="top", bpe:...
3,165
40.116883
118
py
polish-sentence-evaluation
polish-sentence-evaluation-master/examples/paraphrase_mining/run_mining.py
import logging import os import random import zipfile import json from collections import Counter, defaultdict from typing import List, TextIO, Dict import fire import requests from sentence_transformers import SentenceTransformer, util from thefuzz import fuzz from tqdm import tqdm from lsm import LSM from examples.pa...
9,793
38.651822
116
py
polish-sentence-evaluation
polish-sentence-evaluation-master/extensions/LSTMPooling.py
import torch from torch import Tensor from torch import nn from typing import Dict import os import json class LSTMPooling(nn.Module): def __init__(self, word_embedding_dimension, hidden_size, bidirectional=False): super(LSTMPooling, self).__init__() self.config_keys = ['word_embedding_dimension'...
2,205
39.109091
126
py
polish-sentence-evaluation
polish-sentence-evaluation-master/sentevalpl/engine.py
from __future__ import absolute_import, division, unicode_literals from senteval import utils from sentevalpl.pairs_classification import RelatednessEval, EntailmentEval, PPCEval from sentevalpl.classifier import SentEvalClassifier from sentevalpl.tasks import get_task_names, get_task_by_name class SE(object): d...
2,213
43.28
134
py
polish-sentence-evaluation
polish-sentence-evaluation-master/sentevalpl/classifier.py
import logging import os import numpy as np from senteval.tools.validation import SplitClassifier class SentEvalClassifier(object): def __init__(self, task_path: str, task_name: str, nclasses: int, seed=1111): self.seed = seed self.nclasses = nclasses self.task_name = task_name lo...
2,973
40.887324
120
py
polish-sentence-evaluation
polish-sentence-evaluation-master/sentevalpl/pairs_classification.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ''' Relatedness and Entailment tasks ''' from __future__ import absolute_import, division, unicode_literals import os import i...
10,482
40.109804
88
py
WPAL-network
WPAL-network-master/tools/test_net.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the te...
4,084
33.618644
84
py
WPAL-network
WPAL-network-master/tools/estimate_param.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the ter...
4,914
35.679104
112
py
WPAL-network
WPAL-network-master/tools/_init_path.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the ter...
1,529
29
73
py
WPAL-network
WPAL-network-master/tools/loc.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the te...
13,043
44.291667
150
py
WPAL-network
WPAL-network-master/tools/test_net_WS_BL.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the te...
4,078
33.567797
84
py
WPAL-network
WPAL-network-master/tools/train_net.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the te...
4,409
34.853659
117
py
WPAL-network
WPAL-network-master/tools/loc_BL.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the te...
6,828
38.247126
117
py
WPAL-network
WPAL-network-master/lib/data_layer/layer.py
#!/usr/bin/env python #!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or mod...
7,090
37.961538
184
py
WPAL-network
WPAL-network-master/lib/data_layer/minibatch.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the ter...
3,991
34.963964
80
py
WPAL-network
WPAL-network-master/lib/WS_BL/recog.py
import math import cv2 import numpy as np from utils.blob import img_list_to_blob from config import cfg class ResizedImageTooLargeException(Exception): pass class ResizedSideTooShortException(Exception): pass def _get_image_blob(img, neglect): """Converts an image into a network input. Argument...
4,633
32.1
93
py
WPAL-network
WPAL-network-master/lib/WS_BL/config.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the ter...
6,652
28.30837
82
py
WPAL-network
WPAL-network-master/lib/WS_BL/train.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the ter...
4,383
36.152542
93
py