python_code
stringlengths
0
66.4k
#!/usr/bin/env python3 # 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 unittest import numpy as np import numpy.testing as npt from aepsych.config import Config fro...
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # Th...
#!/usr/bin/env python3 # 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 datetime import datetime import numpy as np constants = { "savefolder": "./databases/", ...
#!/usr/bin/env python3 # 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 experiment_config import numpy as np import torch from aepsych_client import AEPsychClient fro...
#!/usr/bin/env python3 # 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 import pyglet from psychopy import core, event from psychopy.visual import Window ...
#!/usr/bin/env python3 # 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. # we have pretty verbose messaging by default, suppress that here import logging import warnings war...
#!/usr/bin/env python3 # 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 copy import copy import matplotlib.pyplot as plt import numpy as np import torch from aepsych....
#!/usr/bin/env python3 # 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 gpytorch import matplotlib.pyplot as plt import numpy as np import seaborn as sns import torch...
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the scripts directory. from __future__ import annotations import argparse import json import os import nbformat from bs4 import BeautifulSoup from nbconver...
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the scripts directory. from __future__ import annotations import argparse import os from bs4 import BeautifulSoup #The base_url must match the base url in...
#!/usr/bin/env python3 # Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. from __future__ import annotations import argparse import json import os import shutil import nbformat from bs4 import BeautifulSoup from nbconvert import HTMLExporter TEMPLATE = """const CWD = process.cwd(); const Rea...
# 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. # # Evaluation script for object localization import json import argparse import torch import itertools import numpy as np...
# 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. # # Script to print stats on the NP annotation file import numpy as np import json import csv import sys src_file = sys.a...
# 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/jiasenlu/NeuralBabyTalk/blob/master/misc/bbox_transform.py # Licensed under The MIT Licen...
# 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. # # Script to preprocess the raw annotation output to NP/object annotation files import os import sys import json import a...
# 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. # # Script to print stats on the object annotation file import numpy as np import json import csv # import visdom import s...
# Copyright (c) Meta Platforms, Inc. and 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 import json import os import random import shutil import pandas as pd import tqdm if __name__ == "__main...
# Copyright (c) Meta Platforms, Inc. and 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 import os import tqdm import json import torch from torch import device from torchvision import transform...
# Copyright (c) Meta Platforms, Inc. and 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 augly.image import functional as aug_functional import torch from torchvision import transforms f...
# Copyright (c) Meta Platforms, Inc. and 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 torch import torch.nn as nn import torch.nn.functional as F class JND(nn.Module): """ https://ieeexplore.ieee....
# Copyright (c) Meta Platforms, Inc. and 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 import json import os import random from typing import Any, Dict, List, NamedTuple, Tuple import augly.im...
# Copyright (c) Meta Platforms, Inc. and 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 import json import time from typing import Callable import faiss import numpy as np import torch from tor...
# Copyright (c) Meta Platforms, Inc. and 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 functools import logging import os import faiss from PIL import Image, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES =...
# Copyright (c) Meta Platforms, Inc. and 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 import os import random import faiss import tqdm import numpy as np import pandas as pd import torch imp...
#!/usr/bin/env python # 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. import setuptools setuptools.setup( name="pterotactyl", version="0.1.0", author="Facebook AI Research", ...
# 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.
# 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.
# 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. import os import numpy as np import torch from pterotactyl.utility import utils BASE_MESH_SIZE = 1824 BASE_CHART_SIZE = 25 # replay buffer u...
# 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. import os import random import numpy as np import torch import torch.utils.data from pterotactyl.utility import utils from pterotactyl.utility...
# 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. import torch.nn as nn import torch from pterotactyl.utility import utils class Latent_Model(nn.Module): def __init__(self, args): ...
# 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. import os import json import argparse from collections import namedtuple from tqdm import tqdm from torch.utils.data import DataLoader import t...
# 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. import random import torch import torch.nn as nn import torch.optim as optim from pterotactyl.policies.DDQN import model from pterotactyl.poli...
# 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. import math import torch.nn as nn import torch from torch.nn.parameter import Parameter import torch.nn.functional as F import numpy as np fro...
# 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. import os from torch.utils.tensorboard import SummaryWriter from torch.utils.data import DataLoader import torch import argparse from submitit....
# 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. import os import random from tqdm import tqdm from torch.utils.data import DataLoader import torch import argparse import numpy as np from subm...
# 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. import numpy as np import random # class for getting radnom samples from the space of action class random_sampler: def __init__(self, args...
# 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 tqdm import tqdm import os from torch.utils.data import DataLoader import torch import argparse from pterotactyl.policies import environm...
# 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 tqdm import tqdm import os from torch.utils.data import DataLoader import torch import argparse from pterotactyl.policies import environm...
# 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. import os from tqdm import tqdm from torch.utils.data import DataLoader import torch import argparse from pterotactyl.policies import environm...
# 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. import os import random from tqdm import tqdm import numpy as np from torch.utils.data import DataLoader import torch import argparse from subm...
# 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. import os import random from tqdm.notebook import tqdm import numpy as np from torch.utils.data import DataLoader import torch import argparse ...
# 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. import os os.environ["PYOPENGL_PLATFORM"] = "egl" import numpy as np from scipy.spatial.transform import Rotation as R import pyrender import t...
# 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. import os os.environ["PYOPENGL_PLATFORM"] = "egl" import numpy as np import cv2 import pyrender import trimesh from scipy.spatial.transform im...
# 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. import os os.environ["PYOPENGL_PLATFORM"] = "egl" import numpy as np import pyrender from pterotactyl.utility import utils class Renderer: ...
#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 import trimesh from scipy.spatial.transform import Rotation as R from scipy.spatial import ConvexHull from pt...
#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 pybullet as pb import numpy as np import trimesh import torch from scipy.spatial.transform import Rotation as R...
#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 import pybullet_utils.bullet_client as bc import pybullet as pb import pybullet_data import torch f...
# 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.
# 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. import math import torch.nn as nn import torch import numpy as np from torch.nn.parameter import Parameter import torch.nn.functional as F # ...
# 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. import os import torch import numpy as np from tqdm import tqdm import argparse import random from PIL import Image from torch.utils.tensorboar...
# 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. import torch import torch.nn as nn # CNN block class DoubleConv(nn.Module): def __init__(self, in_channels, out_channels, last=False): ...
# 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. import os import torch from tqdm import tqdm import argparse from torch.utils.tensorboard import SummaryWriter import torch.optim as optim from...
# 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. import math import torch.nn as nn import torch import numpy as np from torch.nn.parameter import Parameter import torch.nn.functional as F from...
# 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. import os import torch import numpy as np from tqdm import tqdm import argparse from torch.utils.tensorboard import SummaryWriter import torch...
# 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. import os import random from glob import glob from tqdm import tqdm import numpy as np import torch from torchvision import transforms import ...
# 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. import random import os from PIL import Image import math import json import numpy as np import torch import torch.nn.functional as F import ma...
#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 os.environ["PYOPENGL_PLATFORM"] = "egl" import numpy as np import trimesh from scipy.spatial.transform import Rotatio...
#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 tqdm import tqdm from glob import glob import random from pathlib import Path import torch im...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved import argparse import os import numpy as np import torch from human_body_prior.body_model.body_model import BodyModel from human_body_prior.tools.rotation_tools import aa2matrot, local2global_pose from tqdm import tqdm from utils import utils_transform def m...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved import math import os import random import numpy as np import torch from data_loaders.dataloader import load_data, TestDataset from human_body_prior.body_model.body_model import BodyModel as BM from model.networks import PureMLP from tqdm import tqdm from u...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved import json import os import random import numpy as np import torch from data_loaders.dataloader import get_dataloader, load_data, TrainDataset from model.networks import PureMLP from runner.train_mlp import train_step from runner.training_loop import TrainLoo...
# MIT License # Copyright (c) 2021 OpenAI # # This code is based on https://github.com/openai/guided-diffusion # MIT License # Copyright (c) 2022 Guy Tevet # # This code is based on https://github.com/GuyTevet/motion-diffusion-model # Copyright (c) Meta Platforms, Inc. All Rights Reserved import functools import os ...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved import torch def update_lr_multistep( nb_iter, total_iter, max_lr, min_lr, optimizer, lr_anneal_steps ): if nb_iter > lr_anneal_steps: current_lr = min_lr else: current_lr = max_lr for param_group in optimizer.param_groups: ...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved # Metric functions with same inputs import numpy as np import torch def pred_jitter( predicted_position, predicted_angle, predicted_root_angle, gt_position, gt_angle, gt_root_angle, upper_index, lower_index, fps, ): pred...
import os SMPL_DATA_PATH = "./body_models/smpl" SMPL_KINTREE_PATH = os.path.join(SMPL_DATA_PATH, "kintree_table.pkl") SMPL_MODEL_PATH = os.path.join(SMPL_DATA_PATH, "SMPL_NEUTRAL.pkl") JOINT_REGRESSOR_TRAIN_EXTRA = os.path.join(SMPL_DATA_PATH, "J_regressor_extra.npy") ROT_CONVENTION_TO_ROT_NUMBER = { "legacy": ...
# MIT License # Copyright (c) 2022 Guy Tevet # # This code is based on https://github.com/GuyTevet/motion-diffusion-model # Copyright (c) Meta Platforms, Inc. All Rights Reserved from diffusion import gaussian_diffusion as gd from diffusion.respace import space_timesteps, SpacedDiffusion from model.meta_model import M...
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. # Check PYTORCH3D_LICENCE before use import functools from typing import Optional import torch import torch.nn.functional as F """ The transformation matrices returned from the functions in this file assume the points on which the transformatio...
# MIT License # Copyright (c) 2022 Guy Tevet # # This code is based on https://github.com/GuyTevet/motion-diffusion-model # Copyright (c) Meta Platforms, Inc. All Rights Reserved import argparse import json import os from argparse import ArgumentParser def parse_and_load_from_model(parser): # args according to th...
# MIT License # Copyright (c) 2022 ETH Sensing, Interaction & Perception Lab # # This code is based on https://github.com/eth-siplab/AvatarPoser # Copyright (c) Meta Platforms, Inc. All Rights Reserved import os import cv2 import numpy as np import trimesh from body_visualizer.mesh.mesh_viewer import MeshViewer from...
# MIT License # Copyright (c) 2022 ETH Sensing, Interaction & Perception Lab # # This code is based on https://github.com/eth-siplab/AvatarPoser # Copyright (c) Meta Platforms, Inc. All Rights Reserved import torch from human_body_prior.tools import tgm_conversion as tgm from human_body_prior.tools.rotation_tools impo...
# MIT License # Copyright (c) 2021 OpenAI # # This code is based on https://github.com/openai/guided-diffusion """ Helpers for distributed training. """ import socket import torch as th import torch.distributed as dist # Change this to reflect your cluster layout. # The GPU for a given rank is (rank % GPUS_PER_NODE...
# MIT License # Copyright (c) 2021 OpenAI # # This code is based on https://github.com/openai/guided-diffusion # MIT License # Copyright (c) 2022 Guy Tevet # # This code is based on https://github.com/GuyTevet/motion-diffusion-model # Copyright (c) Meta Platforms, Inc. All Rights Reserved import numpy as np import tor...
# MIT License # Copyright (c) 2021 OpenAI # # This code is based on https://github.com/openai/guided-diffusion from abc import ABC, abstractmethod import numpy as np import torch as th import torch.distributed as dist def create_named_schedule_sampler(name, diffusion): """ Create a ScheduleSampler from a lib...
""" Logger copied from OpenAI baselines to avoid extra RL-based dependencies: https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/logger.py """ # MIT License # Copyright (c) 2021 OpenAI # # This code is based on https://github.com/openai/guided-diffusion # Copyright (c) Meta Plat...
""" This code started out as a PyTorch port of Ho et al's diffusion models: https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils_2.py Docstrings have been added, as well as DDIM sampling and a new collection of beta schedules. """ # MIT License # Copyrigh...
""" Helpers for various likelihood-based losses. These are ported from the original Ho et al. diffusion models codebase: https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/utils.py """ # MIT License # Copyright (c) 2021 OpenAI # # This code is based on https://github.co...
# MIT License # Copyright (c) 2021 OpenAI # # This code is based on https://github.com/openai/guided-diffusion """ Helpers to train with 16-bit precision. """ import numpy as np import torch as th import torch.nn as nn from diffusion import logger from torch._utils import _flatten_dense_tensors, _unflatten_dense_tens...
""" This code started out as a PyTorch port of Ho et al's diffusion models: https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils_2.py Docstrings have been added, as well as DDIM sampling and a new collection of beta schedules. """ # MIT License # Copyrigh...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved import numpy as np import torch import torch.nn as nn from model.networks import DiffMLP class MetaModel(nn.Module): def __init__( self, arch, nfeats, latent_dim=256, num_layers=8, dropout=0.1, dataset...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved import torch.nn as nn ############################### ############ Layers ########### ############################### class MLPblock(nn.Module): def __init__(self, dim, seq0, seq1, first=False, w_embed=True): super().__init__() self.w_emb...
# Copyright (c) Meta Platforms, Inc. All Rights Reserved import glob import os import torch from torch.utils.data import DataLoader, Dataset from tqdm import tqdm class TrainDataset(Dataset): def __init__( self, dataset, mean, std, motions, sparses, input_...
# 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 setuptools import setup, find_packages with open('README.md', 'r') as f: long_description = f.read() with ope...
# 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 functools import wraps import multiprocessing import random import re from joblib import Parallel, delayed import t...
# 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 functools import wraps from pathlib import Path import shutil import tempfile from imohash import hashfile from ac...
# 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 functools import lru_cache import Levenshtein import numpy as np from access.resources.paths import FASTTEXT_EMBED...
# 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 abc import ABC from functools import wraps, lru_cache import hashlib from pathlib import Path import dill as pickle ...
# 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 functools import lru_cache import re from string import punctuation from nltk.tokenize.nist import NISTTokenizer fr...
# 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 itertools import product from pathlib import Path REPO_DIR = Path(__file__).resolve().parent.parent.parent EXP_DIR ...