python_code
stringlengths
0
4.04M
repo_name
stringlengths
8
58
file_path
stringlengths
5
147
#!/usr/bin/env python3 # 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 os import tempfile import unittest from typing import Callable import numpy as np from aug...
AugLy-main
augly/tests/audio_tests/base_unit_test.py
#!/usr/bin/env python3 # 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 import random import unittest import numpy as np from augly import audio as audaugs f...
AugLy-main
augly/tests/audio_tests/transforms_unit_test.py
AugLy-main
augly/tests/video_tests/__init__.py
#!/usr/bin/env python3 # 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 os import unittest from typing import List from unittest.mock import MagicMock, patch from...
AugLy-main
augly/tests/video_tests/metadata_unit_test.py
#!/usr/bin/env python3 # 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 hashlib import os import tempfile import unittest from typing import Any, Callable, Dict, L...
AugLy-main
augly/tests/video_tests/base_unit_test.py
#!/usr/bin/env python3 # 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 import unittest from augly import video as vidaugs from augly.tests.base_configs impo...
AugLy-main
augly/tests/video_tests/transforms/image_based_test.py
#!/usr/bin/env python3 # 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 import unittest from augly import video as vidaugs from augly.tests.base_configs impo...
AugLy-main
augly/tests/video_tests/transforms/ffmpeg_test.py
#!/usr/bin/env python3 # 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 import unittest from augly import video as vidaugs from augly.tests.video_tests.base_...
AugLy-main
augly/tests/video_tests/transforms/cv2_test.py
AugLy-main
augly/tests/video_tests/transforms/__init__.py
#!/usr/bin/env python3 # 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 import random import unittest from augly import audio as audaugs, video as vidaugs fr...
AugLy-main
augly/tests/video_tests/transforms/composite_test.py
#!/usr/bin/env python3 # 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 unittest from augly.text.augmenters.utils import ( detokenize, rejoin_words_and_wh...
AugLy-main
augly/tests/text_tests/utils_test.py
AugLy-main
augly/tests/text_tests/__init__.py
#!/usr/bin/env python3 # 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. # @lint-ignore-every UTF8 import random import unittest from augly import text as txtaugs from au...
AugLy-main
augly/tests/text_tests/functional_unit_test.py
#!/usr/bin/env python3 # 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. # @lint-ignore-every UTF8 import json import os import random import unittest from typing import A...
AugLy-main
augly/tests/text_tests/transforms_unit_test.py
#!/usr/bin/env python3 # 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 from augly.utils.classes import Segment def compute_time_crop_segments(...
AugLy-main
augly/utils/functions.py
#!/usr/bin/env python3 # 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 os import random from augly.utils.base_paths import ( AUDIO_ASSETS_DIR, EMOJI_DIR,...
AugLy-main
augly/utils/constants.py
#!/usr/bin/env python3 # 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 iopath.common.file_io import HTTPURLHandler, PathManager pathmgr = PathManager() pathmgr.re...
AugLy-main
augly/utils/io.py
#!/usr/bin/env python3 # 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 os from distutils import spawn from typing import Tuple FFMPEG_PATH = os.environ.get("AUGL...
AugLy-main
augly/utils/ffmpeg.py
#!/usr/bin/env python3 # 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 augly.utils.asserts import ( is_audio_file, is_image_file, is_video_file, val...
AugLy-main
augly/utils/__init__.py
#!/usr/bin/env python3 # 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. def install_libsndfile(): pass
AugLy-main
augly/utils/libsndfile.py
#!/usr/bin/env python3 # 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 os MODULE_BASE_DIR = os.path.dirname(os.path.dirname(__file__)) # asset paths ASSETS_BASE...
AugLy-main
augly/utils/base_paths.py
#!/usr/bin/env python3 # 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 NamedTuple, Optional class Segment(NamedTuple): start: float end: flo...
AugLy-main
augly/utils/classes.py
#!/usr/bin/env python3 # 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 os from typing import Tuple import magic from augly.utils.io import pathmgr def is_conte...
AugLy-main
augly/utils/asserts.py
#!/usr/bin/env python3 # 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 os import random from typing import Any, Callable, Dict, List, Optional, Tuple, Union from...
AugLy-main
augly/image/transforms.py
#!/usr/bin/env python3 # 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 Any, Dict, Optional, Union import numpy as np from augly.image import utils as...
AugLy-main
augly/image/intensity.py
#!/usr/bin/env python3 # 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 augly.image.composition import Compose, OneOf from augly.image.functional import ( apply_...
AugLy-main
augly/image/__init__.py
#!/usr/bin/env python3 # 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 io import math import os import pickle from copy import deepcopy from typing import Any, Ca...
AugLy-main
augly/image/functional.py
#!/usr/bin/env python3 # 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 random from typing import Any, Dict, List, Optional, Tuple from augly.image.transforms imp...
AugLy-main
augly/image/composition.py
#!/usr/bin/env python3 # 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 Callable import numpy as np from PIL import Image def aug_np_wrapper( im...
AugLy-main
augly/image/helpers.py
#!/usr/bin/env python3 # 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 copy import deepcopy from typing import Any, Callable, Dict, List, Optional, Tuple from augl...
AugLy-main
augly/image/utils/metadata.py
#!/usr/bin/env python3 # 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 augly.image.utils.metadata import get_func_kwargs, get_metadata from augly.image.utils.utils ...
AugLy-main
augly/image/utils/__init__.py
#!/usr/bin/env python3 # 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 json import math import os from typing import List, Optional, Tuple, Union...
AugLy-main
augly/image/utils/utils.py
#!/usr/bin/env python3 # 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 math from typing import Callable, List, Optional, Tuple import numpy as np from augly.imag...
AugLy-main
augly/image/utils/bboxes.py
#!/usr/bin/env python3 # 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 random from typing import Any, Callable, Dict, List, Optional, Tuple, Union import numpy a...
AugLy-main
augly/audio/transforms.py
#!/usr/bin/env python3 # 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 Any, Callable, Dict, Optional, Tuple import numpy as np """ This file contai...
AugLy-main
augly/audio/intensity.py
#!/usr/bin/env python3 # 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 augly.audio.composition import Compose, OneOf from augly.audio.functional import ( add_ba...
AugLy-main
augly/audio/__init__.py
#!/usr/bin/env python3 # 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 copy import deepcopy from typing import Any, Callable, Dict, List, Optional, Tuple, Union im...
AugLy-main
augly/audio/functional.py
#!/usr/bin/env python3 # 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 numbers from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np impo...
AugLy-main
augly/audio/utils.py
#!/usr/bin/env python3 # 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 random from typing import Any, Dict, List, Optional, Tuple import numpy as np from augly.a...
AugLy-main
augly/audio/composition.py
#!/usr/bin/env python3 # 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 inspect import random from typing import Any, Callable, Dict, List, Optional, Union from a...
AugLy-main
augly/text/transforms.py
#!/usr/bin/env python3 # 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 Any, Dict, List, Optional, Union def apply_lambda_intensity(aug_function: str...
AugLy-main
augly/text/intensity.py
#!/usr/bin/env python3 # 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 augly.text.composition import Compose, OneOf from augly.text.functional import ( apply_la...
AugLy-main
augly/text/__init__.py
#!/usr/bin/env python3 # 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 copy import deepcopy from typing import Any, Callable, Dict, List, Optional, Union from augl...
AugLy-main
augly/text/functional.py
#!/usr/bin/env python3 # 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 copy import deepcopy from typing import Any, Dict, List, Optional, Union from au...
AugLy-main
augly/text/utils.py
#!/usr/bin/env python3 # 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 random from typing import Any, Dict, List, Optional, Union from augly.text.transforms impo...
AugLy-main
augly/text/composition.py
#!/usr/bin/env python3 # 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, Union from augly.text.augmenters.utils import ( detokenize, get_...
AugLy-main
augly/text/augmenters/upside_down.py
#!/usr/bin/env python3 # 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 typing import Any, Dict, List, Optional, Tuple, Union from augly.text.augmenters...
AugLy-main
augly/text/augmenters/word_replacement.py
#!/usr/bin/env python3 # 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 typing import List, Optional from augly.text.augmenters.utils import ( detok...
AugLy-main
augly/text/augmenters/typo.py
#!/usr/bin/env python3 # 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 augly.text.augmenters.utils import detokenize, tokenize from augly.utils.libsndfile import in...
AugLy-main
augly/text/augmenters/baseline.py
#!/usr/bin/env python3 # 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 typing import List, Optional from augly.text.augmenters.utils import ( get_a...
AugLy-main
augly/text/augmenters/letter_replacement.py
#!/usr/bin/env python3 # 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 import random from typing import List, Optional, Union from augly.text.augmenters.uti...
AugLy-main
augly/text/augmenters/fun_fonts.py
#!/usr/bin/env python3 # 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 augly.text.augmenters.baseline import BaselineAugmenter from augly.text.augmenters.bidirectio...
AugLy-main
augly/text/augmenters/__init__.py
#!/usr/bin/env python3 # 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 random from typing import List, Optional from augly.text.augmenters.utils import detokeniz...
AugLy-main
augly/text/augmenters/words_augmenter.py
#!/usr/bin/env python3 # 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, Union from augly.text.augmenters.utils import ( rejoin_words_and_whi...
AugLy-main
augly/text/augmenters/bidirectional.py
#!/usr/bin/env python3 # 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, List, Union class TextReplacementAugmenter: """ Replaces the in...
AugLy-main
augly/text/augmenters/text_replacement.py
#!/usr/bin/env python3 # 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 random import Random from typing import List, Optional, Union class InsertTextAugmenter: ...
AugLy-main
augly/text/augmenters/insert_text.py
#!/usr/bin/env python3 # 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 from typing import List, Optional, Tuple import regex from augly.utils.libsndfile impor...
AugLy-main
augly/text/augmenters/utils.py
#!/usr/bin/env python3 # 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 math import random from typing import List, Union from augly.text.augmenters.utils import ...
AugLy-main
augly/text/augmenters/insertion.py
#!/usr/bin/env python3 # 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 math from typing import List, Optional, Union import numpy as np from augly.text.augmenter...
AugLy-main
augly/text/augmenters/case.py
#!/usr/bin/env python3 # 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 typing import Any, Dict, List, Optional, Union import numpy as np from augly.tex...
AugLy-main
augly/text/augmenters/contraction.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Clinical-Trial-Parser-main
src/embedding/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # fastText options for training word embeddings options = { "model": "cbow", "loss": "ns", "dim": 100, "ws": 5, "neg": 5, "minCount": 5, "bucket": 2000000, "t": 1e-5, "minn": 0, "maxn...
Clinical-Trial-Parser-main
src/embedding/param.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. """ Train word embeddings with FastText. Run: python src/embedding/train_embeddings.py -i <input file> -o <output file> """ import os import fasttext import numpy as np from argparse import ArgumentParser import embeddin...
Clinical-Trial-Parser-main
src/embedding/train_embeddings.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import unittest from text.transformer import Normalizer from text.transformer import Transformer class TestNormalizer(unittest.TestCase): norm = Normalizer() def test_less(self): actual = self.norm.normal...
Clinical-Trial-Parser-main
src/text/transformer_test.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Clinical-Trial-Parser-main
src/text/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import re import nltk # number or number range def is_number(s): try: float(s.replace(",", "").replace("-", "")) return True except ValueError: return False class Normalizer: def __in...
Clinical-Trial-Parser-main
src/text/transformer.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. """ Process annotated eligibility criteria to a format suitable for training and testing NER models with PyText. Duplicate samples are removed. Run: python src/ie/process_ner_data.py -i <input file> -o <output file> For e...
Clinical-Trial-Parser-main
src/ie/process_ner_data.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
Clinical-Trial-Parser-main
src/ie/__init__.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # # Extract medical terms from clinical-trial eligibility criteria with a NER model. # # python src/ie/ner.py -m <model file> -i <input file> -o <output file> import json from itertools import groupby from argparse import...
Clinical-Trial-Parser-main
src/ie/ner.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
main_pretrain.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. # -------------------------------------------------------- # A script to run multinode training with submitit. # ----------...
AudioMAE-main
submitit_finetune.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. # -------------------------------------------------------- # References: # timm: https://github.com/rwightman/pytorch-image...
AudioMAE-main
models_vit.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
main_finetune_esc.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
engine_finetune.py
# This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit # BEiT: https://github.com/microsoft/unilm/tree/master/beit # AST: https://git...
AudioMAE-main
dataset.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
engine_pretrain.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
engine_finetune_as.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. # -------------------------------------------------------- # A script to run multinode training with submitit. # ----------...
AudioMAE-main
submitit_linprobe.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. # -------------------------------------------------------- # References: # timm: https://github.com/rwightman/pytorch-image...
AudioMAE-main
models_mae.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
main_finetune_as.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. # -------------------------------------------------------- # A script to run multinode training with submitit. # ----------...
AudioMAE-main
submitit_pretrain.py
import logging import math from copy import deepcopy from typing import Tuple, Optional, List, Union, Any, Type import torch import torch.nn as nn import torch.utils.checkpoint as checkpoint from .layers import DropPath, to_2tuple class Mlp(nn.Module): """ MLP as used in Vision Transformer, MLP-Mixer and related...
AudioMAE-main
timm_patch/swin_transformer.py
""" Layer/Module Helpers Hacked together by / Copyright 2020 Ross Wightman """ from itertools import repeat import torch TORCH_MAJOR = int(torch.__version__.split('.')[0]) TORCH_MINOR = int(torch.__version__.split('.')[1]) if TORCH_MAJOR == 1 and TORCH_MINOR < 8: from torch._six import container_abcs else: im...
AudioMAE-main
timm_patch/helpers.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. # -------------------------------------------------------- # References: # ELECTRA https://github.com/google-research/elect...
AudioMAE-main
util/lr_decay.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
util/misc.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. # -------------------------------------------------------- # LARS optimizer, implementation from MoCo v3: # https://github....
AudioMAE-main
util/lars.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. # -------------------------------------------------------- # References: # DeiT: https://github.com/facebookresearch/deit #...
AudioMAE-main
util/datasets.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 math import torch from torchvision import transforms from torchvision.transforms import functional as F class R...
AudioMAE-main
util/crop.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. # -------------------------------------------------------- # Position embedding utils # -----------------------------------...
AudioMAE-main
util/pos_embed.py
import numpy as np from scipy import stats from sklearn import metrics import torch def d_prime(auc): standard_normal = stats.norm() d_prime = standard_normal.ppf(auc) * np.sqrt(2.0) return d_prime @torch.no_grad() def concat_all_gather(tensor): """ Performs all_gather operation on the provided te...
AudioMAE-main
util/stat.py
import torch import torch.nn as nn from timm.models.layers import to_2tuple class PatchEmbed_org(nn.Module): """ Image to Patch Embedding """ def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768): super().__init__() img_size = to_2tuple(img_size) patch_size = t...
AudioMAE-main
util/patch_embed.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 math def adjust_learning_rate(optimizer, epoch, args): """Decay the learning rate with half-cycle cosine after...
AudioMAE-main
util/lr_sched.py
# -*- coding: utf-8 -*- # modified from Yuan Gong@MIT's gen_weight_file import argparse import json import numpy as np import sys, os, csv def make_index_dict(label_csv): index_lookup = {} with open(label_csv, 'r') as f: csv_reader = csv.DictReader(f) line_count = 0 for row in csv_read...
AudioMAE-main
dataset/audioset/gen_weight.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import torch.nn as nn import torchvision.models as models def get_backbone(is_pretrained: bool, arch: str = "resnet18"): # Define the backbone if arch == "resnet18": backbone = models.resnet18(pretrained=is_pretr...
collaborative_image_understanding-main
src/architecture_utils.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time from typing import Tuple import hydra import pandas as pd from tqdm import tqdm from data_utils import DataHelper logger = logging.getLogger(__name__) def convert_to_...
collaborative_image_understanding-main
src/main_download_amazon_sets.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import numpy as np import pytorch_lightning as pl import torch import torch.nn as nn from sklearn.metrics import average_precision_score import os.path as osp from architecture_utils import get_backbone, get_cf_pre...
collaborative_image_understanding-main
src/lit_utils.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time from itertools import chain import imghdr import hydra import numpy as np import pandas as pd from omegaconf import DictConfig from sklearn.model_selection import train_t...
collaborative_image_understanding-main
src/main_process_labels_amazon.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time import hydra import matplotlib.pyplot as plt import pytorch_lightning as pl import torch from hydra.utils import get_original_cwd from omegaconf import DictConfig, OmegaC...
collaborative_image_understanding-main
src/main_train_model_cf_based.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time from glob import glob import hydra import numpy as np import torch from omegaconf import DictConfig, OmegaConf from torch.utils.data.dataloader import DataLoader from tqd...
collaborative_image_understanding-main
src/main_predict_testset.py
# Copyright (c) 2015-present, Meta Platforms, Inc. and affiliates. # All rights reserved. import logging import os import os.path as osp import time import hydra import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import OneHotEncoder from tqdm import tqdm from main_proc...
collaborative_image_understanding-main
src/main_download_pinterest_sets.py