python_code
stringlengths
0
4.04M
repo_name
stringlengths
7
58
file_path
stringlengths
5
147
# 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
# 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 def main(): impor...
av_hubert-main
avhubert/preparation/vox_manifest.py
import numpy as np import torch class RandomEmbedding(torch.nn.Embedding): """A class used for efficiently storing random circulant embeddings. For a n-by-d embedding matrix, we let each d-by-d submatrix be a circulant matrix parameterized by a d-dimensional random vector. To add further variability b...
random_embedding-master
random_embedding.py
import unittest import time import torch import numpy as np from random_embedding import RandomEmbedding class RandomEmbeddingTest(unittest.TestCase): def test_forward(self): for device in ['cuda','cpu']: if device=='cpu' or (device=='cuda' and torch.cuda.is_available()): print(...
random_embedding-master
random_embedding_test.py
# 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. from transformers import BertModel, BertTokenizer import torch from typing import List, Optional, Tuple, Union import to...
care-main
care_bert.py
# 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 re import lexicon_filtering import nltk import string from typing import List, Dict, Tuple tokenizer = nltk.data....
care-main
regex_pipeline.py
# 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 json from functools import partial import requests import pandas as pd import os from typing import Dict, List im...
care-main
download_posts.py
# 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 regex_pipeline from typing import Dict, List from collections import Counter import pandas as pd import utils # ...
care-main
care_predict.py
# 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. from typing import Dict # Clustering into seven affective responses. CLUSTER_MAP = { "disgusted": "angered", "s...
care-main
utils.py
# 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. from typing import List, Tuple, Dict # Map of keyword in the CARE lexicon to pattern combinations that are prohibited. ...
care-main
lexicon_filtering.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions.categorical import Categorical import torch_ac # Function from https://github.com/ikostrikov/pytorch-a2c-ppo-acktr/blob/master/model.py def init_params(m): classname = m.__class__.__name__ if classname.find("Linear") !...
rl-starter-files-master
model.py
import gym import gym_minigrid def make_env(env_key, seed=None): env = gym.make(env_key) env.seed(seed) return env
rl-starter-files-master
utils/env.py
from .agent import * from .env import * from .format import * from .other import * from .storage import *
rl-starter-files-master
utils/__init__.py
import random import numpy import torch import collections def seed(seed): random.seed(seed) numpy.random.seed(seed) torch.manual_seed(seed) if torch.cuda.is_available(): torch.cuda.manual_seed_all(seed) def synthesize(array): d = collections.OrderedDict() d["mean"] = numpy.mean(arra...
rl-starter-files-master
utils/other.py
import os import json import numpy import re import torch import torch_ac import gym import utils def get_obss_preprocessor(obs_space): # Check if obs_space is an image space if isinstance(obs_space, gym.spaces.Box): obs_space = {"image": obs_space.shape} def preprocess_obss(obss, device=Non...
rl-starter-files-master
utils/format.py
import csv import os import torch import logging import sys import utils def create_folders_if_necessary(path): dirname = os.path.dirname(path) if not os.path.isdir(dirname): os.makedirs(dirname) def get_storage_dir(): if "RL_STORAGE" in os.environ: return os.environ["RL_STORAGE"] r...
rl-starter-files-master
utils/storage.py
import torch import utils from model import ACModel class Agent: """An agent. It is able: - to choose an action given an observation, - to analyze the feedback (i.e. reward and done state) of its action.""" def __init__(self, obs_space, action_space, model_dir, device=None, argmax=False, num_en...
rl-starter-files-master
utils/agent.py
import argparse import time import numpy import torch import utils # Parse arguments parser = argparse.ArgumentParser() parser.add_argument("--env", required=True, help="name of the environment to be run (REQUIRED)") parser.add_argument("--model", required=True, help="name of...
rl-starter-files-master
scripts/visualize.py
import argparse import time import datetime import torch import torch_ac import tensorboardX import sys import utils from model import ACModel # Parse arguments parser = argparse.ArgumentParser() ## General parameters parser.add_argument("--algo", required=True, help="algorithm to use: a2c | pp...
rl-starter-files-master
scripts/train.py
import argparse import time import torch from torch_ac.utils.penv import ParallelEnv import utils # Parse arguments parser = argparse.ArgumentParser() parser.add_argument("--env", required=True, help="name of the environment (REQUIRED)") parser.add_argument("--model", required=True, ...
rl-starter-files-master
scripts/evaluate.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 setuptools import setup, find_packages with open('README.md', 'r') as f: long_description = f.read() with ope...
access-main
setup.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 functools import wraps import multiprocessing import random import re from joblib import Parallel, delayed import t...
access-main
access/preprocess.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 functools import wraps from pathlib import Path import shutil import tempfile from imohash import hashfile from ac...
access-main
access/simplifiers.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 functools import lru_cache import Levenshtein import numpy as np from access.resources.paths import FASTTEXT_EMBED...
access-main
access/feature_extraction.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 abc import ABC from functools import wraps, lru_cache import hashlib from pathlib import Path import dill as pickle ...
access-main
access/preprocessors.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 functools import lru_cache import re from string import punctuation from nltk.tokenize.nist import NISTTokenizer fr...
access-main
access/text.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 itertools import product from pathlib import Path REPO_DIR = Path(__file__).resolve().parent.parent.parent EXP_DIR ...
access-main
access/resources/paths.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 hashlib from pathlib import Path from access.preprocess import get_parallel_file_pair_preprocessor from access.pr...
access-main
access/resources/datasets.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 bz2 import gzip import os from pathlib import Path import shutil import sys import tarfile import tempfile import ...
access-main
access/resources/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. # from glob import glob import os from pathlib import Path import shutil import tempfile import numpy as np from access.t...
access-main
access/resources/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. # from collections import defaultdict from functools import lru_cache import shutil from nevergrad.instrumentation import ...
access-main
access/fairseq/main.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 collections import defaultdict import os from pathlib import Path import random import re import shutil import tempf...
access-main
access/fairseq/base.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 contextlib import contextmanager, AbstractContextManager from fcntl import flock, LOCK_EX, LOCK_UN import inspect im...
access-main
access/utils/helpers.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. # # TODO: Move to utils/training.py from functools import wraps import time def print_method_name(func): '''Decorator...
access-main
access/utils/training.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 access.utils.helpers import harmonic_mean # Tranforms take a value and cast it to a score between 0 and 1, the hig...
access-main
access/evaluation/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. # from easse.cli import evaluate_system_output from access.preprocess import lowercase_file, to_lrb_rrb_file from access.r...
access-main
access/evaluation/general.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 fileinput from access.preprocessors import get_preprocessors from access.resources.prepare import prepare_models ...
access-main
scripts/generate.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 access.fairseq.main import fairseq_train_and_evaluate from access.resources.prepare import prepare_wikilarge, prepar...
access-main
scripts/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 access.evaluation.general import evaluate_simplifier_on_turkcorpus from access.preprocessors import get_preprocessor...
access-main
scripts/evaluate.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 click from covid19_spread.data.usa import us_recurring @click.group() def cli(): pass REGION...
covid19_spread-main
recurring.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 click from covid19_spread.data.usa.convert import main as us_convert, SOURCES as US_SOURCES import ...
covid19_spread-main
prepare_data.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 setup( name="covid19_spread", version="0.1", py_mo...
covid19_spread-main
setup.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 copy import click import importlib import itertools import json import pandas as pd import os impor...
covid19_spread-main
cv.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 covid19_spread.bar import BARCV import yaml from argparse import Namespace import torch as th class...
covid19_spread-main
tests/test_batched_bar_inference.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 cv import pandas as pd from click.testing import CliRunner import pytest class TestCV: def tes...
covid19_spread-main
tests/test_cv.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 covid19_spread import load import pandas as pd import pytest DATA_PATH_US_CSV = "covid19_spread/data...
covid19_spread-main
tests/test_load.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 pandas as pd from datetime import timedelta def load_ground_truth(path): df...
covid19_spread-main
covid19_spread/metrics.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 pandas as pd from .cross_val import CV from . import load from datetime import timedelta def simu...
covid19_spread-main
covid19_spread/naive.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 pandas as pd from numpy.linalg import norm import os import re from covid19_sprea...
covid19_spread-main
covid19_spread/common.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 numpy as np import pandas as pd import warnings from datetime import timedelta impo...
covid19_spread-main
covid19_spread/bar.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 pandas as pd import torch as th import yaml from pathlib import Path import json import os def loa...
covid19_spread-main
covid19_spread/load.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 typing import Dict, Any, List, Tuple import pandas as pd from datetime import timedelta import torch a...
covid19_spread-main
covid19_spread/cross_val.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 click class DefaultGroup(click.Group): ignore_unknown_options = True def __init__(self, ...
covid19_spread-main
covid19_spread/lib/click_lib.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 submitit from submitit.slurm.slurm import SlurmExecutor, SlurmJob from submitit...
covid19_spread-main
covid19_spread/lib/slurm_pool_executor.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 contextlib import os import copy import sys import typing as tp @contextlib.contextmanager def en...
covid19_spread-main
covid19_spread/lib/context_managers.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 getpass USER = getpass.getuser() if os.path.exists(f"/checkpoint"): FS = "/checkpoi...
covid19_spread-main
covid19_spread/lib/cluster.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 slack import WebClient import os import json import warnings def post_slack_message(channel, text):...
covid19_spread-main
covid19_spread/lib/slack.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 os sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))...
covid19_spread-main
covid19_spread/data/recurring.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 from covid19_spread.common import update_repo import pandas import re import datetime def get_...
covid19_spread-main
covid19_spread/data/usa/process_cases.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 numpy as np import pandas as pd import torch as th from os import listdir from os.p...
covid19_spread-main
covid19_spread/data/usa/convert.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 from .. import recurring import pandas from ...lib.slack import post_slack_message from datetime...
covid19_spread-main
covid19_spread/data/usa/us_recurring.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 pandas as pd from datetime import datetime from covid19_spread.data.usa.process_cases import get_in...
covid19_spread-main
covid19_spread/data/usa/google/process_mobility.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 pandas from datetime import datetime import os from covid19_spread.data.usa.process_cases import get...
covid19_spread-main
covid19_spread/data/usa/google/process_open_data.py
#!/usr/bin/env python3 # Copyright (c) 2021-present, Facebook, Inc. # 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 .process_mobility import main as mobility_main from .process_open_data import main as open_data_main ...
covid19_spread-main
covid19_spread/data/usa/google/__init__.py