python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
#!/usr/bin/env python2
# 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
import ast
import json
import logging
import os
from collections import namedtuple
... | code-prediction-transformer-main | models/seq/generate_data.py |
#!/usr/bin/env python2
# 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
import sys
import six
from six import StringIO
# Large float and imaginary literals ge... | code-prediction-transformer-main | models/seq/astunparser.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from dataset.dataset import BaseDataset, BaseSetup, BaseVocab
class Setup(BaseSetup):... | code-prediction-transformer-main | models/path_trans/dataset.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import json
import logging
import os
from utils import file_tqdm
logging.basicCon... | code-prediction-transformer-main | models/path_trans/generate_data.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import json
import logging
import os
from utils import file_tqdm, separate_dps
lo... | code-prediction-transformer-main | models/trav_trans/generate_ast_ids.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from dataset.dataset import BaseDataset, BaseSetup, BaseVocab
class Setup(BaseSetup):... | code-prediction-transformer-main | models/trav_trans/dataset.py |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import json
import logging
import os
from utils import file_tqdm, get_dfs, separate... | code-prediction-transformer-main | models/trav_trans/generate_data.py |
"""
Alternative ERM model predictions by clustering representations
"""
import os
import copy
import torch
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from torchvision.utils import make_grid
import torchvision.transforms as transforms
from PIL import Image
from itertools import permutations
f... | correct-n-contrast-main | slice_rep.py |
"""
Functions for slicing data
NOTE: Going to refactor this with slice_train.py and spurious_train.py
- Currently methods support different demos / explorations
"""
import copy
import numpy as np
import torch
from torch.utils.data import DataLoader, SequentialSampler, SubsetRandomSampler
from tqdm import tqdm
f... | correct-n-contrast-main | slice.py |
"""
Methods for sampling datapoints to organize and load contrastive datapoints
Methods:
- prepare_contrastive_points()
- sample_anchors()
- sample_positives()
- sample_negatives()
- load_contrastive_data()
"""
import numpy as np
from tqdm import tqdm
from sklearn.cluster import KMeans
from sklearn.neighbors import ... | correct-n-contrast-main | contrastive_supervised_loader.py |
"""
Functions to help with feature representations
"""
import numpy as np
import torch
from tqdm import tqdm
from utils import print_header
from utils.visualize import plot_umap
from network import get_output
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
cl... | correct-n-contrast-main | activations.py |
import torch
import torch.nn as nn
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d',
'wide_resnet50_2', 'wide_resnet101_2']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'r... | correct-n-contrast-main | resnet.py |
"""
Correct-n-Contrast main script
"""
import os
import sys
import copy
import argparse
import importlib
import torch
import torch.nn.functional as f
import pandas as pd
import numpy as np
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from PIL import Image
from tqdm import tqdm
# Data
... | correct-n-contrast-main | train_supervised_contrast.py |
"""
Model architecture
"""
import os
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
from collections import OrderedDict
# conda install -c huggingface transformers
from transformers import BertForSequenceClassification, BertConfig
fr... | correct-n-contrast-main | network.py |
"""
Training, evaluating, calculating embeddings functions
"""
import os
import numpy as np
import torch
import torch.optim as optim
import matplotlib.pyplot as plt
import torch.nn.functional as F
from torch.utils.data import DataLoader
from tqdm import tqdm
from network import get_criterion, get_optim
from network im... | correct-n-contrast-main | train.py |
"""
Contrastive network architecture, loss, and functions
"""
import torch
import torch.nn as nn
import torchvision.models as models
from copy import deepcopy
from transformers import BertForSequenceClassification, BertConfig
from transformers import AdamW, get_linear_schedule_with_warmup
from utils import free_gpu
... | correct-n-contrast-main | contrastive_network.py |
"""
Epoch evaluation functions
"""
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from activations import visualize_activations
from network import save_checkpoint
from train import test_model
from utils.logging import summarize_acc
from utils.visualize import plot_data_batch, plot_co... | correct-n-contrast-main | evaluate.py |
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | correct-n-contrast-main | utils_glue.py |
"""
CXR8 Dataset
- Modified from https://github.com/jrzech/reproduce-chexnet
- Modified from https://github.com/nimz/stratification/blob/master/datasets/cxr.py
Example command:
python train_supervised_contrast.py --dataset cxr --arch resnet50_pt --train_encoder --pretrained_spurious_path "" --optim sgd --lr_s 1e-4 --m... | correct-n-contrast-main | datasets/cxr.py |
"""
Datasets
"""
import copy
import numpy as np
import importlib
def initialize_data(args):
"""
Set dataset-specific arguments
By default, the args.root_dir below should work ifinstalling datasets as
specified in the README to the specified locations
- Otherwise, change `args.root_dir` to the path... | correct-n-contrast-main | datasets/__init__.py |
"""
CelebA Dataset
- Reference code: https://github.com/kohpangwei/group_DRO/blob/master/data/celebA_dataset.py
- See Group DRO, https://arxiv.org/abs/1911.08731 for more
"""
import os
import numpy as np
import pandas as pd
import torch
import torchvision.transforms as transforms
from torch.utils.data import Dataset, D... | correct-n-contrast-main | datasets/celebA.py |
"""
Dataset grouer for subgroup and group_ix information
- Used by CivilComments
From WILDS: https://github.com/p-lambda/wilds/blob/main/wilds/common/grouper.py
"""
import numpy as np
import torch
# from wilds.common.utils import get_counts
# from wilds.datasets.wilds_dataset import WILDSSubset
import warnings
def ... | correct-n-contrast-main | datasets/grouper.py |
"""
Colored MNIST Dataset
"""
import copy
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.colors import LinearSegmentedColormap, to_rgb
from tqdm import tqdm
import torch
import torchvision
import torchvision.transforms as transforms
from torch.utils.data import Dataset,... | correct-n-contrast-main | datasets/colored_mnist.py |
"""
CivilComments Dataset
- Reference code: https://github.com/p-lambda/wilds/blob/main/wilds/datasets/civilcomments_dataset.py
- See WILDS, https://wilds.stanford.edu for more
"""
import os
import numpy as np
import pandas as pd
import torch
from torch.utils.data import Dataset, DataLoader
from transformers import Be... | correct-n-contrast-main | datasets/civilcomments.py |
"""
Waterbirds Dataset
- Reference code: https://github.com/kohpangwei/group_DRO/blob/master/data/cub_dataset.py
- See Group DRO, https://arxiv.org/abs/1911.08731 for more details
"""
import os
import numpy as np
import pandas as pd
import torch
import torchvision.transforms as transforms
from torch.utils.data import D... | correct-n-contrast-main | datasets/waterbirds.py |
"""
Logging functions and classes
"""
import os
import sys
import csv
import numpy as np
def summarize_acc(correct_by_groups, total_by_groups, stdout=True):
all_correct = 0
all_total = 0
min_acc = 101.
min_correct_total = [None, None]
if stdout:
print('Accuracies by groups:')
for yix, ... | correct-n-contrast-main | utils/logging.py |
"""
Functions for computing useful metrics, e.g. entropy, conditional entropy
"""
import numpy as np
import torch
from sklearn.metrics import roc_auc_score
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
def compute_entropy(targets):
vals, counts = np.uniqu... | correct-n-contrast-main | utils/metrics.py |
"""
Model attributes, from https://github.com/kohpangwei/group_DRO/blob/master/models.py
Used for: Waterbirds
"""
model_attributes = {
'bert': {
'feature_type': 'text'
},
'inception_v3': {
'feature_type': 'image',
'target_resolution': (299, 299),
'flatten': False
},
... | correct-n-contrast-main | utils/models.py |
"""
General utilities
"""
import os
import torch
import numpy as np
from os.path import join, exists
def print_header(stdout, style=None):
if style is None:
print("-" * len(stdout))
print(stdout)
print("-" * len(stdout))
elif style == "bottom":
print(stdout)
print("-" *... | correct-n-contrast-main | utils/__init__.py |
"""
Visualization functions
"""
import numpy as np
import matplotlib.pyplot as plt
import umap
import torch
import torch.nn.functional as F
from torchvision.utils import make_grid
from sklearn.manifold import MDS
from os.path import join
# from train import get_embeddings
def plot_data_batch(dataset, mean=0.0, std... | correct-n-contrast-main | utils/visualize.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 pathlib import Path
from setuptools import setup, find_packages
NAME = 'audiocraft'
DESCRIPTION = 'Audio generati... | audiocraft-main | setup.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.
"""
AudioCraft is a general framework for training audio generative models.
At the moment we provide the training code for... | audiocraft-main | audiocraft/__init__.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.
"""
Entry point for dora to launch solvers for running training loops.
See more info on how to use dora: https://github.c... | audiocraft-main | audiocraft/train.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.
"""
Provides cluster and tools configuration across clusters (slurm, dora, utilities).
"""
import logging
import os
from... | audiocraft-main | audiocraft/environment.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 torch
import torchmetrics
from ..data.audio_utils import convert_audio
from ..modules.chroma import ChromaExtract... | audiocraft-main | audiocraft/metrics/chroma_cosinesim.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 pathlib import Path
import typing as tp
import torch
import torchmetrics
from transformers import RobertaTokenizer ... | audiocraft-main | audiocraft/metrics/clap_consistency.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.
"""Metrics like CLAP score, FAD, KLD, Visqol, Chroma similarity, etc.
"""
# flake8: noqa
from .clap_consistency import CLA... | audiocraft-main | audiocraft/metrics/__init__.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 logging
from pathlib import Path
import os
import subprocess
import tempfile
import typing as tp
from audiocraft.... | audiocraft-main | audiocraft/metrics/fad.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 contextlib
from functools import partial
import logging
import os
import typing as tp
import torch
import torchme... | audiocraft-main | audiocraft/metrics/kld.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 csv
import json
import logging
from pathlib import Path
import tempfile
import typing as tp
import subprocess
impo... | audiocraft-main | audiocraft/metrics/visqol.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 typing as tp
import torch
from torch import nn
import torchaudio
def db_to_scale(volume: tp.Union[float, torch.T... | audiocraft-main | audiocraft/metrics/rvm.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 typing as tp
import torch
from torch import nn
from torch.nn import functional as F
def _unfold(a: ... | audiocraft-main | audiocraft/losses/sisnr.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.
"""Loss related classes and functions. In particular the loss balancer from
EnCodec, and the usual spectral losses."""
# ... | audiocraft-main | audiocraft/losses/__init__.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.
# Adapted from MIT code under the original license
# Copyright 2019 Tomoki Hayashi
# MIT License (https://opensource.org/l... | audiocraft-main | audiocraft/losses/stftloss.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 typing as tp
import numpy as np
from torchaudio.transforms import MelSpectrogram
import torch
from torch import n... | audiocraft-main | audiocraft/losses/specloss.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 typing as tp
import flashy
import torch
from torch import autograd
class Balancer:
"""Loss balancer.
T... | audiocraft-main | audiocraft/losses/balancer.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.
"""Adversarial losses and discriminator architectures."""
# flake8: noqa
from .discriminators import (
MultiPeriodDis... | audiocraft-main | audiocraft/adversarial/__init__.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.
"""
Utility module to handle adversarial losses without requiring to mess up the main training loop.
"""
import typing a... | audiocraft-main | audiocraft/adversarial/losses.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 typing as tp
import torch
import torch.nn as nn
import torch.nn.functional as F
from ...modules import NormConv2... | audiocraft-main | audiocraft/adversarial/discriminators/mpd.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 typing as tp
import torchaudio
import torch
from torch import nn
from einops import rearrange
from ...modules im... | audiocraft-main | audiocraft/adversarial/discriminators/msstftd.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 typing as tp
import numpy as np
import torch
import torch.nn as nn
from ...modules import NormConv1d
from .base ... | audiocraft-main | audiocraft/adversarial/discriminators/msd.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.
# flake8: noqa
from .mpd import MultiPeriodDiscriminator
from .msd import MultiScaleDiscriminator
from .msstftd import Mu... | audiocraft-main | audiocraft/adversarial/discriminators/__init__.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 abc import ABC, abstractmethod
import typing as tp
import torch
import torch.nn as nn
FeatureMapType = tp.List[to... | audiocraft-main | audiocraft/adversarial/discriminators/base.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.
"""
Wrapper around FSDP for more convenient use in the training loops.
"""
from contextlib import contextmanager
import ... | audiocraft-main | audiocraft/optim/fsdp.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.
# ModelEMA implementation is taken from
# https://github.com/facebookresearch/demucs
from collections import defaultdict... | audiocraft-main | audiocraft/optim/ema.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.
"""Optimization stuff. In particular, optimizers (DAdaptAdam), schedulers
and Exponential Moving Average.
"""
# flake8: n... | audiocraft-main | audiocraft/optim/__init__.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 logging
from typing import TYPE_CHECKING, Any
import torch
import torch.optim
import torch.distributed as dist
i... | audiocraft-main | audiocraft/optim/dadam.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 typing as tp
from torch.optim import Optimizer
from torch.optim.lr_scheduler import _LRScheduler
class InverseS... | audiocraft-main | audiocraft/optim/inverse_sqrt_lr_scheduler.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
from torch.optim import Optimizer
from torch.optim.lr_scheduler import _LRScheduler
class CosineLRSchedule... | audiocraft-main | audiocraft/optim/cosine_lr_scheduler.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 torch.optim import Optimizer
from torch.optim.lr_scheduler import _LRScheduler
class PolynomialDecayLRScheduler(_L... | audiocraft-main | audiocraft/optim/polynomial_decay_lr_scheduler.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 typing as tp
from torch.optim import Optimizer
from torch.optim.lr_scheduler import _LRScheduler
class LinearWa... | audiocraft-main | audiocraft/optim/linear_warmup_lr_scheduler.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.
"""
All the functions to build the relevant solvers and used objects
from the Hydra config.
"""
from enum import Enum
im... | audiocraft-main | audiocraft/solvers/builders.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 typing as tp
import flashy
import julius
import omegaconf
import torch
import torch.nn.functional as F
from . im... | audiocraft-main | audiocraft/solvers/diffusion.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 pathlib import Path
import time
import typing as tp
import flashy
import math
import omegaconf
import torch
from to... | audiocraft-main | audiocraft/solvers/musicgen.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 logging
import multiprocessing
from pathlib import Path
import typing as tp
import flashy
import omegaconf
import... | audiocraft-main | audiocraft/solvers/compression.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.
"""
Solvers. A Solver is a training recipe, combining the dataloaders, models,
optimizer, losses etc into a single conveni... | audiocraft-main | audiocraft/solvers/__init__.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 . import builders, musicgen
class AudioGenSolver(musicgen.MusicGenSolver):
"""Solver for AudioGen re-implement... | audiocraft-main | audiocraft/solvers/audiogen.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 abc import ABC, abstractmethod
from contextlib import contextmanager
from pathlib import Path
import typing as tp
i... | audiocraft-main | audiocraft/solvers/base.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 enum import Enum
import logging
from pathlib import Path
import re
import typing as tp
import flashy
import torch
... | audiocraft-main | audiocraft/utils/checkpoint.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 logging
import os
from queue import Queue, Empty
import signal
import sys
import threading
import traceback
logge... | audiocraft-main | audiocraft/utils/deadlock.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.
"""
Legacy functions used at the time of the first release, kept for referencd.
"""
from pathlib import Path
import typi... | audiocraft-main | audiocraft/utils/export_legacy.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 torch
class TorchAutocast:
"""TorchAutocast utility class.
Allows you to enable and disable autocast. Th... | audiocraft-main | audiocraft/utils/autocast.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 collections import defaultdict
import logging
import typing as tp
import flashy
import torch
from ..optim import M... | audiocraft-main | audiocraft/utils/best_state.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 concurrent.futures import ThreadPoolExecutor
from collections import deque
from functools import partial
from hashli... | audiocraft-main | audiocraft/utils/cache.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.
"""Utilities."""
| audiocraft-main | audiocraft/utils/__init__.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.
"""
Utility to export a training checkpoint to a lightweight release checkpoint.
"""
from pathlib import Path
import typ... | audiocraft-main | audiocraft/utils/export.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 concurrent.futures import ProcessPoolExecutor
from contextlib import contextmanager
from functools import wraps, lru... | audiocraft-main | audiocraft/utils/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.
"""
Utility functions for SLURM configuration and cluster settings.
"""
from enum import Enum
import os
import socket
im... | audiocraft-main | audiocraft/utils/cluster.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.
try:
import IPython.display as ipd # type: ignore
except ImportError:
# Note in a notebook...
pass
import ... | audiocraft-main | audiocraft/utils/notebook.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 logging
import typing as tp
import dora
import torch
logger = logging.getLogger(__name__)
class Profiler:
... | audiocraft-main | audiocraft/utils/profiler.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.
| audiocraft-main | audiocraft/utils/samples/__init__.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.
"""
API that can manage the storage and retrieval of generated samples produced by experiments.
It offers the following ... | audiocraft-main | audiocraft/utils/samples/manager.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.
"""Dora Grids."""
| audiocraft-main | audiocraft/grids/__init__.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 abc import ABC, abstractmethod
import time
import typing as tp
from dora import Explorer
import treetable as tt
de... | audiocraft-main | audiocraft/grids/_base_explorers.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 treetable as tt
from .._base_explorers import BaseExplorer
class DiffusionExplorer(BaseExplorer):
eval_metr... | audiocraft-main | audiocraft/grids/diffusion/_explorers.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.
"""Diffusion grids."""
| audiocraft-main | audiocraft/grids/diffusion/__init__.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.
"""
Training of the 4 diffusion models described in
"From Discrete Tokens to High-Fidelity Audio Using Multi-Band Diffusi... | audiocraft-main | audiocraft/grids/diffusion/4_bands_base_32khz.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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(launcher):... | audiocraft-main | audiocraft/grids/musicgen/musicgen_melody_32khz.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 typing as tp
import treetable as tt
from .._base_explorers import BaseExplorer
class LMExplorer(BaseExplorer):... | audiocraft-main | audiocraft/grids/musicgen/_explorers.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.
"""MusicGen grids."""
| audiocraft-main | audiocraft/grids/musicgen/__init__.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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(launcher):... | audiocraft-main | audiocraft/grids/musicgen/musicgen_clapemb_32khz.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.
"""
Evaluation with objective metrics for the pretrained MusicGen models.
This grid takes signature from the training gri... | audiocraft-main | audiocraft/grids/musicgen/musicgen_pretrained_32khz_eval.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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(launcher):... | audiocraft-main | audiocraft/grids/musicgen/musicgen_base_32khz.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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(launcher):... | audiocraft-main | audiocraft/grids/musicgen/musicgen_base_cached_32khz.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 treetable as tt
from .._base_explorers import BaseExplorer
class CompressionExplorer(BaseExplorer):
eval_me... | audiocraft-main | audiocraft/grids/compression/_explorers.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.
"""
Grid search file, simply list all the exp you want in `explorer`.
Any new exp added there will be scheduled.
You can ... | audiocraft-main | audiocraft/grids/compression/encodec_audiogen_16khz.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.
"""EnCodec grids."""
| audiocraft-main | audiocraft/grids/compression/__init__.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.
"""
Grid search file, simply list all the exp you want in `explorer`.
Any new exp added there will be scheduled.
You can ... | audiocraft-main | audiocraft/grids/compression/encodec_musicgen_32khz.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.
"""
Grid search file, simply list all the exp you want in `explorer`.
Any new exp added there will be scheduled.
You can ... | audiocraft-main | audiocraft/grids/compression/encodec_base_24khz.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.
"""
Grid search file, simply list all the exp you want in `explorer`.
Any new exp added there will be scheduled.
You can ... | audiocraft-main | audiocraft/grids/compression/debug.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.