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 |
|---|---|---|---|---|---|---|
PalmTree | PalmTree-master/src/extrinsic_evaluation/gemini/embedding/siamese_emb.py | import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
flags = tf.app.flags
FLAGS = flags.FLAGS
class Siamese:
#calculate embedding
def emb_generation(self, x, n):
mul_mat = x[:, FLAGS.vector_size:]
x = x[:, :FLAGS.vector_size]
# tf.reset_default_grap... | 8,987 | 43.49505 | 145 | py |
PalmTree | PalmTree-master/src/extrinsic_evaluation/EKLAVYA/code/RNN/train/train_rnn.py | import argparse
import functools
import inspect
import os
import sys
import pickle
import dataset
import dataset_caller
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
def lazy_property(function):
attribute = '_' + function.__name__
@property
@functools.wraps(fun... | 17,058 | 39.811005 | 176 | py |
PalmTree | PalmTree-master/src/extrinsic_evaluation/EKLAVYA/code/RNN/train/data_loader.py | """"
Here we implement a class for loading data.
"""
import torch
from torch.autograd import Variable
from vocab import *
from config import *
import numpy as np
import random
import re
np.random.seed(0)
class DataLoader:
EOS = 0 # to mean end of sentence
UNK = 1 # to mean unknown token
maxlen = MAXL... | 3,294 | 30.682692 | 113 | py |
PalmTree | PalmTree-master/src/extrinsic_evaluation/EKLAVYA/code/RNN/train/model.py | """
This file implements the Skip-Thought architecture.
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from config import *
import math
import numpy as np
class Encoder(nn.Module):
thought_size = 128
word_size = 256
@staticmethod
def reverse... | 13,287 | 42.710526 | 180 | py |
PalmTree | PalmTree-master/src/extrinsic_evaluation/EKLAVYA/code/RNN/train/transformer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
from torch.autograd import Variable
from config import *
import numpy as np
import bert_pytorch
from bert_pytorch import dataset
from bert_pytorch import trainer
import pickle as pkl
vocab_path = "data/test_vocab... | 1,971 | 31.866667 | 117 | py |
PalmTree | PalmTree-master/src/extrinsic_evaluation/EKLAVYA/code/RNN/train/train.py | import os
try:
os.chdir(os.path.join(os.getcwd(), 'src/skip-thoughts'))
print(os.getcwd())
except:
pass
import torch
from torch import nn
from torch.autograd import Variable
import re
import pickle
import random
import numpy as np
from data_loader import DataLoader
from model import UniSkip
from config import *
from... | 3,112 | 27.824074 | 92 | py |
PalmTree | PalmTree-master/src/extrinsic_evaluation/EKLAVYA/code/RNN/train/eval_utils.py | # from model import UniSkip, Encoder
from data_loader import DataLoader
from vocab import load_dictionary
from config import *
from torch import nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch
import re
import numpy as np
import pickle
class UsableTransformer:
# @profile
d... | 1,766 | 29.465517 | 63 | py |
PalmTree | PalmTree-master/pre-trained_model/vocab.py | import pickle
import tqdm
from collections import Counter
class TorchVocab(object):
"""Defines a vocabulary object that will be used to numericalize a field.
Attributes:
freqs: A collections.Counter object holding the frequencies of tokens
in the data used to build the Vocab.
stoi:... | 6,753 | 35.311828 | 93 | py |
PalmTree | PalmTree-master/pre-trained_model/how2use.py | import os
from config import *
from torch import nn
from scipy.ndimage.filters import gaussian_filter1d
from torch.autograd import Variable
import torch
import numpy as np
import eval_utils as utils
palmtree = utils.UsableTransformer(model_path="./palmtree/transformer.ep19", vocab_path="./palmtree/vocab")
# tokens h... | 736 | 26.296296 | 107 | py |
PalmTree | PalmTree-master/pre-trained_model/eval_utils.py | from torch.autograd import Variable
import torch
import re
import numpy
from torch import nn
import torch.nn.functional as F
from config import *
import vocab
# this function is how I parse and pre-pocess instructions for palmtree. It is very simple and based on regular expressions.
# If I use IDA pro or angr inst... | 3,712 | 34.361905 | 125 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/main.py | import sys
from timeit import default_timer as timer
from utils.cli_parser import parse_cli_overides
from utils.config import get_dataset
from learning.preprocess import Preprocess
from utils.ddp_init import cleanup, spawn_nproc, setup
import torch
from utils.common import prepare_train_id
from learning import initiali... | 2,506 | 33.342466 | 104 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/data.py | from pathlib import Path
import os
import pandas as pd
import h5py
import numpy as np
import torch
from torch.utils.data import Dataset
from utils.common import int16_samples_to_float32
class BaseDataset(Dataset):
""" User defined datset
"""
def __init__(self, args, cfg, dataset):
"""
Ar... | 3,767 | 34.54717 | 126 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/feature.py | import torch
import torch.nn as nn
import librosa
import numpy as np
from methods.utils.stft import (STFT, LogmelFilterBank, intensityvector,
spectrogram_STFTInput)
import math
def nCr(n, r):
return math.factorial(n) // math.factorial(r) // math.factorial(n-r)
class LogmelIntensity... | 7,445 | 42.040462 | 127 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/stft.py | import math
import librosa
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from librosa import ParameterError
from torch.nn.parameter import Parameter
eps = torch.finfo(torch.float32).eps
class DFTBase(nn.Module):
def __init__(self):
"""Base class for DFT and IDFT ma... | 31,480 | 34.174302 | 107 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/model_utilities.py | import numpy as np
import torch
import torch.nn as nn
def init_layer(layer, nonlinearity='leaky_relu'):
'''
Initialize a layer
'''
classname = layer.__class__.__name__
if (classname.find('Conv') != -1) or (classname.find('Linear') != -1):
nn.init.kaiming_uniform_(layer.weight, nonlinearity... | 3,157 | 33.703297 | 96 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/loss_utilities.py | import torch
import torch.nn as nn
import torch.nn.functional as F
eps = torch.finfo(torch.float32).eps
class MSELoss:
def __init__(self, reduction='mean'):
self.reduction = reduction
self.name = 'loss_MSE'
if self.reduction != 'PIT':
self.loss = nn.MSELoss(reduction='mean')
... | 1,222 | 31.184211 | 93 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/dense_block.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
class _DenseLayer(nn.Module):
def __init__(self, num_input_features, growth_rate, bn_size, drop_rate, dilation):
super(_DenseLayer, self).__init__()
self.add_module('norm1', nn.BatchNorm2d(num_input_feature... | 4,940 | 40.175 | 95 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/data_utilities.py | import numpy as np
import pandas as pd
import torch
def _segment_index(x, chunklen, hoplen, last_frame_always_paddding=False):
"""Segment input x with chunklen, hoplen parameters. Return
Args:
x: input, time domain or feature domain (channels, time)
chunklen:
hoplen:
last_fram... | 15,990 | 46.734328 | 157 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/embedding.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 1,861 | 41.318182 | 98 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/activation.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 1,588 | 35.113636 | 119 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/modules.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 2,540 | 32.434211 | 97 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/model.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 9,594 | 41.268722 | 119 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/encoder.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 10,007 | 40.7 | 118 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/convolution.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 7,029 | 36.195767 | 115 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/feed_forward.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 2,117 | 34.3 | 119 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/decoder.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 5,064 | 37.664122 | 119 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/utils/conformer/attention.py | # Copyright (c) 2021, Soohwan Kim. 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 at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | 6,428 | 40.746753 | 117 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/ein_seld/inference.py | from pathlib import Path
import h5py
import numpy as np
import torch
from tqdm import tqdm
from methods.inference import BaseInferer
from methods.utils.data_utilities import *
class Inferer(BaseInferer):
def __init__(self, cfg, dataset, af_extractor, model, cuda, test_set=None):
super().__init__()
... | 5,046 | 40.710744 | 137 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/ein_seld/losses.py | import numpy as np
import torch
import sys
from methods.utils.loss_utilities import BCEWithLogitsLoss, MSELoss
from torch import linalg as LA
from itertools import permutations
class Losses:
def __init__(self, cfg):
self.cfg = cfg
self.beta = cfg['training']['loss_beta']
self.losses = [BCEW... | 3,138 | 41.418919 | 114 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/ein_seld/training.py | from pathlib import Path
import random
import sys
from timeit import default_timer as timer
import h5py
import numpy as np
import torch
from methods.training import BaseTrainer
from utils.ddp_init import reduce_value, gather_value, get_rank, get_world_size
from methods.utils.data_utilities import track_to_dcase_format... | 8,056 | 41.856383 | 141 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/ein_seld/data.py | from pathlib import Path
import pandas as pd
from timeit import default_timer as timer
import h5py
import numpy as np
import torch
from methods.utils.data_utilities import load_output_format_file, to_metrics_format
from torch.utils.data import Dataset, Sampler
from utils.common import int16_samples_to_float32
from ut... | 12,771 | 44.29078 | 130 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/ein_seld/models/ConvConformer.py | import torch
import torch.nn as nn
from methods.utils.model_utilities import (DoubleConv, init_layer)
from methods.utils.conformer.encoder import ConformerBlocks
class ConvConformer(nn.Module):
def __init__(self, cfg, dataset):
super().__init__()
self.cfg = cfg
self.num_classes = dataset.n... | 7,746 | 44.840237 | 85 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/ein_seld/models/ConvTransformer.py | import torch
import torch.nn as nn
from methods.utils.model_utilities import (DoubleConv, PositionalEncoding,
init_layer)
class ConvTransformer(nn.Module):
def __init__(self, cfg, dataset):
super().__init__()
self.pe_enable = False # Ture | False
... | 8,566 | 46.594444 | 110 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/methods/ein_seld/models/DenseConformer.py | import torch
import torch.nn as nn
from methods.utils.model_utilities import init_layer
from methods.utils.conformer.encoder import ConformerBlocks
from methods.utils.dense_block import _DenseBlock, _Transition
class DenseConformer(nn.Module):
def __init__(self, cfg, dataset):
super().__init__()
se... | 9,821 | 50.968254 | 128 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/learning/checkpoint.py | import logging
import random
import numpy as np
import pandas as pd
import torch
from utils.ddp_init import get_rank, get_world_size
class CheckpointIO:
"""CheckpointIO class.
It handles saving and loading checkpoints.
"""
def __init__(self, checkpoints_dir, model, optimizer, batch_sampler, metric... | 7,008 | 40.97006 | 124 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/learning/initialize.py | import logging
import random
import shutil
import socket
from datetime import datetime
from pathlib import Path
import numpy as np
import torch
import torch.distributed as dist
import torch.optim as optim
from torch.backends import cudnn
from torch.nn.parallel import DistributedDataParallel as DDP
from torch.utils.ten... | 7,430 | 37.304124 | 140 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/learning/infer.py | import torch
from utils.config import get_afextractor, get_inferer, get_models
def infer(cfg, dataset, **infer_initializer):
""" Infer, only save the testset predictions
"""
submissions_dir = infer_initializer['submissions_dir']
predictions_dir = infer_initializer['predictions_dir']
ckpts_paths_... | 1,270 | 38.71875 | 80 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/learning/preprocess.py | import shutil
import sys
from functools import reduce
from pathlib import Path
from timeit import default_timer as timer
import h5py
import librosa
import numpy as np
import pandas as pd
import torch
from sklearn import preprocessing
from torch.utils.data import DataLoader
from tqdm import tqdm
from methods.data impo... | 28,736 | 55.90495 | 158 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/utils/ddp_init.py | import torch
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
import torch.multiprocessing as mp
import os
def get_world_size():
if dist.is_initialized():
return dist.get_world_size()
else:
return 1
def get_rank():
if dist.is_initialized():
... | 1,671 | 27.827586 | 73 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/utils/config.py | from utils.datasets import dacase2022_dask3
from methods import ein_seld
from torch.utils.data import DataLoader
import torch.distributed as dist
from ruamel.yaml import YAML
import logging
from utils.common import convert_ordinal, count_parameters, move_model_to_gpu
import methods.feature as feature
import torch.optim... | 6,513 | 33.104712 | 106 | py |
DCASE2022-TASK3 | DCASE2022-TASK3-main/code/utils/common.py | import numpy as np
import torch
import logging
from datetime import datetime
from tqdm import tqdm
import math
import torch.distributed as dist
import shutil
from pathlib import Path
from .ddp_init import get_rank, get_world_size
def float_samples_to_int16(y):
"""Convert floating-point numpy array of audio samples ... | 4,202 | 29.904412 | 90 | py |
OpenPSG | OpenPSG-main/setup.py | #!/usr/bin/env python
# Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import platform
import shutil
import sys
import warnings
from setuptools import find_packages, setup
import torch
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
... | 7,887 | 35.518519 | 125 | py |
OpenPSG | OpenPSG-main/ce7454/main.py | import argparse
import os
import time
import torch
from dataset import PSGClsDataset
from evaluator import Evaluator
from torch.utils.data import DataLoader
from torchvision.models import resnet50
from trainer import BaseTrainer
parser = argparse.ArgumentParser()
parser.add_argument('--model_name', type=str, default=... | 3,628 | 33.561905 | 116 | py |
OpenPSG | OpenPSG-main/ce7454/dataset.py | import io
import json
import logging
import os
import torch
import torchvision.transforms as trn
from PIL import Image, ImageFile
from torch.utils.data import Dataset
# to fix "OSError: image file is truncated"
ImageFile.LOAD_TRUNCATED_IMAGES = True
class Convert:
def __init__(self, mode='RGB'):
self.mo... | 2,352 | 26.682353 | 65 | py |
OpenPSG | OpenPSG-main/ce7454/evaluator.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
class Evaluator:
def __init__(
self,
net: nn.Module,
k: int,
):
self.net = net
self.k = k
def eval_recall(
self,
data_loade... | 2,442 | 30.727273 | 76 | py |
OpenPSG | OpenPSG-main/ce7454/trainer.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
from tqdm import tqdm
def cosine_annealing(step, total_steps, lr_max, lr_min):
return lr_min + (lr_max -
lr_min) * 0.5 * (1 + np.cos(step / total_steps * np.pi))
cla... | 2,273 | 30.150685 | 77 | py |
OpenPSG | OpenPSG-main/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 grade import save_results
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
f... | 9,830 | 39.126531 | 112 | py |
OpenPSG | OpenPSG-main/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 mm... | 8,188 | 35.234513 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/evaluation/sgg_eval.py | # ---------------------------------------------------------------
# vg_eval.py
# Set-up time: 2020/5/18 上午9:48
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ------... | 11,583 | 33.47619 | 83 | py |
OpenPSG | OpenPSG-main/openpsg/evaluation/sgg_metrics.py | # ---------------------------------------------------------------
# sgg_eval.py
# Set-up time: 2020/5/18 上午9:49
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# -----... | 43,520 | 39.826454 | 128 | py |
OpenPSG | OpenPSG-main/openpsg/models/roi_extractors/visual_spatial.py | # ---------------------------------------------------------------
# visual_spatial.py
# Set-up time: 2020/4/28 下午8:46
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
#... | 23,631 | 41.275492 | 84 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/motif_head.py | # ---------------------------------------------------------------
# motif_head.py
# Set-up time: 2020/4/27 下午8:08
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ---... | 6,943 | 38.908046 | 87 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/gps_head.py | # ---------------------------------------------------------------
# gps_head.py
# Set-up time: 2021/3/31 17:13
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ------... | 6,890 | 41.801242 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/imp_head.py | # ---------------------------------------------------------------
# imp_head.py
# Set-up time: 2020/5/21 下午11:22
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ----... | 3,996 | 40.635417 | 87 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/psgformer_head.py | # Copyright (c) OpenMMLab. All rights reserved.
from collections import defaultdict
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
from mmcv.cnn import Conv2d, Linear, build_activation_layer
from mmcv.cnn.bricks.transformer import build_positional_encoding
from mmcv.runner import... | 59,405 | 44.979876 | 119 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/relation_head.py | import copy
import itertools
import mmcv
import numpy as np
import torch
import torch.nn.functional as F
from mmcv.runner import BaseModule
from mmdet.core import bbox2roi
from mmdet.models import HEADS, builder
from mmdet.models.losses import accuracy
from .approaches import (FrequencyBias, PostProcessor, RelationSa... | 18,539 | 41.136364 | 131 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/vctree_head.py | # ---------------------------------------------------------------
# vctree_head.py
# Set-up time: 2020/6/4 上午9:35
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ---... | 7,052 | 40.005814 | 87 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/psgtr_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import time
from collections import defaultdict
from inspect import signature
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
from mmcv.cnn import Conv2d, Linear, build_activation_layer
from mmcv.cnn.bricks.transformer import FFN, bu... | 64,402 | 46.600148 | 189 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/detr4seg_head.py | # Copyright (c) OpenMMLab. All rights reserved.
import time
from collections import defaultdict
from inspect import signature
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
from mmcv.cnn import Conv2d, Linear, build_activation_layer
from mmcv.cnn.bricks.transformer import FFN, bu... | 41,053 | 43.049356 | 108 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/vctree_util.py | # ---------------------------------------------------------------
# vctree_util.py
# Set-up time: 2020/6/4 下午3:43
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ---... | 15,131 | 32.330396 | 105 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/imp.py | # ---------------------------------------------------------------
# imp.py
# Set-up time: 2020/5/21 下午11:26
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ---------... | 5,667 | 38.915493 | 78 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/pointnet.py | # ---------------------------------------------------------------
# pointnet.py
# Set-up time: 2020/10/6 23:24
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ------... | 7,176 | 33.671498 | 75 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/dmp.py | # ---------------------------------------------------------------
# dmp.py
# Set-up time: 2020/10/7 22:23
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# -----------... | 6,337 | 39.113924 | 76 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/motif_util.py | # ---------------------------------------------------------------
# motif_util.py
# Set-up time: 2020/5/4 下午4:36
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ----... | 11,894 | 36.40566 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/matcher.py | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmdet.core import AssignResult, BaseAssigner, bbox_cxcywh_to_xyxy
from mmdet.core.bbox.builder import BBOX_ASSIGNERS
from mmdet.core.bbox.match_costs import build_match_cost
try:
from scipy.optimize import linear_sum_assignment
except ImportError:
... | 9,976 | 45.404651 | 78 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/relation_ranker.py | # ---------------------------------------------------------------
# relation_ranker.py
# Set-up time: 2021/5/11 16:21
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
#... | 8,696 | 41.014493 | 126 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/relation_util.py | # ---------------------------------------------------------------
# relation_util.py
# Set-up time: 2020/5/7 下午11:13
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ... | 28,570 | 41.707025 | 123 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/sampling.py | # ---------------------------------------------------------------
# sampling.py
# Set-up time: 2020/5/7 下午4:31
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ------... | 18,035 | 46.968085 | 120 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/motif.py | # ---------------------------------------------------------------
# motif.py
# Set-up time: 2020/5/4 下午4:31
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# ---------... | 19,918 | 41.112051 | 102 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/treelstm_util.py | # ---------------------------------------------------------------
# treelstm_util.py
# Set-up time: 2020/6/4 下午4:42
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# -... | 15,090 | 41.271709 | 99 | py |
OpenPSG | OpenPSG-main/openpsg/models/relation_heads/approaches/vctree.py | # ---------------------------------------------------------------
# vctree.py
# Set-up time: 2020/6/4 上午10:22
# Copyright (c) 2020 ICT
# Licensed under The MIT License [see LICENSE for details]
# Written by Kenneth-Wong (Wenbin-Wang) @ VIPL.ICT
# Contact: wenbin.wang@vipl.ict.ac.cn [OR] nkwangwenbin@gmail.com
# -------... | 16,755 | 41.206549 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/models/frameworks/dual_transformer.py | import torch
from mmcv.cnn import xavier_init
from mmcv.cnn.bricks.transformer import build_transformer_layer_sequence
from mmcv.runner.base_module import BaseModule
from mmdet.models.utils.builder import TRANSFORMER
@TRANSFORMER.register_module()
class DualTransformer(BaseModule):
"""Modify the DETR transformer ... | 4,484 | 45.237113 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/models/frameworks/psgtr.py | # Copyright (c) OpenMMLab. All rights reserved.
import warnings
import mmcv
import numpy as np
import torch
import torch.nn.functional as F
from detectron2.utils.visualizer import VisImage, Visualizer
from mmdet.datasets.coco_panoptic import INSTANCE_OFFSET
from mmdet.models import DETECTORS, SingleStageDetector
from... | 6,062 | 39.152318 | 104 | py |
OpenPSG | OpenPSG-main/openpsg/models/frameworks/detr4seg.py | # Copyright (c) OpenMMLab. All rights reserved.
import imghdr
import random
import time
import warnings
from turtle import shape
import cv2
import matplotlib.pyplot as plt
import mmcv
import numpy as np
import torch
import torch.nn.functional as F
from detectron2.utils.visualizer import VisImage, Visualizer
from mmdet... | 11,322 | 35.525806 | 85 | py |
OpenPSG | OpenPSG-main/openpsg/models/frameworks/sg_panoptic_fpn.py | import mmcv
import numpy as np
import torch
import torch.nn.functional as F
from detectron2.utils.visualizer import VisImage, Visualizer
from mmdet.core import BitmapMasks, bbox2roi, build_assigner, multiclass_nms
from mmdet.datasets.coco_panoptic import INSTANCE_OFFSET
from mmdet.models import DETECTORS, PanopticFPN
f... | 35,038 | 34.003996 | 88 | py |
OpenPSG | OpenPSG-main/openpsg/models/frameworks/sg_rcnn.py | import mmcv
import numpy as np
import torch
import torch.nn.functional as F
from detectron2.utils.visualizer import VisImage, Visualizer
from mmdet.core import bbox2roi, build_assigner
from mmdet.models import DETECTORS, TwoStageDetector
from mmdet.models.builder import build_head
from openpsg.models.relation_heads.ap... | 23,736 | 35.462366 | 112 | py |
OpenPSG | OpenPSG-main/openpsg/models/roi_heads/bbox_heads/sg_bbox_head.py | import torch.nn.functional as F
from mmcv.runner import force_fp32
from mmdet.models import Shared2FCBBoxHead
from mmdet.models.builder import HEADS
from openpsg.utils.utils import multiclass_nms_alt
@HEADS.register_module()
class SceneGraphBBoxHead(Shared2FCBBoxHead):
@force_fp32(apply_to=('cls_score', 'bbox_pr... | 3,107 | 36.445783 | 78 | py |
OpenPSG | OpenPSG-main/openpsg/models/losses/seg_losses.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmdet.models.builder import LOSSES
from mmdet.models.losses.utils import weighted_loss
#@mmcv.jit(derivate=True, coderize=True)
@weighted_loss
def dice_loss(input, target, mask=None, eps=0.001):
N, H, W = input.shape
input = input.contig... | 5,046 | 34.542254 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/datasets/psg.py | import os.path as osp
import random
from collections import defaultdict
import mmcv
import numpy as np
import torch
from detectron2.data.detection_utils import read_image
from mmdet.datasets import DATASETS, CocoPanopticDataset
from mmdet.datasets.coco_panoptic import COCOPanoptic
from mmdet.datasets.pipelines import ... | 15,541 | 34.083521 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/datasets/builder.py | # Copyright (c) OpenMMLab. All rights reserved.
import platform
from mmcv.utils import Registry, build_from_cfg
from mmdet.datasets import DATASETS as MMDET_DATASETS
from mmdet.datasets.builder import _concat_dataset
if platform.system() != 'Windows':
# https://github.com/pytorch/pytorch/issues/973
import res... | 1,841 | 40.863636 | 79 | py |
OpenPSG | OpenPSG-main/openpsg/utils/utils.py | from typing import Tuple
import os.path as osp
import PIL
import mmcv
import mmcv.ops as ops
import numpy as np
import torch
from detectron2.utils.colormap import colormap
from detectron2.utils.visualizer import VisImage, Visualizer
from mmdet.datasets.coco_panoptic import INSTANCE_OFFSET
import matplotlib.pyplot as pl... | 16,860 | 31.676357 | 90 | py |
OpenPSG | OpenPSG-main/openpsg/utils/vis_tools/detectron_viz.py | import colorsys
import math
import cv2
import matplotlib as mpl
import matplotlib.colors as mplc
import numpy as np
import pycocotools.mask as mask_util
import torch
from detectron2.data.catalog import MetadataCatalog
from detectron2.structures import (BitMasks, Boxes, BoxMode, Keypoints,
... | 41,496 | 41.343878 | 100 | py |
OpenPSG | OpenPSG-main/configs/gpsnet/panoptic_fpn_r101_fpn_1x_sgdet_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_sgdet_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'gpsnet_panoptic_fpn_r101_fpn_1x_sgdet_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config = di... | 671 | 23.888889 | 94 | py |
OpenPSG | OpenPSG-main/configs/gpsnet/panoptic_fpn_r101_fpn_1x_predcls_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_predcls_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'gpsnet_panoptic_fpn_r101_fpn_1x_predcls_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config ... | 675 | 24.037037 | 94 | py |
OpenPSG | OpenPSG-main/configs/imp/panoptic_fpn_r101_fpn_1x_sgdet_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_sgdet_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'imp_panoptic_fpn_r101_fpn_1x_sgdet_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config = dict(... | 668 | 23.777778 | 94 | py |
OpenPSG | OpenPSG-main/configs/imp/panoptic_fpn_r101_fpn_1x_predcls_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_predcls_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'imp_panoptic_fpn_r101_fpn_1x_predcls_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config = d... | 765 | 25.413793 | 94 | py |
OpenPSG | OpenPSG-main/configs/vctree/panoptic_fpn_r101_fpn_1x_sgdet_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_sgdet_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'vctree_panoptic_fpn_r101_fpn_1x_sgdet_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config = di... | 764 | 25.37931 | 94 | py |
OpenPSG | OpenPSG-main/configs/vctree/panoptic_fpn_r101_fpn_1x_predcls_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_predcls_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'vctree_panoptic_fpn_r101_fpn_1x_predcls_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config ... | 768 | 25.517241 | 94 | py |
OpenPSG | OpenPSG-main/configs/psgtr/psgtr_r50.py | model = dict(
type='PSGTr',
backbone=dict(type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=False),
norm_eval=True,
... | 4,523 | 53.506024 | 77 | py |
OpenPSG | OpenPSG-main/configs/_base_/models/psgtr_r50.py | model = dict(
type='PSGTr',
backbone=dict(type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=False),
norm_eval=True,
... | 4,523 | 53.506024 | 77 | py |
OpenPSG | OpenPSG-main/configs/_base_/models/mask_rcnn_r50_fpn.py | # model settings
model = dict(
type='MaskRCNN',
backbone=dict(type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True... | 5,776 | 52.490741 | 77 | py |
OpenPSG | OpenPSG-main/configs/_base_/models/detr4seg_r101.py | model = dict(
type='DETR4seg',
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=False),
norm_eval=True,
... | 3,394 | 51.230769 | 77 | py |
OpenPSG | OpenPSG-main/configs/_base_/models/detr4seg_r50.py | model = dict(
type='DETR4seg',
backbone=dict(type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=False),
norm_eval=True,
... | 3,471 | 51.606061 | 77 | py |
OpenPSG | OpenPSG-main/configs/_base_/models/psgtr_r101.py | _base_ = './psgtr_r50.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
| 147 | 23.666667 | 76 | py |
OpenPSG | OpenPSG-main/configs/_base_/models/panoptic_fpn_r101_fpn_psg.py | _base_ = './panoptic_fpn_r50_fpn_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
expt_name = 'panoptic_fpn_r101_fpn_psg'
load_from = 'work_dirs/checkpoints/panoptic_fpn_r101_fpn_1x_coco_20210820_193950-ab9157a2.pth'
| 298 | 32.222222 | 94 | py |
OpenPSG | OpenPSG-main/configs/_base_/models/detr_r50.py | model = dict(
type='DETR',
backbone=dict(type='ResNet',
depth=50,
num_stages=4,
out_indices=(3, ),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=False),
norm_eval=True,
style='... | 3,360 | 50.707692 | 77 | py |
OpenPSG | OpenPSG-main/configs/psgformer/psgformer_r101_psg.py | _base_ = './psgformer_r50_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# learning policy
lr_config = dict(policy='step', step=48)
runner = dict(type='EpochBasedRunner', max_epochs=60)
project_name = 'psgformer'
expt_name = 'psgformer_... | 488 | 27.764706 | 76 | py |
OpenPSG | OpenPSG-main/configs/psgformer/psgformer_r50.py | model = dict(
type='PSGTr',
backbone=dict(type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=False),
norm_eval=True,
... | 5,041 | 50.979381 | 79 | py |
OpenPSG | OpenPSG-main/configs/motifs/panoptic_fpn_r101_fpn_1x_sgdet_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_sgdet_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'motifs_panoptic_fpn_r101_fpn_1x_sgdet_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config = di... | 764 | 25.37931 | 94 | py |
OpenPSG | OpenPSG-main/configs/motifs/panoptic_fpn_r101_fpn_1x_predcls_psg.py | _base_ = './panoptic_fpn_r50_fpn_1x_predcls_psg.py'
model = dict(backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
# Log config
project_name = 'openpsg'
expt_name = 'motifs_panoptic_fpn_r101_fpn_1x_predcls_psg'
work_dir = f'./work_dirs/{expt_name}'
log_config ... | 768 | 25.517241 | 94 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.