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 |
|---|---|---|---|---|---|---|
GCNet | GCNet-main/gcnet/loss.py | import os
import time
import glob
import pickle
import random
import argparse
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.nn.utils.rnn import pad_sequence
from torch_geometric.nn import RGCNConv, GraphConv
## for reconstruction [... | 3,568 | 35.418367 | 98 | py |
GCNet | GCNet-main/gcnet/model.py | import os
import time
import glob
import pickle
import random
import argparse
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.nn.utils.rnn import pad_sequence
from torch_geometric.nn import RGCNConv, GraphConv
from module import *
fr... | 6,538 | 39.86875 | 124 | py |
GCNet | GCNet-main/gcnet/module.py | import os
import time
import glob
import pickle
import random
import argparse
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.nn.utils.rnn import pad_sequence
from torch_geometric.nn import RGCNConv, GraphConv
cl... | 4,749 | 41.792793 | 108 | py |
GCNet | GCNet-main/gcnet/graph.py | import os
import time
import glob
import pickle
import random
import argparse
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.nn.utils.rnn import pad_sequence
from torch_geometric.nn import RGCNConv, GraphConv
de... | 4,988 | 33.406897 | 106 | py |
GCNet | GCNet-main/gcnet/train_gcnet.py | import os
import time
import glob
import math
import pickle
import random
import argparse
import numpy as np
from numpy.random import randint
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
from torch.utils.data.sampler import SubsetRandomSampler
from sklearn.metr... | 29,188 | 50.570671 | 164 | py |
GCNet | GCNet-main/gcnet/dataloader_cmumosi.py | import os
import time
import glob
import tqdm
import pickle
import random
import argparse
import numpy as np
import pandas as pd
import torch
from torch.utils.data import Dataset
from torch.nn.utils.rnn import pad_sequence
## gain name2features [only one speaker]
## videoLabels: from [-3, 3], type=float
def read_dat... | 6,527 | 39.296296 | 182 | py |
GCNet | GCNet-main/baseline-mmin/models/uttf_dataaug_model.py |
import torch
import os
import json
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClassifier
class UttFDataAugModel(BaseM... | 7,112 | 45.490196 | 134 | py |
GCNet | GCNet-main/baseline-mmin/models/mmin_model.py | import torch
import os
import json
from collections import OrderedDict
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClassi... | 11,679 | 54.09434 | 135 | py |
GCNet | GCNet-main/baseline-mmin/models/base_model.py | import os
import torch
from collections import OrderedDict
from abc import ABC, abstractmethod
from .networks import tools
class BaseModel(ABC):
"""This class is an abstract base class (ABC) for models.
To create a subclass, you need to implement the following five functions:
-- <__init__>: ... | 10,973 | 42.721116 | 260 | py |
GCNet | GCNet-main/baseline-mmin/models/utt_fusion_model.py | import torch
import os
import json
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClassifier
class UttFusionModel(BaseMode... | 7,369 | 48.797297 | 134 | py |
GCNet | GCNet-main/baseline-mmin/models/mmin_old_model.py | import torch
import os
import json
from collections import OrderedDict
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClassi... | 10,447 | 53.989474 | 135 | py |
GCNet | GCNet-main/baseline-mmin/models/lstm_audio_model.py |
import torch
import os
import json
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.lstm import LSTMEncoder
from models.networks.fc_encoder import FcEncoder
class LSTMAudioModel(BaseModel):
'''
A: DNN
V: denseface + LSTM + maxpool
L: bert + textcnn
'''
... | 3,310 | 39.876543 | 108 | py |
GCNet | GCNet-main/baseline-mmin/models/mmin_AE_model.py | import torch
import os
import json
from collections import OrderedDict
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClassi... | 8,665 | 53.1625 | 135 | py |
GCNet | GCNet-main/baseline-mmin/models/mmin_ablation_model.py |
import torch
import os
import json
from collections import OrderedDict
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClass... | 10,052 | 53.63587 | 135 | py |
GCNet | GCNet-main/baseline-mmin/models/mmin_no_cycle_model.py |
import torch
import os
import json
from collections import OrderedDict
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClass... | 9,130 | 53.35119 | 135 | py |
GCNet | GCNet-main/baseline-mmin/models/mmin_CRA_model.py | import torch
import os
import json
from collections import OrderedDict
import torch.nn.functional as F
from models.base_model import BaseModel
from models.networks.fc import FcEncoder
from models.networks.lstm import LSTMEncoder
from models.networks.textcnn import TextCNN
from models.networks.classifier import FcClassi... | 8,754 | 52.384146 | 135 | py |
GCNet | GCNet-main/baseline-mmin/models/networks/fc.py | import torch
import torch.nn as nn
class FcEncoder(nn.Module):
def __init__(self, input_dim, layers, dropout=0.5, use_bn=False):
''' Fully Connect classifier
fc+relu+bn+dropout, 最后分类128-4层是直接fc的
Parameters:
--------------------------
input_dim: input feature ... | 1,113 | 34.935484 | 96 | py |
GCNet | GCNet-main/baseline-mmin/models/networks/lstm.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class LSTMEncoder(nn.Module):
''' one directional LSTM encoder
'''
def __init__(self, input_size, hidden_size, embd_method='last'):
super(LSTMEncoder, self).__init__()
self.input_size = input_size
self.hidden_size =... | 2,679 | 43.666667 | 113 | py |
GCNet | GCNet-main/baseline-mmin/models/networks/textcnn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class TextCNN(nn.Module):
def __init__(self, input_dim, emb_size=128, in_channels=1, out_channels=128, kernel_heights=[3,4,5], dropout=0.5):
super().__init__()
'''
cat((conv1-relu+conv2-relu+conv3-relu)+maxpool) + dropout, ... | 1,730 | 47.083333 | 125 | py |
GCNet | GCNet-main/baseline-mmin/models/networks/classifier.py | import torch
import torch.nn as nn
from torch.nn.utils.rnn import pad_sequence, pack_padded_sequence, pad_packed_sequence
class LSTMClassifier(nn.Module):
def __init__(self, input_size, hidden_size, fc1_size, output_size, dropout_rate):
super(LSTMClassifier, self).__init__()
self.input_size = input... | 6,538 | 36.797688 | 110 | py |
GCNet | GCNet-main/baseline-mmin/models/networks/tools.py | import torch
import torch.nn as nn
from torch.nn import init
import numpy as np
import functools
from torch.optim import lr_scheduler
class Identity(nn.Module):
def forward(self, x):
return x
def get_norm_layer(norm_type='instance'):
"""Return a normalization layer
Parameters:
norm_type ... | 7,631 | 38.340206 | 128 | py |
GCNet | GCNet-main/baseline-mmin/models/networks/autoencoder.py | import torch
import torch.nn as nn
import random
import copy
import torch.nn.functional as F
class BaseAutoencoder(nn.Module):
def __init__(self):
super().__init__()
self.encoder = nn.Sequential(
nn.Linear(128, 64),
nn.ReLU(),
nn.Linear(64, 32),
nn.Re... | 12,059 | 36.570093 | 116 | py |
GCNet | GCNet-main/baseline-mmin/opts/base_opts.py | import argparse
import os
import torch
import models
import data
import json
class BaseOptions():
"""This class defines options used during both training and test time.
It also implements several helper functions such as parsing, printing, and saving the options.
It also gathers additional options define... | 7,317 | 47.463576 | 223 | py |
GCNet | GCNet-main/baseline-mmin/preprocess/tools/bert_extractor.py | import torch
import torch.nn as nn
from transformers import BertTokenizer, BertModel
class BertExtractor(object):
def __init__(self, cuda=False, cuda_num=None):
self.tokenizer = BertTokenizer.from_pretrained('/data2/lrc/bert_cache/pytorch')
self.model = BertModel.from_pretrained('/data2/lrc/bert_ca... | 2,257 | 36.016393 | 111 | py |
GCNet | GCNet-main/baseline-mmin/preprocess/MSP/make_comparE.py | import os
import h5py
import json
import numpy as np
import pandas as pd
import scipy.signal as spsig
from torch.nn.functional import normalize
from tqdm import tqdm
class ComParEExtractor(object):
''' 抽取comparE特征, 输入音频路径, 输出npy数组, 每帧130d
'''
def __init__(self, opensmile_tool_dir=None, downsample=10, tmp_... | 4,252 | 37.663636 | 114 | py |
GCNet | GCNet-main/baseline-mmin/utils/image_pool.py | import random
import torch
class ImagePool():
"""This class implements an image buffer that stores previously generated images.
This buffer enables us to update discriminators using a history of generated images
rather than the ones produced by the latest generators.
"""
def __init__(self, pool_... | 2,226 | 39.490909 | 140 | py |
GCNet | GCNet-main/baseline-mmin/data/cmumosei_miss_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import random
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
from numpy.random import randint
from sklearn.preprocessing import OneHotEncoder
## copy... | 5,340 | 42.422764 | 150 | py |
GCNet | GCNet-main/baseline-mmin/data/melspec_dataset.py | import os
import json
import torch
import numpy as np
import h5py
import PIL
from torchvision.transforms import transforms
from data.base_dataset import BaseDataset
class MelspecDataset(BaseDataset):
@staticmethod
def modify_commandline_options(parser, isTrain=None):
parser.add_argument('--cvNo', typ... | 3,926 | 33.447368 | 103 | py |
GCNet | GCNet-main/baseline-mmin/data/msp_miss_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import random
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class MSPMissDataset(BaseDataset):
@staticmethod
def modify_commandline_options... | 4,910 | 36.776923 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/base_dataset.py | """This module implements an abstract base class (ABC) 'BaseDataset' for datasets.
It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses.
"""
import random
import numpy as np
import torch.utils.data as data
from PIL import Image
import torchvision.... | 5,389 | 32.899371 | 141 | py |
GCNet | GCNet-main/baseline-mmin/data/comparE_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class ComparEDataset(BaseDataset):
@staticmethod
def modify_commandline_options(p... | 4,316 | 35.584746 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/multimodal_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class MultimodalDataset(BaseDataset):
@staticmethod
def modify_commandline_option... | 6,499 | 40.139241 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/msp_multimodal_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class MSPMultimodalDataset(BaseDataset):
@staticmethod
def modify_commandline_opt... | 4,633 | 34.374046 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/iemocapfour_miss_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import random
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
from numpy.random import randint
from sklearn.preprocessing import OneHotEncoder
## copy... | 6,228 | 43.492857 | 150 | py |
GCNet | GCNet-main/baseline-mmin/data/iemocapsix_miss_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import random
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
from numpy.random import randint
from sklearn.preprocessing import OneHotEncoder
## copy... | 5,536 | 43.296 | 150 | py |
GCNet | GCNet-main/baseline-mmin/data/cmumosei_multimodal_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class CMUMOSEIMultimodalDataset(BaseDataset):
@staticmethod
def modify_commandlin... | 4,761 | 34.537313 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/word_aligned_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class WordAlignedDataset(BaseDataset):
@staticmethod
def modify_commandline_optio... | 5,803 | 38.216216 | 127 | py |
GCNet | GCNet-main/baseline-mmin/data/cmumosi_miss_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import random
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
from numpy.random import randint
from sklearn.preprocessing import OneHotEncoder
## copy... | 5,341 | 42.080645 | 150 | py |
GCNet | GCNet-main/baseline-mmin/data/cmumosi_multimodal_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class CMUMOSIMultimodalDataset(BaseDataset):
@staticmethod
def modify_commandline... | 4,759 | 34.522388 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/iemocapsix_multimodal_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class IEMOCAPSIXMultimodalDataset(BaseDataset):
@staticmethod
def modify_commandl... | 3,886 | 37.87 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/__init__.py | """This package includes all the modules related to data loading and preprocessing
To add a custom dataset class called 'dummy', you need to add a file called 'dummy_dataset.py' and define a subclass 'DummyDataset' inherited from BaseDataset.
You need to implement four functions:
-- <__init__>: ... | 5,421 | 41.031008 | 176 | py |
GCNet | GCNet-main/baseline-mmin/data/iemocapfour_multimodal_dataset.py | import os
import json
from typing import List
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class IEMOCAPFOURMultimodalDataset(BaseDataset):
@staticmethod
def modify_command... | 3,987 | 38.485149 | 125 | py |
GCNet | GCNet-main/baseline-mmin/data/multimodal_miss_dataset.py | import os
import json
import random
import torch
import numpy as np
import h5py
from torch.nn.utils.rnn import pad_sequence
from torch.nn.utils.rnn import pack_padded_sequence
from data.base_dataset import BaseDataset
class MultimodalMissDataset(BaseDataset):
@staticmethod
def modify_commandline_options(pars... | 7,786 | 38.729592 | 125 | py |
Text2Video-Zero | Text2Video-Zero-main/app.py | import gradio as gr
import torch
from model import Model, ModelType
from app_canny import create_demo as create_demo_canny
from app_pose import create_demo as create_demo_pose
from app_text_to_video import create_demo as create_demo_text_to_video
from app_pix2pix_video import create_demo as create_demo_pix2pix_video
f... | 5,412 | 53.13 | 309 | py |
Text2Video-Zero | Text2Video-Zero-main/utils.py | import os
import PIL.Image
import numpy as np
import torch
import torchvision
from torchvision.transforms import Resize, InterpolationMode
import imageio
from einops import rearrange
import cv2
from PIL import Image
from annotator.util import resize_image, HWC3
from annotator.canny import CannyDetector
from annotator.... | 8,315 | 35.473684 | 133 | py |
Text2Video-Zero | Text2Video-Zero-main/model.py | from enum import Enum
import gc
import numpy as np
import tomesd
import torch
from diffusers import StableDiffusionInstructPix2PixPipeline, StableDiffusionControlNetPipeline, ControlNetModel, UNet2DConditionModel
from diffusers.schedulers import EulerAncestralDiscreteScheduler, DDIMScheduler
from text_to_video_pipelin... | 24,071 | 47.532258 | 193 | py |
Text2Video-Zero | Text2Video-Zero-main/text_to_video_pipeline.py | from diffusers import StableDiffusionPipeline
import torch
from dataclasses import dataclass
from typing import Callable, List, Optional, Union
import numpy as np
from diffusers.utils import deprecate, logging, BaseOutput
from einops import rearrange, repeat
from torch.nn.functional import grid_sample
import torchvisio... | 22,305 | 43.170297 | 202 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/utils.py | """Utils for monoDepth."""
import sys
import re
import numpy as np
import cv2
import torch
def read_pfm(path):
"""Read pfm file.
Args:
path (str): path to file
Returns:
tuple: (data, scale)
"""
with open(path, "rb") as file:
color = None
width = None
heig... | 4,582 | 23.121053 | 88 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/api.py | # based on https://github.com/isl-org/MiDaS
import cv2
import os
import torch
import torch.nn as nn
from torchvision.transforms import Compose
from .midas.dpt_depth import DPTDepthModel
from .midas.midas_net import MidasNet
from .midas.midas_net_custom import MidasNet_small
from .midas.transforms import Resize, Norma... | 5,229 | 29.764706 | 124 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/__init__.py | import cv2
import numpy as np
import torch
from einops import rearrange
from .api import MiDaSInference
class MidasDetector:
def __init__(self):
self.model = MiDaSInference(model_type="dpt_hybrid").cuda()
def __call__(self, input_image, a=np.pi * 2.0, bg_th=0.1):
assert input_image.ndim == 3... | 1,400 | 34.923077 | 81 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/midas/base_model.py | import torch
class BaseModel(torch.nn.Module):
def load(self, path):
"""Load model from file.
Args:
path (str): file path
"""
parameters = torch.load(path, map_location=torch.device('cpu'))
if "optimizer" in parameters:
parameters = parameters["mod... | 367 | 20.647059 | 71 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/midas/midas_net.py | """MidashNet: Network for monocular depth estimation trained by mixing several datasets.
This file contains code that is adapted from
https://github.com/thomasjpfan/pytorch_refinenet/blob/master/pytorch_refinenet/refinenet/refinenet_4cascade.py
"""
import torch
import torch.nn as nn
from .base_model import BaseModel
f... | 2,709 | 34.194805 | 130 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/midas/vit.py | import torch
import torch.nn as nn
import timm
import types
import math
import torch.nn.functional as F
class Slice(nn.Module):
def __init__(self, start_index=1):
super(Slice, self).__init__()
self.start_index = start_index
def forward(self, x):
return x[:, self.start_index :]
class... | 14,625 | 28.727642 | 96 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/midas/dpt_depth.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .base_model import BaseModel
from .blocks import (
FeatureFusionBlock,
FeatureFusionBlock_custom,
Interpolate,
_make_encoder,
forward_vit,
)
def _make_fusion_block(features, use_bn):
return FeatureFusionBlock_custom(
... | 3,154 | 27.681818 | 89 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/midas/midas_net_custom.py | """MidashNet: Network for monocular depth estimation trained by mixing several datasets.
This file contains code that is adapted from
https://github.com/thomasjpfan/pytorch_refinenet/blob/master/pytorch_refinenet/refinenet/refinenet_4cascade.py
"""
import torch
import torch.nn as nn
from .base_model import BaseModel
f... | 5,207 | 39.6875 | 168 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/midas/midas/blocks.py | import torch
import torch.nn as nn
from .vit import (
_make_pretrained_vitb_rn50_384,
_make_pretrained_vitl16_384,
_make_pretrained_vitb16_384,
forward_vit,
)
def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, use_vit_only=False, use_readout="ign... | 9,242 | 25.947522 | 150 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/openpose/hand.py | import cv2
import json
import numpy as np
import math
import time
from scipy.ndimage.filters import gaussian_filter
import matplotlib.pyplot as plt
import matplotlib
import torch
from skimage.measure import label
from .model import handpose_model
from . import util
class Hand(object):
def __init__(self, model_pat... | 3,426 | 38.848837 | 110 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/openpose/model.py | import torch
from collections import OrderedDict
import torch
import torch.nn as nn
def make_layers(block, no_relu_layers):
layers = []
for layer_name, v in block.items():
if 'pool' in layer_name:
layer = nn.MaxPool2d(kernel_size=v[0], stride=v[1],
paddi... | 8,745 | 38.754545 | 86 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/openpose/util.py | import math
import numpy as np
import matplotlib
import cv2
def padRightDownCorner(img, stride, padValue):
h = img.shape[0]
w = img.shape[1]
pad = 4 * [None]
pad[0] = 0 # up
pad[1] = 0 # left
pad[2] = 0 if (h % stride == 0) else stride - (h % stride) # down
pad[3] = 0 if (w % stride == 0)... | 7,507 | 44.50303 | 133 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/openpose/__init__.py | import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
import torch
import numpy as np
from . import util
from .body import Body
from .hand import Hand
from annotator.util import annotator_ckpts_path
body_model_path = "https://huggingface.co/lllyasviel/ControlNet/resolve/main/annotator/ckpts/body_pose_model.pth"
hand_m... | 1,957 | 42.511111 | 113 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/openpose/body.py | import cv2
import numpy as np
import math
import time
from scipy.ndimage.filters import gaussian_filter
import matplotlib.pyplot as plt
import matplotlib
import torch
from torchvision import transforms
from . import util
from .model import bodypose_model
class Body(object):
def __init__(self, model_path):
... | 10,994 | 48.977273 | 137 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmcv_custom/checkpoint.py | # Copyright (c) Open-MMLab. All rights reserved.
import io
import os
import os.path as osp
import pkgutil
import time
import warnings
from collections import OrderedDict
from importlib import import_module
from tempfile import TemporaryDirectory
import torch
import torchvision
from torch.optim import Optimizer
from to... | 19,091 | 37.184 | 110 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/apis/inference.py | import matplotlib.pyplot as plt
import annotator.uniformer.mmcv as mmcv
import torch
from annotator.uniformer.mmcv.parallel import collate, scatter
from annotator.uniformer.mmcv.runner import load_checkpoint
from annotator.uniformer.mmseg.datasets.pipelines import Compose
from annotator.uniformer.mmseg.models import b... | 4,729 | 33.525547 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/apis/test.py | import os.path as osp
import pickle
import shutil
import tempfile
import annotator.uniformer.mmcv as mmcv
import numpy as np
import torch
import torch.distributed as dist
from annotator.uniformer.mmcv.image import tensor2imgs
from annotator.uniformer.mmcv.runner import get_dist_info
def np2tmp(array, temp_file_name=... | 8,288 | 33.682008 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/apis/train.py | import random
import warnings
import numpy as np
import torch
from annotator.uniformer.mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from annotator.uniformer.mmcv.runner import build_optimizer, build_runner
from annotator.uniformer.mmseg.core import DistEvalHook, EvalHook
from annotator.uniformer.mms... | 4,035 | 33.495726 | 87 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/core/evaluation/metrics.py | from collections import OrderedDict
import annotator.uniformer.mmcv as mmcv
import numpy as np
import torch
def f_score(precision, recall, beta=1):
"""calcuate the f-score value.
Args:
precision (float | torch.Tensor): The precision value.
recall (float | torch.Tensor): The recall value.
... | 13,079 | 39 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/core/seg/sampler/ohem_pixel_sampler.py | import torch
import torch.nn.functional as F
from ..builder import PIXEL_SAMPLERS
from .base_pixel_sampler import BasePixelSampler
@PIXEL_SAMPLERS.register_module()
class OHEMPixelSampler(BasePixelSampler):
"""Online Hard Example Mining Sampler for segmentation.
Args:
context (nn.Module): The contex... | 3,155 | 39.987013 | 103 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/necks/multilevel_neck.py | import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import NECKS
@NECKS.register_module()
class MultiLevelNeck(nn.Module):
"""MultiLevelNeck.
A neck structure connect vit backbone and decoder_heads.
Args:
in_channels (List[int]... | 2,454 | 33.577465 | 76 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/necks/fpn.py | import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, xavier_init
from ..builder import NECKS
@NECKS.register_module()
class FPN(nn.Module):
"""Feature Pyramid Network.
This is an implementation of - Feature Pyramid Networks for Object
Detection (http... | 9,159 | 42.004695 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/fcn_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FCNHead(BaseDecodeHead):
"""Fully Convolution Networks for Semantic Segmentation.
This head is implemented of `FCNNet <htt... | 2,817 | 33.365854 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/sep_aspp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .aspp_head import ASPPHead, ASPPModule
class DepthwiseSeparableASPPModule(ASPPModule):
"""Atrous Spatial Pyramid P... | 3,527 | 33.588235 | 81 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/ann_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PPMConcat(nn.ModuleList):
"""Pyramid Pooling Module that only concat the features of each ... | 9,194 | 36.378049 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/apc_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ACM(nn.Module):
"""Adaptive Context Module used in APCNet.
Args:
... | 5,572 | 34.050314 | 76 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/ocr_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .cascade_decode_head import BaseCascadeDecodeHead
clas... | 4,319 | 32.75 | 76 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/dm_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, build_activation_layer, build_norm_layer
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class DCM(nn.Module):
"""Dynamic Convolutional Module used in DMNet.
Args:
... | 5,004 | 34.496454 | 93 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/ema_head.py | import math
import torch
import torch.distributed as dist
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from ..builder import HEADS
from .decode_head import BaseDecodeHead
def reduce_mean(tensor):
"""Reduce mean when distributed training."""
if not... | 5,796 | 33.301775 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/da_head.py | import torch
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, Scale
from torch import nn
from annotator.uniformer.mmseg.core import add_prefix
from ..builder import HEADS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PA... | 5,585 | 30.206704 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/psp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class PPM(nn.ModuleList):
"""Pooling Pyramid Module used in PSPNet.
Args:
pool_scales (tuple[int... | 3,352 | 31.872549 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/cc_head.py | import torch
from ..builder import HEADS
from .fcn_head import FCNHead
try:
from annotator.uniformer.mmcv.ops import CrissCrossAttention
except ModuleNotFoundError:
CrissCrossAttention = None
@HEADS.register_module()
class CCHead(FCNHead):
"""CCNet: Criss-Cross Attention for Semantic Segmentation.
... | 1,303 | 29.325581 | 71 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/enc_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule, build_norm_layer
from annotator.uniformer.mmseg.ops import Encoding, resize
from ..builder import HEADS, build_loss
from .decode_head import BaseDecodeHead
class EncModule(nn.Module):
"""Encodi... | 6,784 | 35.090426 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/fpn_head.py | import numpy as np
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class FPNHead(BaseDecodeHead):
"""Panoptic Feature Pyramid Networks.
This... | 2,422 | 34.115942 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/nl_head.py | import torch
from annotator.uniformer.mmcv.cnn import NonLocal2d
from ..builder import HEADS
from .fcn_head import FCNHead
@HEADS.register_module()
class NLHead(FCNHead):
"""Non-local Neural Networks.
This head is the implementation of `NLNet
<https://arxiv.org/abs/1711.07971>`_.
Args:
redu... | 1,577 | 30.56 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/dnl_head.py | import torch
from annotator.uniformer.mmcv.cnn import NonLocal2d
from torch import nn
from ..builder import HEADS
from .fcn_head import FCNHead
class DisentangledNonLocal2d(NonLocal2d):
"""Disentangled Non-Local Blocks.
Args:
temperature (float): Temperature to adjust attention. Default: 0.05
""... | 4,591 | 33.787879 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/decode_head.py | from abc import ABCMeta, abstractmethod
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import normal_init
from annotator.uniformer.mmcv.runner import auto_fp16, force_fp32
from annotator.uniformer.mmseg.core import build_pixel_sampler
from annotator.uniformer.mmseg.ops import resize
from ..build... | 9,240 | 38.323404 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/lraspp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv import is_tuple_of
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
@HEADS.register_module()
class LRASPPHead(BaseDecodeHead):
"... | 3,098 | 33.054945 | 77 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/uper_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
from .psp_head import PPM
@HEADS.register_module()
class UPerHead(BaseDecodeHead):
"""Unified Perceptual Pars... | 4,012 | 30.598425 | 72 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/aspp_head.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
class ASPPModule(nn.ModuleList):
"""Atrous Spatial Pyramid Pooling (ASPP) Module.
Args:
dilation... | 3,459 | 31.037037 | 76 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/psa_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmcv.cnn import ConvModule
from annotator.uniformer.mmseg.ops import resize
from ..builder import HEADS
from .decode_head import BaseDecodeHead
try:
from annotator.uniformer.mmcv.ops import PSAMask
except ModuleNotFoundErr... | 7,544 | 37.299492 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/gc_head.py | import torch
from annotator.uniformer.mmcv.cnn import ContextBlock
from ..builder import HEADS
from .fcn_head import FCNHead
@HEADS.register_module()
class GCHead(FCNHead):
"""GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond.
This head is the implementation of `GCNet
<https://arxiv.... | 1,611 | 32.583333 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/decode_heads/point_head.py | # Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa
import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule, normal_init
from annotator.uniformer.mmcv.ops import point_sample
from annotator.uniformer.mmseg.models... | 14,754 | 41.157143 | 126 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/utils/se_layer.py | import annotator.uniformer.mmcv as mmcv
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule
from .make_divisible import make_divisible
class SELayer(nn.Module):
"""Squeeze-and-Excitation Module.
Args:
channels (int): The input (and output) channels of the SE layer.
rati... | 2,151 | 36.103448 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/utils/weight_init.py | """Modified from https://github.com/rwightman/pytorch-image-
models/blob/master/timm/models/layers/drop.py."""
import math
import warnings
import torch
def _no_grad_trunc_normal_(tensor, mean, std, a, b):
"""Reference: https://people.sc.fsu.edu/~jburkardt/presentations
/truncated_normal.pdf"""
def norm... | 2,327 | 35.952381 | 76 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/utils/res_layer.py | from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer
from torch import nn as nn
class ResLayer(nn.Sequential):
"""ResLayer to build ResNet style backbone.
Args:
block (nn.Module): block used to build ResLayer.
inplanes (int): inplanes of block.
planes (int): pla... | 3,335 | 34.115789 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/utils/self_attention_block.py | import torch
from annotator.uniformer.mmcv.cnn import ConvModule, constant_init
from torch import nn as nn
from torch.nn import functional as F
class SelfAttentionBlock(nn.Module):
"""General self-attention block/non-local block.
Please refer to https://arxiv.org/abs/1706.03762 for details about key,
que... | 6,145 | 37.4125 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/utils/up_conv_block.py | import torch
import torch.nn as nn
from annotator.uniformer.mmcv.cnn import ConvModule, build_upsample_layer
class UpConvBlock(nn.Module):
"""Upsample convolution block in decoder for UNet.
This upsample convolution block consists of one upsample module
followed by one convolution block. The upsample mod... | 3,988 | 38.107843 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/utils/inverted_residual.py | from annotator.uniformer.mmcv.cnn import ConvModule
from torch import nn
from torch.utils import checkpoint as cp
from .se_layer import SELayer
class InvertedResidual(nn.Module):
"""InvertedResidual block for MobileNetV2.
Args:
in_channels (int): The input channels of the InvertedResidual block.
... | 7,025 | 32.617225 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/utils/drop.py | """Modified from https://github.com/rwightman/pytorch-image-
models/blob/master/timm/models/layers/drop.py."""
import torch
from torch import nn
class DropPath(nn.Module):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of
residual blocks).
Args:
drop_prob (float): Drop r... | 1,015 | 30.75 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/segmentors/base.py | import logging
import warnings
from abc import ABCMeta, abstractmethod
from collections import OrderedDict
import annotator.uniformer.mmcv as mmcv
import numpy as np
import torch
import torch.distributed as dist
import torch.nn as nn
from annotator.uniformer.mmcv.runner import auto_fp16
class BaseSegmentor(nn.Module... | 10,398 | 36.952555 | 79 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/segmentors/cascade_encoder_decoder.py | from torch import nn
from annotator.uniformer.mmseg.core import add_prefix
from annotator.uniformer.mmseg.ops import resize
from .. import builder
from ..builder import SEGMENTORS
from .encoder_decoder import EncoderDecoder
@SEGMENTORS.register_module()
class CascadeEncoderDecoder(EncoderDecoder):
"""Cascade Enc... | 3,708 | 36.464646 | 78 | py |
Text2Video-Zero | Text2Video-Zero-main/annotator/uniformer/mmseg/models/segmentors/encoder_decoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.uniformer.mmseg.core import add_prefix
from annotator.uniformer.mmseg.ops import resize
from .. import builder
from ..builder import SEGMENTORS
from .base import BaseSegmentor
@SEGMENTORS.register_module()
class EncoderDecoder(BaseSegm... | 11,344 | 36.943144 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.