python_code
stringlengths
0
4.04M
repo_name
stringlengths
7
58
file_path
stringlengths
5
147
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_uninitialized_test.py
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_color_test.py
#!/usr/bin/env python # # Copyright 2006, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_break_on_failure_unittest.py
#!/usr/bin/env python # # Copyright 2009, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_help_test.py
#!/usr/bin/env python # # Copyright 2009 Google Inc. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_shuffle_test.py
#!/usr/bin/env python # # Copyright 2005 Google Inc. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_filter_unittest.py
#!/usr/bin/env python # # Copyright 2006, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_test_utils.py
#!/usr/bin/env python # # Copyright 2010 Google Inc. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list o...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_catch_exceptions_test.py
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_xml_outfiles_test.py
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_output_test.py
#!/usr/bin/env python # # Copyright 2006, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_xml_test_utils.py
#!/usr/bin/env python # # Copyright 2009, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_throw_on_failure_test.py
#!/usr/bin/env python # # Copyright 2006, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_list_tests_unittest.py
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/test/gtest_env_var_test.py
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/scripts/pump.py
#!/usr/bin/env python # # Copyright 2009, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/scripts/fuse_gtest_files.py
#!/usr/bin/env python # # Copyright 2006, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
dimmwitted-master
lib/gtest-1.7.0/scripts/gen_gtest_pred_impl.py
import argparse from distutils.command.config import config import yaml import itertools import os import importlib import time import tqdm import numpy as np import subprocess from copy import deepcopy GPUS = {'v100': 'nvidia-tesla-v100', 'p100': 'nvidia-tesla-p100', 'a100': 'nvidia-tesla-a100', 't4': 'nvidia-tesla-...
gcp-cloud-nine-master
gcp/run_jobs.py
import argparse import yaml import subprocess import os import sys GPUS = {'v100': 'nvidia-tesla-v100', 'p100': 'nvidia-tesla-p100', 't4': 'nvidia-tesla-t4'} def startup_commands(): cmds = ['cd /home/workspace/projects/muscaria/', # insert pip install or apt-get commands here if any ...
gcp-cloud-nine-master
gcp/launch.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch import torchvision from transformers import BertForSequenceClassification, AdamW, get_scheduler class ToyNet(torch.nn.Module): def __init__(self, dim, gammas): super(ToyNet, self).__init__() # gammas is a list of ...
BalancingGroups-main
models.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import argparse import os import re import tarfile from zipfile import ZipFile import logging logging.basicConfig(level=logging.INFO) import gdown import pandas as pd from six import remove_move def download_and_extract(url, dst, remove=True): ...
BalancingGroups-main
setup_datasets.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import os import torch import submitit from itertools import product from train import run_experiment, parse_args def product_dict(**kwargs): keys = kwargs.keys() vals = kwargs.values() for instance in product(*vals): yield di...
BalancingGroups-main
train_toy.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import os import torch import pandas as pd import numpy as np from PIL import Image from torchvision import transforms from transformers import BertTokenizer from torch.utils.data import DataLoader from sklearn.datasets import make_blobs import pa...
BalancingGroups-main
datasets.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import matplotlib from matplotlib.colors import ListedColormap import numpy as np import torch import torch.utils.data from models import ToyNet from parse import parse_json_to_df from datasets import Toy import matplotlib.pyplot as plt from torch ...
BalancingGroups-main
plot_toy_scatter.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved #!/usr/bin/env python import os import sys import json import time import torch import submitit import argparse import numpy as np import models from datasets import get_loaders class Tee: def __init__(self, fname, stream, mode="a+"): ...
BalancingGroups-main
train.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved #!/usr/bin/env python import os import glob import json import argparse from typing import ContextManager import pandas as pd from pandas.core.indexes import multi import seaborn as sns import matplotlib.pyplot as plt import numpy as np from pathl...
BalancingGroups-main
parse.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # from utils.masks import generate_masks, evaluate_masks import torch def train(*args, **kwargs): return {} params =...
calibration_membership-main
api.py
# -*- coding: utf-8 -*- # Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import argparse import json import os import sys import inspect currentdir = os.path.dirname(os...
calibration_membership-main
training/image_classification.py
# -*- coding: utf-8 -*- # Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import argparse import json import os from models import build_model from datasets import get_...
calibration_membership-main
training/language_modeling.py
calibration_membership-main
training/__init__.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch import torchvision import torchvision.transforms as transforms from torch.utils.data import Dataset, Tenso...
calibration_membership-main
datasets/__init__.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch class TextIterator: def __init__(self, sequence, batch_size, seq_len): assert sequence.ndim =...
calibration_membership-main
datasets/text_data.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # # Taken from https://github.com/facebookresearch/XLM import argparse FALSY_STRINGS = {'off', 'false', '0'} TRUTHY_STRI...
calibration_membership-main
utils/misc.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # from datetime import timedelta import logging import re import sys import time class LogFormatter(): def __init_...
calibration_membership-main
utils/logger.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import numpy as np import torch import operator def to_mask(n_data, indices): mask = torch.zeros(n_data, dtype=bo...
calibration_membership-main
utils/masks.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import re import inspect import json import itertools from torch import optim import numpy as np from logging import ge...
calibration_membership-main
utils/optimizer.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # from collections import OrderedDict import functools import os import time import numpy as np import torch from torch....
calibration_membership-main
utils/trainer.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # from logging import getLogger from collections import OrderedDict import numpy as np import torch from torch.nn import ...
calibration_membership-main
utils/evaluator.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch.nn as nn import torch.nn.functional as F class KLLeNet(nn.Module): def __init__(self, params): ...
calibration_membership-main
models/KLlenet.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch.nn as nn import torch.nn.functional as F class LinearNet(nn.Module): def __init__(self, params): ...
calibration_membership-main
models/linear.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch.nn as nn import torch.nn.functional as F from .lenet import LeNet from .KLlenet import KLLeNet from .lstml...
calibration_membership-main
models/__init__.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch.nn as nn import torch.nn.functional as F class MLP(nn.Module): def __init__(self, params): su...
calibration_membership-main
models/mlp.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch.nn as nn import torch.nn.functional as F class LeNet(nn.Module): def __init__(self, params): ...
calibration_membership-main
models/lenet.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # from opacus.layers import DPLSTM import torch import torch.nn as nn class LSTMLM(nn.Module): def __init__(self, p...
calibration_membership-main
models/lstmlm.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import torch import torch.nn as nn class AlexNet(nn.Module): def __init__(self, params): super(AlexNet, s...
calibration_membership-main
models/alexnet.py
calibration_membership-main
attacks/__init__.py
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the CC-by-NC license found in the # LICENSE file in the root directory of this source tree. # import os from posixpath import join import sys import inspect import math from random import randrange import pickle ...
calibration_membership-main
attacks/privacy_attacks.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/closest_augs.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/test_imagenet.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. import os import argparse import overlap.utils.logging as lu import decimal import simplejson import numpy as np import omegaconf from itertoo...
augmentation-corruption-fbr_main
experiments/sample_datasets.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net_jsd import train_net from overlap.test_net import test_...
augmentation-corruption-fbr_main
experiments/train_imagenet_jsd.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. import os import numpy as np import argparse parser = argparse.ArgumentParser(description="Calculate corruptions distance "\ "to the ...
augmentation-corruption-fbr_main
experiments/calc_distance_shifts.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/severity_scan_imagenet.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net_jsd import train_net from overlap.test_net import test_...
augmentation-corruption-fbr_main
experiments/train_cifar10_jsd.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/feature_corrupt_error.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/severity_scan.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/test_cifar10.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/train_imagenet.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. import hydra from hydra.utils import instantiate import logging from overlap.train_net import train_net from overlap.test_net import test_net ...
augmentation-corruption-fbr_main
experiments/train_cifar10.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. import os import argparse import overlap.utils.logging as lu import decimal import simplejson import numpy as np import omegaconf from itertoo...
augmentation-corruption-fbr_main
experiments/tools/get_target_error.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. import os import argparse import overlap.utils.logging as lu import decimal import simplejson import numpy as np import omegaconf parser = ar...
augmentation-corruption-fbr_main
experiments/tools/summarize.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. import numpy as np import argparse parser = argparse.ArgumentParser(description="Generate random indicies '\ 'for sampling from the C...
augmentation-corruption-fbr_main
experiments/tools/sample_image_indices.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. import torch import logging from .utils import logging as lu from omegaconf import open_dict from .augmentations.utils import aug_finder from...
augmentation-corruption-fbr_main
experiments/overlap/test_corrupt_net.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. import torch import logging from .utils import logging as lu log = logging.getLogger(__name__) def test_net(model, test_dataset, batch_size,...
augmentation-corruption-fbr_main
experiments/overlap/test_net.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. import math import torch import torch.nn as nn import torch.nn.functional as F class ResHead(nn.Module): """ResNet head.""" def __in...
augmentation-corruption-fbr_main
experiments/overlap/models.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. import torch import logging from .utils import logging as lu import numpy as np import os log = logging.getLogger(__name__) def distributed_...
augmentation-corruption-fbr_main
experiments/overlap/extract_features.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 . import augmentations as aug from .augmentations.utils.converters import NumpyToTensor, PilToNumpy from .augmentations.utils.aug_finder ...
augmentation-corruption-fbr_main
experiments/overlap/datasets.py
augmentation-corruption-fbr_main
experiments/overlap/__init__.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. import torch import logging import os import time import datetime import torch.nn as nn import torch.nn.functional as F log = logging.getLogg...
augmentation-corruption-fbr_main
experiments/overlap/train_net_jsd.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. import torch import numpy as np from hydra.utils import instantiate from .train_net import train_net class Network(object): def __in...
augmentation-corruption-fbr_main
experiments/overlap/feature_extractor.py
# This source code is adapted from code licensed under the MIT license # found in third_party/wideresnet_license from the root directory of # this source tree. """WideResNet implementation (https://arxiv.org/abs/1605.07146).""" import math import torch import torch.nn as nn import torch.nn.functional as F class Bas...
augmentation-corruption-fbr_main
experiments/overlap/wideresnet.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. import torch import logging import os import time import datetime log = logging.getLogger(__name__) def eta_str(eta_td): """Converts an ...
augmentation-corruption-fbr_main
experiments/overlap/train_net.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. import simplejson import decimal import logging log = logging.getLogger(__name__) _TAG = 'json_stats: ' def log_json_stats(stats): """Lo...
augmentation-corruption-fbr_main
experiments/overlap/utils/logging.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. import numpy as np class Cosine(object): def __init__(self, base_lr, max_epoch): self.base_lr = base_lr self.max_epoch = ...
augmentation-corruption-fbr_main
experiments/overlap/utils/lr_policy.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 .base import Augmentation from scipy.ndimage import gaussian_filter from .utils.severity import float_parameter, int_parameter, sample_le...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/distortion.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 .base import Augmentation from .utils.image import bilinear_interpolation from .utils.severity import float_parameter, int_parameter, sam...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/blurs.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 .base import Augmentation from math import floor, ceil import numpy as np class Gaussian(Augmentation): name = 'pg_gaussian' tag...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/patch_gaussian.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 .base import Augmentation import numpy as np from .utils.severity import int_parameter, float_parameter, sample_level from .utils.image i...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/color.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 . import identity from . import base from . import pil from . import obscure from . import additive_noise from . import color from . impo...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/__init__.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 .base import Augmentation from .utils.severity import float_parameter, int_parameter, sample_level from .utils.image import smoothstep fr...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/additive_noise.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 .base import Augmentation import numpy as np class Cifar10CropAndFlip(Augmentation): def sample_parameters(self): crop_pos ...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/standard_augmentations.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 .base import Augmentation from .utils.severity import float_parameter, int_parameter, sample_level from PIL import Image, ImageOps, Imag...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/pil.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 math import floor, ceil import numpy as np from .base import Augmentation from .utils.severity import int_parameter, sample_level, float_...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/obscure.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 .base import Augmentation class Identity(Augmentation): tags = ["identity"] name = ['identity'] def __init__(self, severit...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/identity.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 .base import Augmentation from collections import namedtuple import numpy as np class Augmix(Augmentation): tags = ['compositor', '...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/compositions.py
# This source code is adapted from code licensed under the license at # third_party/imagenetc_license from the root directory of the repository # Originally available: github.com/hendrycks/robustness # Modifications Copyright (c) Facebook, Inc. and its affiliates, # licensed under the MIT license found in the LICENSE...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/imagenetc.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. import abc import numpy as np def is_iterable(obj): try: iter(obj) except: return False else: return Tru...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/base.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. import numpy as np def int_parameter(level, maxval): return int(level * maxval / 10) def float_parameter(level, maxval): return float(l...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/utils/severity.py
augmentation-corruption-fbr_main
experiments/overlap/augmentations/utils/__init__.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 ... import augmentations as aug master_aug_list = [ aug.pil.AutoContrast, aug.pil.Equalize, aug.pil.Posterize, aug.pil.S...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/utils/aug_finder.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. import numpy as np class PerlinNoiseGenerator(object): def __init__(self, random_state=None): self.rand = np.random if random_sta...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/utils/noise.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. import numpy as np from PIL import Image import torch class PilToNumpy(object): def __init__(self, as_float=False, scaled_to_one=False): ...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/utils/converters.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. import numpy as np def smoothstep(low, high, x): x = np.clip(x, low, high) x = (x - low) / (high - low) return np.clip(3 * (x ** ...
augmentation-corruption-fbr_main
experiments/overlap/augmentations/utils/image.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 transform_finder import build_transform import torch import torchvision as tv from utils.converters import PilToNumpy, NumpyToTensor CIF...
augmentation-corruption-fbr_main
imagenet_c_bar/test_c_bar.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. import corrupt as corr transform_list = [ corr.ColorBalance, corr.QuadrilateralNoBars, corr.PerspectiveNoBars, corr.SingleFre...
augmentation-corruption-fbr_main
imagenet_c_bar/transform_finder.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. import argparse import torchvision as tv from transform_finder import build_transform from utils.converters import PilToNumpy, NumpyToPil impo...
augmentation-corruption-fbr_main
imagenet_c_bar/make_imagenet_c_bar.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. import numpy as np from math import floor, ceil from PIL import Image from scipy.fftpack import ifft2 from scipy.ndimage import gaussian_filt...
augmentation-corruption-fbr_main
imagenet_c_bar/corrupt.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. import argparse import torchvision as tv from transform_finder import build_transform from utils.converters import PilToNumpy, NumpyToPil impo...
augmentation-corruption-fbr_main
imagenet_c_bar/make_cifar10_c_bar.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. import abc import numpy as np def is_iterable(obj): try: iter(obj) except: return False else: return Tru...
augmentation-corruption-fbr_main
imagenet_c_bar/base.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. import numpy as np from PIL import Image import torch class PilToNumpy(object): def __init__(self, as_float=False, scaled_to_one=False): ...
augmentation-corruption-fbr_main
imagenet_c_bar/utils/converters.py