python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
# Copyright (c) Facebook, Inc. and its affiliates. import argparse import numpy as np import os import torch from torch import nn from torch.autograd import Variable import torchvision import utils.modelZoo as modelZoo from utils.load_utils import * DATA_PATHS = { #'video_data/Oliver/train/':1, #'vide...
body2hands-main
train_gan.py
# Copyright (c) Facebook, Inc. and its affiliates. import argparse import os import json import numpy as np import torch import torchvision from torch import nn from torch.autograd import Variable import utils.modelZoo as modelZoo from utils.load_utils import * def main(args): ## variable initializations devi...
body2hands-main
sample.py
import tensorflow as tf import os import sys from nets.CPM import CPM from data.DomeReader import DomeReader from data.TsimonDBReader import TsimonDBReader from data.RHDReader import RHDReader from data.STBReader import STBReader from data.MultiDataset import combineMultiDataset from data.GAneratedReader import GAnera...
body2hands-main
visualization/POF/training_PAF_hand.py
import os import numpy as np import numpy.linalg as nl import json import pickle import argparse map_body25_to_body19 = list(range(8)) + list(range(9, 25)) # total of 24 parser = argparse.ArgumentParser() parser.add_argument('--seqName', '-n', type=str) parser.add_argument('--rootDir', '-r', type=str) parser.add_arg...
body2hands-main
visualization/POF/collect_openpose.py
import tensorflow as tf import os import sys from nets.CPM import CPM from nets.Hourglass import Hourglass from data.DomeReader import DomeReader from data.HumanReader import HumanReader from data.MultiDataset import combineMultiDataset from data.COCOReader import COCOReader import pickle import utils.general import ...
body2hands-main
visualization/POF/training_e2e_PAF.py
from __future__ import print_function, unicode_literals import tensorflow as tf import numpy as np import numpy.linalg as nl import matplotlib.pyplot as plt import matplotlib.patches from mpl_toolkits.mplot3d import Axes3D import argparse import cv2 import os from time import time import json from nets.CPM import CPM ...
body2hands-main
visualization/POF/save_total_sequence.py
import tensorflow as tf import pickle import os from utils.ops import NetworkOps as ops class handSegNet: def __init__(self): pass def init_sess(self, sess): file_name = './weights/handsegnet-rhd.pickle' exclude_var_list = [] assert os.path.exists(file_name), "File not found."...
body2hands-main
visualization/POF/utils/handSegNet.py
import tensorflow as tf import numpy as np import numpy.linalg as nl import utils.general import skimage.feature import json import os PAF_type = 0 allPAFConnection = [[np.array([[1, 8], [8, 9], [9, 10], [1, 11], [11, 12], [12, 13], [1, 2], [2, 3], [3, 4], [2, 16], [1, 5], [5, 6], [6, 7], [5, 17], [1, 0], [0, 14], [0,...
body2hands-main
visualization/POF/utils/PAF.py
import numpy as np def transReProjectionLoss(t, X0, K, uv): assert t.shape == (3,) assert len(X0.shape) == 2 and X0.shape[1] == 3 assert K.shape == (3, 3) assert len(uv.shape) == 2 and uv.shape[1] == 2 X = X0 + t[np.newaxis, :] x = X.dot(K.T) x /= x[:, 2][:, np.newaxis] return np.sum...
body2hands-main
visualization/POF/utils/optimization.py
import tensorflow as tf from tensorflow.python import pywrap_tensorflow def load_weights_from_snapshot(session, checkpoint_path, discard_list=None, rename_dict=None): """ Loads weights from a snapshot except the ones indicated with discard_list. Others are possibly renamed. """ reader = pywrap_tensorf...
body2hands-main
visualization/POF/utils/load_ckpt.py
import tensorflow as tf import json import numpy as np class AdamModel(object): num_shape_coeff = 30 num_vertices = 18540 num_joints = 62 def __init__(self): # read in model file model_file = 'utils/adam_v1_plus2.json' with open(model_file) as f: model_data = json...
body2hands-main
visualization/POF/utils/AdamModel.py
import tensorflow as tf import math import numpy as np class NetworkOps(object): """ Operations that are frequently used within networks. """ neg_slope_of_relu = 0.01 @classmethod def leaky_relu(cls, tensor, name='relu'): out_tensor = tf.maximum(tensor, cls.neg_slope_of_relu * tensor, name=na...
body2hands-main
visualization/POF/utils/ops.py
from utils.AdamModel import AdamModel from utils.PAF import PAFConnection import tensorflow as tf import numpy as np import json if __name__ == '__main__': adam = AdamModel() adam_joints = adam.reconstruct() sess = tf.Session() V_vec, joints_v = sess.run([adam.mean_shape, adam_joints]) sess.close()...
body2hands-main
visualization/POF/utils/default_PAF_length.py
import numpy as np def calc_auc(x, y): """ Given x and y values it calculates the approx. integral and normalizes it: area under curve""" integral = np.trapz(y, x) norm = np.trapz(np.ones_like(y), x) return integral / norm class EvalUtil: """ Util class for evaluation networks. """ def _...
body2hands-main
visualization/POF/utils/EvalUtil.py
# Don't use anaconda for this import ctypes import os from PIL import Image, ImageOps import matplotlib.pyplot as plt import numpy as np class wrapper_hand_model(object): def __init__(self, lib_file='./utils/libPythonWrapper.so', model_file='./utils/hand2_l_all_uv.json'): self.lib = ctypes.cdll.LoadLibrar...
body2hands-main
visualization/POF/utils/wrapper_hand_model.py
import numpy as np from math import factorial def savitzky_golay(y, window_size, order, deriv=0, rate=1): r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter. The Savitzky-Golay filter removes high frequency noise from data. It has the advantage of preserving the original shape and...
body2hands-main
visualization/POF/utils/smoothing.py
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib.widgets import Slider import utils.general class vis_heatmap3d(object): def __init__(self, fig, ax, heatmap, keypoints=None, type_str=None): assert len(heatmap.shape) == 4 self.fig = fig ...
body2hands-main
visualization/POF/utils/vis_heatmap3d.py
import tensorflow as tf def average_gradients(tower_grads): average_grads = [] for grad_and_vars in zip(*tower_grads): # Note that each grad_and_vars looks like the following: # ((grad0_gpu0, var0_gpu0), ... , (grad0_gpuN, var0_gpuN)) grads = [] for g, _ in grad_and_vars: ...
body2hands-main
visualization/POF/utils/multigpu.py
import ctypes from PIL import Image, ImageOps import numpy as np class meshWrapper(object): def __init__(self, lib_file='./utils/libPythonWrapper.so'): self.lib = ctypes.cdll.LoadLibrary(lib_file) # extern "C" void load_totalmodel(char* obj_file, char* model_file, char* pca_file); self.li...
body2hands-main
visualization/POF/utils/meshWrapper.py
import tensorflow as tf import numpy as np import numpy.linalg as nl import cv2 # in A4 order (SMC) tbody_connMat = np.array([0, 1, 0, 3, 3, 4, 4, 5, 0, 9, 9, 10, 10, 11, 0, 2, 2, 6, 6, 7, 7, 8, 2, 12, 12, 13, 13, 14, 1, 15, 15, 16, 1, 17, 17, 18, 0, 19, 0, 20, 20, 12, 20, 6]) thand_connMat = np.array([0, 1, 1, 2, 2, ...
body2hands-main
visualization/POF/utils/general.py
import numpy as np import numpy.linalg as nl from utils.general import connMat a4_to_main = { 'body': np.array([1, 0, 9, 10, 11, 3, 4, 5, 12, 13, 14, 6, 7, 8, 17, 15, 18, 16, 19, 20], dtype=np.int64), # convert to order of openpose '1_body': np.array([1, 0, 9, 10, 11, 3, 4, 5, 12, 13, 14, 6, 7, 8, 17, 15, 18,...
body2hands-main
visualization/POF/utils/keypoint_conversion.py
import tensorflow as tf from utils.ops import NetworkOps import numpy as np ops = NetworkOps class CPM(object): # The original CPM: set input image to right hand, BGR channel order (OpenCV), image scale to x / 256.0 - 0.5, output channel number to 22 (the last one for background) def __init__(self, crop_siz...
body2hands-main
visualization/POF/nets/CPM.py
import tensorflow as tf from data.BaseReader import BaseReader import numpy as np class TempConstReader(BaseReader): crop_scale_noise_sigma = 0.1 crop_offset_noise_sigma = 0.1 def __init__(self, objtype=0, shuffle=False, batch_size=1, crop_noise=False): super(TempConstReader, self).__init__(objty...
body2hands-main
visualization/POF/data/TempConstReader.py
# Run this script with OpenCV2 import cv2 import numpy as np import os import json source_dir = '/media/posefs3b/Users/gines/mpii_mask' target_dir = '/media/posefs3b/Users/donglaix/mpii_mask' if __name__ == '__main__': path_to_db = './MPII_collected.json' with open(path_to_db) as f: db_data = json.loa...
body2hands-main
visualization/POF/data/process_MPII_mask.py
import tensorflow as tf import numpy as np import utils.general class BaseReader(object): # BaseReader is a virual base class to be inherited by other data readers which provide data by calling register_tensor crop_size_zoom = 1.5 crop_size_zoom_2d = 1.8 crop_size = 368 grid_size = crop_size // 8...
body2hands-main
visualization/POF/data/BaseReader.py
import tensorflow as tf from data.BaseReader import BaseReader import numpy as np import h5py from utils.keypoint_conversion import human36m_to_main, mpi3d_to_main, SMPL_to_main import pickle import os class HumanReader(BaseReader): def __init__(self, name='Human3.6M', mode='training', objtype=0, shuffle=True, b...
body2hands-main
visualization/POF/data/HumanReader.py
import tensorflow as tf from data.BaseReader import BaseReader import numpy as np class Base2DReader(BaseReader): # inherit from BaseReader, implement different 2D cropping (cropping from 2D) def __init__(self, objtype=0, shuffle=True, batch_size=1, crop_noise=False): super(Base2DReader, self).__init...
body2hands-main
visualization/POF/data/Base2DReader.py
import tensorflow as tf from data.TempConstReader import TempConstReader import numpy as np import numpy.linalg as nl import pickle from utils.keypoint_conversion import a4_to_main as order_dict import json import os class DomeReaderTempConst(TempConstReader): def __init__(self, mode='training', objtype=0, shuff...
body2hands-main
visualization/POF/data/DomeReaderTempConst.py
import os import numpy as np import numpy.linalg as nl import json import pickle map_body25_to_body19 = list(range(8)) + list(range(9, 25)) # total of 24 seqName = 'Dexter_Grasp2' # root = '/home/donglaix/Documents/Experiments/{}'.format(seqName) root = '/media/posefs1b/Users/donglaix/siggasia018/{}/'.format(seqName...
body2hands-main
visualization/POF/data/collect_openpose.py
import tensorflow as tf class MultiDataset(object): # A class to combine multi dataset input def __init__(self, db_list): assert type(db_list) == list and len(db_list) >= 1 self.db_list = db_list def get(self, name_wanted): data_list = [] for i, db in enumerate(self.db_li...
body2hands-main
visualization/POF/data/MultiDataset.py
import tensorflow as tf import os import numpy as np from data.BaseReader import BaseReader import pickle from data.collect_stb import PATH_TO_DATASET, K, Rl, Rr, tl, tr, TRAIN_SEQS, TEST_SEQS from utils.keypoint_conversion import STB_to_main class STBReader(BaseReader): def __init__(self, mode='training', objtyp...
body2hands-main
visualization/POF/data/STBReader.py
import tensorflow as tf from data.BaseReader import BaseReader import numpy as np import numpy.linalg as nl import pickle from utils.keypoint_conversion import a4_to_main as order_dict import json import os class DomeReader(BaseReader): def __init__(self, mode='training', objtype=0, shuffle=False, batch_size=1, ...
body2hands-main
visualization/POF/data/DomeReader.py
import tensorflow as tf import os import numpy as np import json from data.Base2DReader import Base2DReader from utils.keypoint_conversion import COCO_to_main, MPII_to_main class COCOReader(Base2DReader): def __init__(self, name='COCO', mode='training', objtype=0, shuffle=True, batch_size=1, crop_noise=False): ...
body2hands-main
visualization/POF/data/COCOReader.py
import pickle from scipy.io import loadmat import os import numpy as np PATH_TO_DATASET = '/media/posefs0c/Users/donglaix/Experiments/StereoHandTracking/' TEST_SEQS = ['B1Counting', 'B1Random'] TRAIN_SEQS = ['B2Counting', 'B2Random', 'B3Counting', 'B3Random', 'B4Counting', 'B4Random', 'B5Counting', 'B5Random', 'B6Coun...
body2hands-main
visualization/POF/data/collect_stb.py
import tensorflow as tf from data.Base2DReader import Base2DReader import os import pickle import numpy as np from utils.keypoint_conversion import GAnerated_to_main as order_dict class GAneratedReader(Base2DReader): def __init__(self, mode='training', objtype=1, shuffle=False, batch_size=1, crop_noise=False): ...
body2hands-main
visualization/POF/data/GAneratedReader.py
import pickle import os import numpy as np from utils.general import plot2d_cv2 import cv2 map_index = np.array([0, 4, 3, 2, 1, 8, 7, 6, 5, 12, 11, 10, 9, 16, 15, 14, 13, 20, 19, 18, 17], dtype=int) def project(joints, K, R=None, t=None, distCoef=None): """ Perform Projection. joints: N * 3 """ x...
body2hands-main
visualization/POF/data/collect_crop_hand.py
import tensorflow as tf import numpy as np import json from data.Base2DReader import Base2DReader import os from utils.keypoint_conversion import tsimon_to_main as order_dict class TsimonDBReader(Base2DReader): def __init__(self, mode='training', objtype=1, shuffle=False, batch_size=1, crop_noise=False): ...
body2hands-main
visualization/POF/data/TsimonDBReader.py
import tensorflow as tf import pickle from data.BaseReader import BaseReader import os import numpy as np class RHDReader(BaseReader): def __init__(self, mode='training', objtype=1, shuffle=False, batch_size=1, crop_noise=False): assert objtype == 1 super(RHDReader, self).__init__(objtype, shuffle...
body2hands-main
visualization/POF/data/RHDReader.py
import os import pickle import json import numpy as np def load_calib_file(calib_file): assert os.path.isfile(calib_file) with open(calib_file) as f: calib = json.load(f) for key in calib: if type(calib[key]) == list: calib[key] = np.array(calib[key]) return calib """ ###...
body2hands-main
visualization/POF/data/collect_a4.py
import tensorflow as tf from data.BaseReader import BaseReader import numpy as np import pickle from utils.keypoint_conversion import a4_to_main as order_dict import json import os class OpenposeReader(BaseReader): def __init__(self, seqName, mode='evaluation', objtype=0, shuffle=False, batch_size=1, crop_noise=...
body2hands-main
visualization/POF/data/OpenposeReader.py
# Copyright (c) Facebook, Inc. and its affiliates. import os import sys import numpy as np import scipy.io as io rng = np.random.RandomState(23456) import torch import torchvision from torch import nn from torch.autograd import Variable from torch.utils.data import DataLoader from torchvision.utils import save_image ...
body2hands-main
utils/modelZoo.py
# Copyright (c) Facebook, Inc. and its affiliates. import json import numpy as np import os, sys import scipy import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d, Axes3D from scipy.spatial.transform import Rotation as R from shutil import copyfile from PIL import Image,ImageDraw from torchvision i...
body2hands-main
utils/load_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. import argparse import os import json import numpy as np import torch import torchvision from torch import nn from torch.autograd import Variable import pickle import utils.modelZoo as modelZoo from utils.load_utils import * ARMS_ONLY = [13,14,16,17,18,19] #arms for ...
body2hands-main
smplx_plugin/demo.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. #%% import json import time try: from eval_server_common import connect_to_redis except ImportError: print("HINT:...
codraw-models-master
eval_run_bots.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. #%% import numpy as np from pathlib import Path import torch import torch.cuda import torch.nn as nn import torch.nn.func...
codraw-models-master
baseline4_models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ An event-based view of the CoDraw dataset """ #%% import numpy as np from pathlib import Path import json from enum i...
codraw-models-master
codraw_data.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Multi-headed attention implementation """ #%% import numpy as np import torch import torch.cuda import torch.nn as n...
codraw-models-master
attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. #%% import numpy as np from pathlib import Path import heapq import torch import torch.cuda import torch.nn as nn import ...
codraw-models-master
baseline2_models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% import numpy as np from p...
codraw-models-master
baseline4_eval.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% assert __name__ == "__mai...
codraw-models-master
baseline1_train.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np def scene_similarity_orig(pred, target): """ DEPRECATED: use scene_similarity instead! Thi...
codraw-models-master
abs_metric.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. try: from IPython.display import display except ImportError: assert not INTERACTIVE def display(*args, **kwargs...
codraw-models-master
episode.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import redis REDIS_HOST = 'localhost' REDIS_PORT = 6379 REDIS_PASSWORD = 'YOUR PASSWORD HERE' REDIS_CONNECTION = None de...
codraw-models-master
example.eval_server_common.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. __all__ = ['cpu', 'cuda_if_available', 'logsumexp', 'torch_load'] import torch # %% cpu = torch.device('cpu') if torch....
codraw-models-master
nkfb_util.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. #%% import numpy as np from pathlib import Path import torch import torch.cuda import torch.nn as nn import torch.nn.func...
codraw-models-master
baseline3_models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np from pathlib import Path import editdistance from collections import Counter import torch import torch....
codraw-models-master
datagen.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. #%% def load_models(*partitions): if not partitions: partitions = (1, 2, 3, 4) models = {} if 1 in p...
codraw-models-master
saved_models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Provides the Packer class, which is useful for managing a hierarchy where each batch element has a variable number of c...
codraw-models-master
packer.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np from pathlib import Path import editdistance import torch import torch.cuda import torch.nn as nn impor...
codraw-models-master
model.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% import json import numpy a...
codraw-models-master
eval_transcripts.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% import numpy as np from p...
codraw-models-master
baseline2_eval.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from pathlib import Path from IPython.display import SVG, display from PIL import Image from binascii import b2a_base64 PN...
codraw-models-master
abs_render.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% assert __name__ == "__mai...
codraw-models-master
baseline2_train.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% assert __name__ == "__mai...
codraw-models-master
baseline3_train.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% import numpy as np from p...
codraw-models-master
eval_automatic.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% import numpy as np from p...
codraw-models-master
baseline3_eval.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Abstract Scene (abs) utilities copied from the original CoDraw codebase """ import math import torch from torch.autogr...
codraw-models-master
abs_util_orig.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% import numpy as np from p...
codraw-models-master
baseline1_eval.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. try: get_ipython() INTERACTIVE=True except: INTERACTIVE=False def try_magic(*args, **kwargs): if not INTER...
codraw-models-master
interactivity.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. """ Scene-level nearest-neighbor teller """ from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmod...
codraw-models-master
exp28_scenenn.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. #%% import numpy as np from pathlib import Path import editdistance import torch import torch.cuda import torch.nn as nn ...
codraw-models-master
baseline1_models.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from interactivity import INTERACTIVE, try_magic, try_cd try_cd('~/dev/drawmodel/nkcodraw') #%% assert __name__ == "__mai...
codraw-models-master
baseline4_train.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import ast from itertools import chain import logging import math import os import sys import json import hashlib import ed...
av_hubert-main
avhubert/infer_s2s.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from argparse import Namespace import contextlib import copy import math import numpy as np import torch import torch.nn as...
av_hubert-main
avhubert/decoder.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import logging import os, glob import sys from typing import Dict, List, Optional, Tuple import numpy as np from dataclas...
av_hubert-main
avhubert/hubert_pretraining.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .hubert import * # noqa from .hubert_asr import * # noqa from .hubert_dataset import * from .hubert_pretraining import * from .hubert_c...
av_hubert-main
avhubert/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import math from typing import Dict, List, Optional import sys import torch import torch.nn as nn from fairseq import sear...
av_hubert-main
avhubert/sequence_generator.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import math import re from dataclasses import dataclass, field from typing import List, Optional import torch import torch...
av_hubert-main
avhubert/hubert_criterion.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import logging import math import torch.nn as nn import pdb logger = logging.getLogger(__name__) def conv3x3(in_planes, ...
av_hubert-main
avhubert/resnet.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import sys,logging import contextlib import tempfile from argparse import Namespace from typing import Any, Optional impor...
av_hubert-main
avhubert/hubert_asr.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import cv2 import torch import random import numpy as np from typing import Dict, List, Optional, Tuple def load_video(pat...
av_hubert-main
avhubert/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import os import sys import time from typing import Any, List, Optional, Union import nump...
av_hubert-main
avhubert/hubert_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import os,sys import logging from typing import Dict, List, Optional, Tuple import numpy as np import torch import torch....
av_hubert-main
avhubert/hubert.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import sys import argparse import torch from fairseq.data import Dictionary, encoders def add_task_state(ckpt_path): s...
av_hubert-main
avhubert/misc/fix_state.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import logging import os import sys import numpy as np import joblib import torch import tqdm logging.basicConfig( f...
av_hubert-main
avhubert/clustering/dump_km_label.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import logging import math import os import sys import fairseq import soundfile as sf import torch import torch.nn.functio...
av_hubert-main
avhubert/clustering/dump_hubert_feature.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import os, subprocess import submitit import argparse from argparse import Namespace def dump_av_hubert(*args, **kwargs): ...
av_hubert-main
avhubert/clustering/submit_cluster.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import logging import os import sys import numpy as np from sklearn.cluster import MiniBatchKMeans import joblib logging...
av_hubert-main
avhubert/clustering/learn_kmeans.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import logging import math import os import sys import soundfile as sf import torch import torchaudio import tqdm from npy...
av_hubert-main
avhubert/clustering/dump_mfcc_feature.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import os import glob import shutil import subprocess from tqdm import tqdm from pathlib import Path from gen_subword impor...
av_hubert-main
avhubert/preparation/lrs3_manifest.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import os import numpy as np from scipy.io import wavfile from tqdm import tqdm def mix_audio(wav_fns): wav_data = [wa...
av_hubert-main
avhubert/preparation/lrs3_noise.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import os, sys, glob, subprocess, json, math import numpy as np from scipy.io import wavfile from os.path import basename, ...
av_hubert-main
avhubert/preparation/vox_prepare.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import cv2, math, os import submitit import tempfile import shutil from tqdm import tqdm from scipy.io import wavfile def ...
av_hubert-main
avhubert/preparation/count_frames_slurm.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import sys, os, glob, subprocess, shutil, math from datetime import timedelta import tempfile from collections import Order...
av_hubert-main
avhubert/preparation/lrs3_prepare.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import sys,os,pickle,math import cv2,dlib,time import numpy as np from tqdm import tqdm def load_video(path): videogen...
av_hubert-main
avhubert/preparation/detect_landmark.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse from tempfile import NamedTemporaryFile import csv from pathlib import Path import zipfile from functools i...
av_hubert-main
avhubert/preparation/gen_subword.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. ## Based on: https://github.com/mpc001/Lipreading_using_Temporal_Convolutional_Networks/blob/master/preprocessing/crop_mout...
av_hubert-main
avhubert/preparation/align_mouth.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import math import tempfile import shutil import submitit import os, sys, subprocess, glob, re import numpy as np from coll...
av_hubert-main
avhubert/preparation/musan_prepare.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import math, time import os, sys, subprocess, glob, re import numpy as np from collections import defaultdict from scipy.io...
av_hubert-main
avhubert/preparation/noise_manifest.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import cv2, math, os import tempfile import shutil from tqdm import tqdm from scipy.io import wavfile def count_frames(fid...
av_hubert-main
avhubert/preparation/count_frames.py