python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/scopes.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/collections_test.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/variables.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/inception_test.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/scopes_test.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/slim.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/ops.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/inception_model.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/ops_test.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/losses.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/losses_test.py |
# Copyright 2016 Google Inc. 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 law or agree... | models-master | inception/inception/slim/variables_test.py |
#!/usr/bin/python
# Copyright 2016 Google Inc. 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 a... | models-master | inception/inception/data/preprocess_imagenet_validation_data.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | inception/inception/data/build_imagenet_data.py |
#!/usr/bin/python
# Copyright 2016 Google Inc. 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 a... | models-master | inception/inception/data/process_bounding_boxes.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | inception/inception/data/build_image_data.py |
#!/bin/python
from subprocess import call, Popen
import time
import signal
import sys, os
def kill_exp():
call(["pkill", "-u", "daniter", "-f","imagenet_distributed_train"])
call(["ssh", "raiders3","pkill -u daniter -f imagenet_distributed_train"])
def signal_handler(signal, frame):
kill_exp()
... | models-master | inception/utils/experiments-v2.py |
#!/bin/python
from subprocess import call, Popen
import time
import signal
import sys, os
def kill_exp():
call(["pkill", "-u", "daniter", "-f","imagenet_distributed_train"])
call(["ssh", "raiders3","pkill -u daniter -f imagenet_distributed_train"])
def signal_handler(signal, frame):
kill_exp()
... | models-master | inception/utils/experiments.py |
#!/bin/python
import sys
from os import listdir
import os
from shutil import copyfile
if __name__=='__main__':
if len(sys.argv) != 2:
print("Usage: %s <data-folder>" % __file__)
exit(1)
folder = sys.argv[1]
for i in range(16):
os.mkdir(folder+"-"+str(i))
#print folder+"-"+... | models-master | inception/utils/make-data-directories.py |
# Copyright 2016 The TensorFlow Authors. 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 applica... | models-master | inception/utils/checkpoints/compare_checkpoints.py |
# Copyright 2016 The TensorFlow Authors. 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 applica... | models-master | inception/utils/checkpoints/inspect_checkpoint.py |
#!/bin/python
import sys
from tensorflow.core.framework import graph_pb2
from google.protobuf import text_format
from tensorflow.python.training.checkpoint_state_pb2 import CheckpointState
from tensorflow.core.framework.variable_pb2 import SaveSliceInfoDef
import tensorflow as tf
ckpt = SaveSliceInfoDef()
print(dir(c... | models-master | inception/utils/checkpoints/fix_models.py |
# Copyright 2016 The TensorFlow Authors. 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 applica... | models-master | transformer/example.py |
# Copyright 2016 The TensorFlow Authors. 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 applica... | models-master | transformer/cluttered_mnist.py |
# Copyright 2016 The TensorFlow Authors. 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 applica... | models-master | transformer/tf_utils.py |
# Copyright 2016 The TensorFlow Authors. 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 applica... | models-master | transformer/spatial_transformer.py |
# Copyright 2015 Google Inc. 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 law or a... | models-master | neural_gpu/neural_gpu.py |
# Copyright 2015 Google Inc. 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 law or a... | models-master | neural_gpu/data_utils.py |
# Copyright 2015 Google Inc. 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 law or a... | models-master | neural_gpu/neural_gpu_trainer.py |
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: datum.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflect... | models-master | tfrecord-utils/datum_pb2.py |
#!/bin/python
import tensorflow as tf
import os
import sys
import numpy as np
from numpy import *
import scipy.io
import multiprocessing
import datum_pb2
import lmdb
import timeit
def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=[value]))
def _bytes_feature(value):
return ... | models-master | tfrecord-utils/make_tfrecord.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | namignizer/names.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | namignizer/model.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | namignizer/data_utils.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/graph_builder_test.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/structured_graph_builder.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/load_parser_ops.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/beam_reader_ops_test.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/parser_trainer.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/parser_eval.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/graph_builder.py |
# coding=utf-8
# Copyright 2016 Google Inc. 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 appl... | models-master | syntaxnet/syntaxnet/lexicon_builder_test.py |
# coding=utf-8
# Copyright 2016 Google Inc. 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 appl... | models-master | syntaxnet/syntaxnet/text_formats_test.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/reader_ops_test.py |
# Copyright 2016 Google Inc. 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 law or a... | models-master | syntaxnet/syntaxnet/conll2tree.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
import torch
from torch.nn import functional as F
from torchvision.utils import make_grid, save_image
import numpy as np
import argparse
import os
import sys
sys.path.append('vae_submodule')
from utils.helpers import FormatterNoDuplicate, chec... | amortized-optimization-tutorial-main | code/evaluate_amortization_speed_vae.py |
# Copyright (c) Facebook, Inc. and its affiliates.
import torch
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('bmh')
params = {
"text.usetex" : True,
"font.family" : "serif",
"font.serif" : ["Computer Modern Serif"]
}
plt.rcParams.update(params)
import os
import time
def evaluate_amor... | amortized-optimization-tutorial-main | code/evaluate_amortization_speed_function.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import torch
from torch import nn
import numpy as np
import os
import matplotlib.pyplot as plt
plt.style.use('bmh')
import sys
from IPython.core import ultratb
sys.excepthook = ultratb.FormattedTB(
mode='Plain', color_scheme='Neutral', c... | amortized-optimization-tutorial-main | code/train-sphere.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
import numpy as np
import torch
import argparse
import os
import sys
import pickle as pkl
import shutil
from omegaconf import OmegaConf
from collections import namedtuple
import dmc2gym
import matplotlib.pyplot as plt
plt.style.use('bmh')
from... | amortized-optimization-tutorial-main | code/evaluate_amortization_speed_control.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Computer Modern Rom... | amortized-optimization-tutorial-main | code/figures/ctrl.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Computer Modern Rom... | amortized-optimization-tutorial-main | code/figures/smoothed-loss.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import shutil
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Comp... | amortized-optimization-tutorial-main | code/figures/maxent-animation.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Computer Modern Rom... | amortized-optimization-tutorial-main | code/figures/main-example.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Computer Modern Rom... | amortized-optimization-tutorial-main | code/figures/fixed-point.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Computer Modern Rom... | amortized-optimization-tutorial-main | code/figures/loss-comp.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Computer Modern Rom... | amortized-optimization-tutorial-main | code/figures/imaml.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import jax
import jax.numpy as jnp
import os
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.sans-serif": ["Computer Modern Rom... | amortized-optimization-tutorial-main | code/figures/maxent.py |
# 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.