index int64 0 50.7k | project_path stringclasses 279
values | completion_path stringlengths 57 199 | signature_postion stringlengths 3 11 | class_position stringlengths 3 11 | function_name stringlengths 1 62 | class_name stringlengths 0 55 | body_position stringlengths 3 11 | body_position_with_comments stringlengths 3 11 | masked_class stringlengths 14 8.32k | masked_class_with_comment stringlengths 14 8.32k | func_body stringlengths 9 6.72k | func_body_with_comment stringlengths 9 6.72k | len_func_body int64 1 643 | len_input int64 10 2.02k | len_output int64 4 1.9k | total int64 20 2.05k | file_code stringlengths 14 442k | file_code_with_comment stringlengths 14 442k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13,690 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/_base_explorers.py | 14,15 | 1,81 | get_sheep_ping | 17,31 | 15,31 | # 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... | # 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... | ping = None
if sheep.log is not None and sheep.log.exists():
delta = time.time() - sheep.log.stat().st_mtime
if delta > 3600 * 24:
ping = f'{delta / (3600 * 24):.1f}d'
elif delta > 3600:
ping = f'{delta / (3600):.1f}h'
elif delta > 60:
ping = f... | """Return the amount of time since the Sheep made some update
to its log. Returns a str using the relevant time unit."""
ping = None
if sheep.log is not None and sheep.log.exists():
delta = time.time() - sheep.log.stat().st_mtime
if delta > 3600 * 24:
ping = f'{delta / (3600 ... | 52 | 618 | 174 | 792 | # 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... | # 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... | |
13,691 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/_base_explorers.py | 60,61 | 31,81 | process_sheep | BaseExplorer | 61,81 | 61,81 | class BaseExplorer(ABC, Explorer):
"""Base explorer for AudioCraft grids.
All task specific solvers are expected to implement the `get_grid_metrics`
method to specify logic about metrics to display for a given task.
If additional stages are used, the child explorer must define how to handle
these ... | class BaseExplorer(ABC, Explorer):
"""Base explorer for AudioCraft grids.
All task specific solvers are expected to implement the `get_grid_metrics`
method to specify logic about metrics to display for a given task.
If additional stages are used, the child explorer must define how to handle
these ... | train = {
"epoch": len(history),
}
parts = {"train": train}
for metrics in history:
for key, sub in metrics.items():
part = parts.get(key, {})
if 'duration' in sub:
# Convert to minutes for readability.
... | train = {
"epoch": len(history),
}
parts = {"train": train}
for metrics in history:
for key, sub in metrics.items():
part = parts.get(key, {})
if 'duration' in sub:
# Convert to minutes for readability.
... | 76 | 295 | 203 | 498 | # 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... | # 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... |
13,692 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/audiogen/audiogen_base_16khz.py | 11,13 | 1,24 | explorer | 13,24 | 13,24 | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=64, partition=partitions)
launcher.bind_(solver='audiogen/audiogen_base_16khz')
# replace this by the desired environmental sound dataset
launcher.bind_(dset='internal/sounds_16khz')
fsdp = {'autoca... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=64, partition=partitions)
launcher.bind_(solver='audiogen/audiogen_base_16khz')
# replace this by the desired environmental sound dataset
launcher.bind_(dset='internal/sounds_16khz')
fsdp = {'autoca... | 29 | 102 | 160 | 262 | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | |
13,693 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/audiogen/audiogen_pretrained_16khz_eval.py | 26,27 | 1,69 | eval | 27,48 | 27,48 | # 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 AudioGen models.
This grid takes signature from the training gri... | # 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 AudioGen models.
This grid takes signature from the training gri... | opts = {
'dset': 'audio/audiocaps_16khz',
'solver/audiogen/evaluation': 'objective_eval',
'execute_only': 'evaluate',
'+dataset.evaluate.batch_size': batch_size,
'+metrics.fad.tf.batch_size': 32,
}
# binary for FAD computation: replace this path with your own path
... | opts = {
'dset': 'audio/audiocaps_16khz',
'solver/audiogen/evaluation': 'objective_eval',
'execute_only': 'evaluate',
'+dataset.evaluate.batch_size': batch_size,
'+metrics.fad.tf.batch_size': 32,
}
# binary for FAD computation: replace this path with your own path
... | 54 | 557 | 277 | 834 | # 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 AudioGen models.
This grid takes signature from the training gri... | # 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 AudioGen models.
This grid takes signature from the training gri... | |
13,694 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/compression/_explorers.py | 28,29 | 12,56 | get_grid_metrics | CompressionExplorer | 31,56 | 29,56 | class CompressionExplorer(BaseExplorer):
eval_metrics = ["sisnr", "visqol"]
def stages(self):
return ["train", "valid", "evaluate"]
def get_grid_meta(self):
"""Returns the list of Meta information to display for each XP/job.
"""
return [
tt.leaf("index", align="... | class CompressionExplorer(BaseExplorer):
eval_metrics = ["sisnr", "visqol"]
def stages(self):
return ["train", "valid", "evaluate"]
def get_grid_meta(self):
"""Returns the list of Meta information to display for each XP/job.
"""
return [
tt.leaf("index", align="... | return [
tt.group(
"train",
[
tt.leaf("epoch"),
tt.leaf("bandwidth", ".2f"),
tt.leaf("adv", ".4f"),
tt.leaf("d_loss", ".4f"),
],
align=">",
),
... | """Return the metrics that should be displayed in the tracking table.
"""
return [
tt.group(
"train",
[
tt.leaf("epoch"),
tt.leaf("bandwidth", ".2f"),
tt.leaf("adv", ".4f"),
... | 40 | 183 | 239 | 422 | # 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... | # 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... |
13,695 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/compression/debug.py | 21,23 | 1,32 | explorer | 23,32 | 23,32 | # 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 ... | # 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 ... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=2, partition=partitions)
launcher.bind_(solver='compression/debug')
with launcher.job_array():
# base debug task using config from solver=compression/debug
launcher()
# we can overri... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=2, partition=partitions)
launcher.bind_(solver='compression/debug')
with launcher.job_array():
# base debug task using config from solver=compression/debug
launcher()
# we can overri... | 34 | 191 | 138 | 329 | # 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 ... | # 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 ... | |
13,696 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/compression/encodec_audiogen_16khz.py | 19,21 | 1,30 | explorer | 21,30 | 21,30 | # 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 ... | # 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 ... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=8, partition=partitions)
# use configuration for AudioGen's EnCodec model trained on monophonic audio sampled at 16 kHz
# AudioGen's EnCodec is trained with a total stride of 320 leading to a frame rate of 5... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=8, partition=partitions)
# use configuration for AudioGen's EnCodec model trained on monophonic audio sampled at 16 kHz
# AudioGen's EnCodec is trained with a total stride of 320 leading to a frame rate of 5... | 54 | 169 | 174 | 343 | # 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 ... | # 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 ... | |
13,697 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/compression/encodec_base_24khz.py | 19,21 | 1,29 | explorer | 21,29 | 21,29 | # 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 ... | # 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 ... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=8, partition=partitions)
# base causal EnCodec trained on monophonic audio sampled at 24 kHz
launcher.bind_(solver='compression/encodec_base_24khz')
# replace this by the desired dataset
launcher.bin... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=8, partition=partitions)
# base causal EnCodec trained on monophonic audio sampled at 24 kHz
launcher.bind_(solver='compression/encodec_base_24khz')
# replace this by the desired dataset
launcher.bin... | 31 | 169 | 127 | 296 | # 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 ... | # 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 ... | |
13,698 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/compression/encodec_musicgen_32khz.py | 19,21 | 1,35 | explorer | 21,35 | 21,35 | # 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 ... | # 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 ... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=8, partition=partitions)
# use configuration for MusicGen's EnCodec model trained on monophonic audio sampled at 32 kHz
# MusicGen's EnCodec is trained with a total stride of 640 leading to a frame rate of 5... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=8, partition=partitions)
# use configuration for MusicGen's EnCodec model trained on monophonic audio sampled at 32 kHz
# MusicGen's EnCodec is trained with a total stride of 640 leading to a frame rate of 5... | 62 | 168 | 249 | 417 | # 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 ... | # 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 ... | |
13,699 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/diffusion/4_bands_base_32khz.py | 16,18 | 1,28 | explorer | 18,28 | 18,28 | # 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... | # 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... | launcher.slurm_(gpus=4, partition='learnfair')
launcher.bind_({'solver': 'diffusion/default',
'dset': 'internal/music_10k_32khz'})
with launcher.job_array():
launcher({'filter.use': True, 'filter.idx_band': 0, "processor.use": False, 'processor.power_std': 0.4})
launche... | launcher.slurm_(gpus=4, partition='learnfair')
launcher.bind_({'solver': 'diffusion/default',
'dset': 'internal/music_10k_32khz'})
with launcher.job_array():
launcher({'filter.use': True, 'filter.idx_band': 0, "processor.use": False, 'processor.power_std': 0.4})
launche... | 40 | 134 | 240 | 374 | # 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... | # 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... | |
13,700 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/diffusion/_explorers.py | 18,19 | 12,67 | get_grid_meta | DiffusionExplorer | 21,28 | 19,28 | class DiffusionExplorer(BaseExplorer):
eval_metrics = ["sisnr", "visqol"]
def stages(self):
return ["train", "valid", "valid_ema", "evaluate", "evaluate_ema"]
def get_grid_meta(self):
FILL_FUNC_BODY def get_grid_metrics(self):
"""Return the metrics that should be displayed in the tracki... | class DiffusionExplorer(BaseExplorer):
eval_metrics = ["sisnr", "visqol"]
def stages(self):
return ["train", "valid", "valid_ema", "evaluate", "evaluate_ema"]
def get_grid_meta(self):
"""Returns the list of Meta information to display for each XP/job.
"""
FILL_FUNC_BODY def get_... | return [
tt.leaf("index", align=">"),
tt.leaf("name", wrap=140),
tt.leaf("state"),
tt.leaf("sig", align=">"),
]
| """Returns the list of Meta information to display for each XP/job.
"""
return [
tt.leaf("index", align=">"),
tt.leaf("name", wrap=140),
tt.leaf("state"),
tt.leaf("sig", align=">"),
]
| 10 | 498 | 67 | 565 | # 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... | # 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... |
13,701 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/magnet/audio_magnet_16khz.py | 11,13 | 1,33 | explorer | 13,33 | 13,33 | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='magnet/audio_magnet_16khz')
# replace this by the desired environmental sound dataset
launcher.bind_(dset='internal/sounds_16khz')
fsdp = {'autocast'... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='magnet/audio_magnet_16khz')
# replace this by the desired environmental sound dataset
launcher.bind_(dset='internal/sounds_16khz')
fsdp = {'autocast'... | 50 | 102 | 273 | 375 | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | |
13,702 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/magnet/audio_magnet_pretrained_16khz_eval.py | 46,48 | 1,75 | explorer | 48,75 | 48,75 | # 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 audio-MAGNeT models.
This grid takes signature from the training... | # 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 audio-MAGNeT models.
This grid takes signature from the training... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=4, partition=partitions)
if 'REGEN' not in os.environ:
folder = train.main.dora.dir / 'grids' / __name__.split('.', 2)[-1]
with launcher.job_array():
for sig in folder.iterdir():
... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=4, partition=partitions)
if 'REGEN' not in os.environ:
folder = train.main.dora.dir / 'grids' / __name__.split('.', 2)[-1]
with launcher.job_array():
for sig in folder.iterdir():
... | 70 | 455 | 429 | 884 | # 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 audio-MAGNeT models.
This grid takes signature from the training... | # 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 audio-MAGNeT models.
This grid takes signature from the training... | |
13,703 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/magnet/magnet_32khz.py | 11,13 | 1,48 | explorer | 13,48 | 13,48 | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='magnet/magnet_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': False, 'fsdp.u... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='magnet/magnet_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': False, 'fsdp.u... | 87 | 102 | 464 | 566 | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | # 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 ..musicgen._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplorer
def explorer(... | |
13,704 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/magnet/magnet_pretrained_32khz_eval.py | 26,27 | 1,88 | eval | 27,46 | 27,46 | # 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 MAGNeT models.
This grid takes signature from the training grid ... | # 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 MAGNeT models.
This grid takes signature from the training grid ... | opts = {
'dset': 'audio/musiccaps_32khz',
'solver/musicgen/evaluation': 'objective_eval',
'execute_only': 'evaluate',
'+dataset.evaluate.batch_size': batch_size,
'+metrics.fad.tf.batch_size': 16,
}
# binary for FAD computation: replace this path with your own path
... | opts = {
'dset': 'audio/musiccaps_32khz',
'solver/musicgen/evaluation': 'objective_eval',
'execute_only': 'evaluate',
'+dataset.evaluate.batch_size': batch_size,
'+metrics.fad.tf.batch_size': 16,
}
# binary for FAD computation: replace this path with your own path
... | 41 | 922 | 209 | 1,131 | # 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 MAGNeT models.
This grid takes signature from the training grid ... | # 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 MAGNeT models.
This grid takes signature from the training grid ... | |
13,705 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/_explorers.py | 75,76 | 69,94 | get_grid_metrics | GenerationEvalExplorer | 77,94 | 76,94 | class GenerationEvalExplorer(BaseExplorer):
eval_metrics: tp.List[str] = []
def stages(self) -> tp.List[str]:
return ['evaluate']
def get_grid_metrics(self):
FILL_FUNC_BODY | class GenerationEvalExplorer(BaseExplorer):
eval_metrics: tp.List[str] = []
def stages(self) -> tp.List[str]:
return ['evaluate']
def get_grid_metrics(self):
"""Return the metrics that should be displayed in the tracking table."""
FILL_FUNC_BODY | return [
tt.group(
'evaluate',
[
tt.leaf('epoch', '.3f'),
tt.leaf('duration', '.1f'),
tt.leaf('ping'),
tt.leaf('ce', '.4f'),
tt.leaf('ppl', '.3f'),
... | """Return the metrics that should be displayed in the tracking table."""
return [
tt.group(
'evaluate',
[
tt.leaf('epoch', '.3f'),
tt.leaf('duration', '.1f'),
tt.leaf('ping'),
tt.l... | 26 | 92 | 178 | 270 | # 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):... | # 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):... |
13,706 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/_explorers.py | 45,46 | 14,69 | process_sheep | LMExplorer | 46,69 | 46,69 | class LMExplorer(BaseExplorer):
eval_metrics: tp.List[str] = []
def stages(self) -> tp.List[str]:
return ['train', 'valid']
def get_grid_metrics(self):
"""Return the metrics that should be displayed in the tracking table."""
return [
tt.group(
'train',
... | class LMExplorer(BaseExplorer):
eval_metrics: tp.List[str] = []
def stages(self) -> tp.List[str]:
return ['train', 'valid']
def get_grid_metrics(self):
"""Return the metrics that should be displayed in the tracking table."""
return [
tt.group(
'train',
... | parts = super().process_sheep(sheep, history)
track_by = {'ppl': 'lower'} # values should be in ['lower', 'higher']
best_metrics = {k: (1 if v == 'lower' else -1) * float('inf') for k, v in track_by.items()}
def comparator(mode, a, b):
return a < b if mode == 'lower' else ... | parts = super().process_sheep(sheep, history)
track_by = {'ppl': 'lower'} # values should be in ['lower', 'higher']
best_metrics = {k: (1 if v == 'lower' else -1) * float('inf') for k, v in track_by.items()}
def comparator(mode, a, b):
return a < b if mode == 'lower' else ... | 119 | 285 | 297 | 582 | # 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):... | # 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):... |
13,707 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/musicgen_base_32khz.py | 11,13 | 1,44 | explorer | 13,44 | 13,44 | # 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):... | # 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):... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': False... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': False... | 72 | 99 | 447 | 546 | # 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):... | # 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):... | |
13,708 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/musicgen_base_cached_32khz.py | 11,13 | 1,68 | explorer | 13,68 | 13,68 | # 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):... | # 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):... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': False... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': False... | 148 | 99 | 812 | 911 | # 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):... | # 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):... | |
13,709 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/musicgen_clapemb_32khz.py | 11,13 | 1,33 | explorer | 13,33 | 13,33 | # 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):... | # 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):... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
launcher.bind_(conditioner... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
launcher.bind_(conditioner... | 40 | 99 | 331 | 430 | # 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):... | # 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):... | |
13,710 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/musicgen_melody_32khz.py | 11,13 | 1,66 | explorer | 13,66 | 13,66 | # 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):... | # 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):... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_melody_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': Fal... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_melody_32khz')
# replace this by the desired music dataset
launcher.bind_(dset='internal/music_400k_32khz')
fsdp = {'autocast': Fal... | 134 | 99 | 763 | 862 | # 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):... | # 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):... | |
13,711 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/musicgen_pretrained_32khz_eval.py | 62,64 | 1,100 | explorer | 64,100 | 64,100 | # 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... | # 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... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=4, partition=partitions)
if 'REGEN' not in os.environ:
folder = train.main.dora.dir / 'grids' / __name__.split('.', 2)[-1]
with launcher.job_array():
for sig in folder.iterdir():
... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=4, partition=partitions)
if 'REGEN' not in os.environ:
folder = train.main.dora.dir / 'grids' / __name__.split('.', 2)[-1]
with launcher.job_array():
for sig in folder.iterdir():
... | 89 | 700 | 646 | 1,346 | # 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... | # 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... | |
13,712 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/grids/musicgen/musicgen_stereo_finetune_32khz.py | 12,14 | 1,58 | explorer | 14,58 | 14,58 | # 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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplore... | # 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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplore... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset, which needs to be stereo
launcher.bind_(dset='audio/example')
fsdp = {'au... | partitions = AudioCraftEnvironment.get_slurm_partitions(['team', 'global'])
launcher.slurm_(gpus=32, partition=partitions)
launcher.bind_(solver='musicgen/musicgen_base_32khz')
# replace this by the desired music dataset, which needs to be stereo
launcher.bind_(dset='audio/example')
fsdp = {'au... | 140 | 105 | 710 | 815 | # 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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplore... | # 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 ._explorers import LMExplorer
from ...environment import AudioCraftEnvironment
@LMExplore... | |
13,713 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/balancer.py | 77,78 | 14,137 | backward | Balancer | 89,137 | 78,137 | class Balancer:
"""Loss balancer.
The loss balancer combines losses together to compute gradients for the backward.
Given `y = f(...)`, and a number of losses `l1(y, ...)`, `l2(y, ...)`, with `...`
not having any dependence on `f`, the balancer can efficiently normalize the partial gradients
`d l1 ... | class Balancer:
"""Loss balancer.
The loss balancer combines losses together to compute gradients for the backward.
Given `y = f(...)`, and a number of losses `l1(y, ...)`, `l2(y, ...)`, with `...`
not having any dependence on `f`, the balancer can efficiently normalize the partial gradients
`d l1 ... | norms = {}
grads = {}
for name, loss in losses.items():
# Compute partial derivative of the less with respect to the input.
grad, = autograd.grad(loss, [input], retain_graph=True)
if self.per_batch_item:
# We do not average the gradient over th... | """Compute the backward and return the effective train loss, e.g. the loss obtained from
computing the effective weights. If `balance_grads` is True, the effective weights
are the one that needs to be applied to each gradient to respect the desired relative
scale of gradients coming from... | 252 | 1,163 | 700 | 1,863 | # 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... | # 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... |
13,714 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/specloss.py | 89,90 | 65,96 | forward | MelSpectrogramL1Loss | 90,96 | 90,96 | class MelSpectrogramL1Loss(torch.nn.Module):
"""L1 Loss on MelSpectrogram.
Args:
sample_rate (int): Sample rate.
n_fft (int): Number of fft.
hop_length (int): Hop size.
win_length (int): Window length.
n_mels (int): Number of mel bins.
f_min (float or None): Mini... | class MelSpectrogramL1Loss(torch.nn.Module):
"""L1 Loss on MelSpectrogram.
Args:
sample_rate (int): Sample rate.
n_fft (int): Number of fft.
hop_length (int): Hop size.
win_length (int): Window length.
n_mels (int): Number of mel bins.
f_min (float or None): Mini... | self.melspec.to(x.device)
s_x = self.melspec(x)
s_y = self.melspec(y)
return self.l1(s_x, s_y)
| self.melspec.to(x.device)
s_x = self.melspec(x)
s_y = self.melspec(y)
return self.l1(s_x, s_y)
| 10 | 435 | 66 | 501 | # 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... | # 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... |
13,715 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/specloss.py | 48,49 | 18,65 | forward | MelSpectrogramWrapper | 49,65 | 49,65 | class MelSpectrogramWrapper(nn.Module):
"""Wrapper around MelSpectrogram torchaudio transform providing proper padding
and additional post-processing including log scaling.
Args:
n_mels (int): Number of mel bins.
n_fft (int): Number of fft.
hop_length (int): Hop size.
win_le... | class MelSpectrogramWrapper(nn.Module):
"""Wrapper around MelSpectrogram torchaudio transform providing proper padding
and additional post-processing including log scaling.
Args:
n_mels (int): Number of mel bins.
n_fft (int): Number of fft.
hop_length (int): Hop size.
win_le... | p = int((self.n_fft - self.hop_length) // 2)
if len(x.shape) == 2:
x = x.unsqueeze(1)
x = F.pad(x, (p, p), "reflect")
# Make sure that all the frames are full.
# The combination of `pad_for_conv1d` and the above padding
# will make the output of size ceil(T / ... | p = int((self.n_fft - self.hop_length) // 2)
if len(x.shape) == 2:
x = x.unsqueeze(1)
x = F.pad(x, (p, p), "reflect")
# Make sure that all the frames are full.
# The combination of `pad_for_conv1d` and the above padding
# will make the output of size ceil(T / ... | 76 | 503 | 253 | 756 | # 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... | # 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... |
13,716 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/specloss.py | 137,138 | 96,150 | forward | MultiScaleMelSpectrogramLoss | 138,150 | 138,150 | class MultiScaleMelSpectrogramLoss(nn.Module):
"""Multi-Scale spectrogram loss (msspec).
Args:
sample_rate (int): Sample rate.
range_start (int): Power of 2 to use for the first scale.
range_stop (int): Power of 2 to use for the last scale.
n_mels (int): Number of mel bins.
... | class MultiScaleMelSpectrogramLoss(nn.Module):
"""Multi-Scale spectrogram loss (msspec).
Args:
sample_rate (int): Sample rate.
range_start (int): Power of 2 to use for the first scale.
range_stop (int): Power of 2 to use for the last scale.
n_mels (int): Number of mel bins.
... | loss = 0.0
self.l1s.to(x.device)
self.l2s.to(x.device)
for i in range(len(self.alphas)):
s_x_1 = self.l1s[i](x)
s_y_1 = self.l1s[i](y)
s_x_2 = self.l2s[i](x)
s_y_2 = self.l2s[i](y)
loss += F.l1_loss(s_x_1, s_y_1) + self.alphas[i... | loss = 0.0
self.l1s.to(x.device)
self.l2s.to(x.device)
for i in range(len(self.alphas)):
s_x_1 = self.l1s[i](x)
s_y_1 = self.l1s[i](y)
s_x_2 = self.l2s[i](x)
s_y_2 = self.l2s[i](y)
loss += F.l1_loss(s_x_1, s_y_1) + self.alphas[i... | 39 | 665 | 206 | 871 | # 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... | # 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... |
13,718 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/stftloss.py | 74,75 | 64,86 | forward | LogSTFTMagnitudeLoss | 83,86 | 75,86 | class LogSTFTMagnitudeLoss(nn.Module):
"""Log STFT magnitude loss.
Args:
epsilon (float): Epsilon value for numerical stability.
"""
def __init__(self, epsilon: float = torch.finfo(torch.float32).eps):
super().__init__()
self.epsilon = epsilon
def forward(self, x_mag: torch... | class LogSTFTMagnitudeLoss(nn.Module):
"""Log STFT magnitude loss.
Args:
epsilon (float): Epsilon value for numerical stability.
"""
def __init__(self, epsilon: float = torch.finfo(torch.float32).eps):
super().__init__()
self.epsilon = epsilon
def forward(self, x_mag: torch... | return F.l1_loss(torch.log(self.epsilon + y_mag), torch.log(self.epsilon + x_mag))
| """Calculate forward propagation.
Args:
x_mag (torch.Tensor): Magnitude spectrogram of predicted signal (B, #frames, #freq_bins).
y_mag (torch.Tensor): Magnitude spectrogram of groundtruth signal (B, #frames, #freq_bins).
Returns:
torch.Tensor: Log STFT magni... | 7 | 232 | 41 | 273 | # 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... | # 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... |
13,719 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/stftloss.py | 189,190 | 164,208 | forward | MRSTFTLoss | 198,208 | 190,208 | class MRSTFTLoss(nn.Module):
"""Multi resolution STFT loss.
Args:
n_ffts (Sequence[int]): Sequence of FFT sizes.
hop_lengths (Sequence[int]): Sequence of hop sizes.
win_lengths (Sequence[int]): Sequence of window lengths.
window (str): Window function type.
factor_sc (fl... | class MRSTFTLoss(nn.Module):
"""Multi resolution STFT loss.
Args:
n_ffts (Sequence[int]): Sequence of FFT sizes.
hop_lengths (Sequence[int]): Sequence of hop sizes.
win_lengths (Sequence[int]): Sequence of window lengths.
window (str): Window function type.
factor_sc (fl... | sc_loss = torch.Tensor([0.0])
mag_loss = torch.Tensor([0.0])
for f in self.stft_losses:
sc_l, mag_l = f(x, y)
sc_loss += sc_l
mag_loss += mag_l
sc_loss /= len(self.stft_losses)
mag_loss /= len(self.stft_losses)
return self.factor_sc * ... | """Calculate forward propagation.
Args:
x (torch.Tensor): Predicted signal (B, T).
y (torch.Tensor): Groundtruth signal (B, T).
Returns:
torch.Tensor: Multi resolution STFT loss.
"""
sc_loss = torch.Tensor([0.0])
mag_loss = torch.Tenso... | 35 | 554 | 146 | 700 | # 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... | # 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... |
13,720 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/stftloss.py | 151,152 | 129,164 | forward | STFTLoss | 160,164 | 152,164 | class STFTLoss(nn.Module):
"""Single Resolution STFT loss.
Args:
n_fft (int): Nb of FFT.
hop_length (int): Hop length.
win_length (int): Window length.
window (str): Window function type.
normalized (bool): Whether to use normalized STFT or not.
epsilon (float): ... | class STFTLoss(nn.Module):
"""Single Resolution STFT loss.
Args:
n_fft (int): Nb of FFT.
hop_length (int): Hop length.
win_length (int): Window length.
window (str): Window function type.
normalized (bool): Whether to use normalized STFT or not.
epsilon (float): ... | sc_loss, mag_loss = self.loss(x, y)
return self.factor_sc * sc_loss + self.factor_mag * mag_loss
| """Calculate forward propagation.
Args:
x (torch.Tensor): Predicted signal (B, T).
y (torch.Tensor): Groundtruth signal (B, T).
Returns:
torch.Tensor: Single resolution STFT loss.
"""
sc_loss, mag_loss = self.loss(x, y)
return self.fac... | 13 | 424 | 46 | 470 | # 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... | # 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... |
13,721 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/stftloss.py | 109,110 | 86,129 | forward | STFTLosses | 119,129 | 110,129 | class STFTLosses(nn.Module):
"""STFT losses.
Args:
n_fft (int): Size of FFT.
hop_length (int): Hop length.
win_length (int): Window length.
window (str): Window function type.
normalized (bool): Whether to use normalized STFT or not.
epsilon (float): Epsilon for ... | class STFTLosses(nn.Module):
"""STFT losses.
Args:
n_fft (int): Size of FFT.
hop_length (int): Hop length.
win_length (int): Window length.
window (str): Window function type.
normalized (bool): Whether to use normalized STFT or not.
epsilon (float): Epsilon for ... | x_mag = _stft(x, self.n_fft, self.hop_length,
self.win_length, self.window, self.normalized) # type: ignore
y_mag = _stft(y, self.n_fft, self.hop_length,
self.win_length, self.window, self.normalized) # type: ignore
sc_loss = self.spectral_convergeng... | """Calculate forward propagation.
Args:
x (torch.Tensor): Predicted signal (B, T).
y (torch.Tensor): Groundtruth signal (B, T).
Returns:
torch.Tensor: Spectral convergence loss value.
torch.Tensor: Log STFT magnitude loss value.
"""
... | 33 | 445 | 170 | 615 | # 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... | # 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... |
13,722 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/losses/stftloss.py | 52,53 | 45,64 | forward | SpectralConvergenceLoss | 61,64 | 53,64 | class SpectralConvergenceLoss(nn.Module):
"""Spectral convergence loss.
"""
def __init__(self, epsilon: float = torch.finfo(torch.float32).eps):
super().__init__()
self.epsilon = epsilon
def forward(self, x_mag: torch.Tensor, y_mag: torch.Tensor):
FILL_FUNC_BODY | class SpectralConvergenceLoss(nn.Module):
"""Spectral convergence loss.
"""
def __init__(self, epsilon: float = torch.finfo(torch.float32).eps):
super().__init__()
self.epsilon = epsilon
def forward(self, x_mag: torch.Tensor, y_mag: torch.Tensor):
"""Calculate forward propagatio... | return torch.norm(y_mag - x_mag, p="fro") / (torch.norm(y_mag, p="fro") + self.epsilon)
| """Calculate forward propagation.
Args:
x_mag: Magnitude spectrogram of predicted signal (B, #frames, #freq_bins).
y_mag: Magnitude spectrogram of groundtruth signal (B, #frames, #freq_bins).
Returns:
torch.Tensor: Spectral convergence loss value.
"""... | 10 | 198 | 49 | 247 | # 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... | # 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... |
13,723 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/metrics/rvm.py | 13,14 | 1,111 | db_to_scale | 14,17 | 14,17 | # 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... | # 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... | return 10 ** (volume / 20)
| return 10 ** (volume / 20)
| 6 | 1,803 | 19 | 1,822 | # 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... | # 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... | |
13,724 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/metrics/rvm.py | 84,85 | 22,111 | forward | RelativeVolumeMel | 95,111 | 85,111 | class RelativeVolumeMel(nn.Module):
"""Relative volume melspectrogram measure.
Computes a measure of distance over two mel spectrogram that is interpretable in terms
of decibels. Given `x_ref` and `x_est` two waveforms of shape `[*, T]`, it will
first renormalize both by the ground truth of `x_ref`.
... | class RelativeVolumeMel(nn.Module):
"""Relative volume melspectrogram measure.
Computes a measure of distance over two mel spectrogram that is interpretable in terms
of decibels. Given `x_ref` and `x_est` two waveforms of shape `[*, T]`, it will
first renormalize both by the ground truth of `x_ref`.
... | min_scale = db_to_scale(-self.max_initial_gain)
std = ground_truth.pow(2).mean().sqrt().clamp(min=min_scale)
z_gt = self.melspec(ground_truth / std).sqrt()
z_est = self.melspec(estimate / std).sqrt()
delta = z_gt - z_est
ref_db = scale_to_db(z_gt, self.min_activity_volum... | """Compute RVM metric between estimate and reference samples.
Args:
estimate (torch.Tensor): Estimate sample.
ground_truth (torch.Tensor): Reference sample.
Returns:
dict[str, torch.Tensor]: Metrics with keys `rvm` for the overall average, and `rvm_{k}`
... | 64 | 1,321 | 325 | 1,646 | # 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... | # 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... |
13,725 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/audiogen.py | 39,41 | 23,94 | get_pretrained | AudioGen | 45,63 | 41,63 | class AudioGen(BaseGenModel):
"""AudioGen main model with convenient generation API.
Args:
name (str): name of the model.
compression_model (CompressionModel): Compression model
used to map audio to invertible discrete representations.
lm (LMModel): Language model over discr... | class AudioGen(BaseGenModel):
"""AudioGen main model with convenient generation API.
Args:
name (str): name of the model.
compression_model (CompressionModel): Compression model
used to map audio to invertible discrete representations.
lm (LMModel): Language model over discr... | if device is None:
if torch.cuda.device_count():
device = 'cuda'
else:
device = 'cpu'
if name == 'debug':
# used only for unit tests
compression_model = get_debug_compression_model(device, sample_rate=16000)
lm ... | """Return pretrained model, we provide a single model for now:
- facebook/audiogen-medium (1.5B), text to sound,
# see: https://huggingface.co/facebook/audiogen-medium
"""
if device is None:
if torch.cuda.device_count():
device = 'cuda'
e... | 61 | 812 | 227 | 1,039 | # 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.
"""
Main model for using AudioGen. This will combine all the required components
and provide easy access to the generatio... | # 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.
"""
Main model for using AudioGen. This will combine all the required components
and provide easy access to the generatio... |
13,727 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/encodec.py | 87,91 | 28,125 | get_pretrained | CompressionModel | 104,125 | 91,125 | class CompressionModel(ABC, nn.Module):
"""Base API for all compression models that aim at being used as audio tokenizers
with a language model.
"""
@abstractmethod
def forward(self, x: torch.Tensor) -> qt.QuantizedResult:
...
@abstractmethod
def encode(self, x: torch.Tensor) -> tp... | class CompressionModel(ABC, nn.Module):
"""Base API for all compression models that aim at being used as audio tokenizers
with a language model.
"""
@abstractmethod
def forward(self, x: torch.Tensor) -> qt.QuantizedResult:
...
@abstractmethod
def encode(self, x: torch.Tensor) -> tp... |
from . import builders, loaders
model: CompressionModel
if name in ['dac_44khz', 'dac_24khz']:
model_type = name.split('_')[1]
logger.info("Getting pretrained compression model from DAC %s", model_type)
model = DAC(model_type)
elif name in ['debug_com... | """Instantiate a CompressionModel from a given pretrained model.
Args:
name (Path or str): name of the pretrained model. See after.
device (torch.device or str): Device on which the model is loaded.
Pretrained models:
- dac_44khz (https://github.com/descript... | 85 | 695 | 303 | 998 | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... |
13,728 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/encodec.py | 274,275 | 262,323 | forward | DAC | 275,278 | 275,278 | class DAC(CompressionModel):
def __init__(self, model_type: str = "44khz"):
super().__init__()
try:
import dac.utils
except ImportError:
raise RuntimeError("Could not import dac, make sure it is installed, "
"please run `pip install desc... | class DAC(CompressionModel):
def __init__(self, model_type: str = "44khz"):
super().__init__()
try:
import dac.utils
except ImportError:
raise RuntimeError("Could not import dac, make sure it is installed, "
"please run `pip install desc... | # We don't support training with this.
raise NotImplementedError("Forward and training with DAC not supported.")
| # We don't support training with this.
raise NotImplementedError("Forward and training with DAC not supported.")
| 15 | 605 | 35 | 640 | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... |
13,729 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/encodec.py | 206,207 | 125,262 | forward | EncodecModel | 207,223 | 207,223 | class EncodecModel(CompressionModel):
"""Encodec model operating on the raw waveform.
Args:
encoder (nn.Module): Encoder network.
decoder (nn.Module): Decoder network.
quantizer (qt.BaseQuantizer): Quantizer network.
frame_rate (int): Frame rate for the latent representation.
... | class EncodecModel(CompressionModel):
"""Encodec model operating on the raw waveform.
Args:
encoder (nn.Module): Encoder network.
decoder (nn.Module): Decoder network.
quantizer (qt.BaseQuantizer): Quantizer network.
frame_rate (int): Frame rate for the latent representation.
... | assert x.dim() == 3
length = x.shape[-1]
x, scale = self.preprocess(x)
emb = self.encoder(x)
q_res = self.quantizer(emb, self.frame_rate)
out = self.decoder(q_res.x)
# remove extra padding added by the encoder and decoder
assert out.shape[-1] >= length, ... | assert x.dim() == 3
length = x.shape[-1]
x, scale = self.preprocess(x)
emb = self.encoder(x)
q_res = self.quantizer(emb, self.frame_rate)
out = self.decoder(q_res.x)
# remove extra padding added by the encoder and decoder
assert out.shape[-1] >= length, ... | 47 | 1,330 | 166 | 1,496 | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... |
13,730 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/encodec.py | 344,345 | 323,397 | encode | HFEncodecCompressionModel | 345,352 | 345,352 | class HFEncodecCompressionModel(CompressionModel):
"""Wrapper around HuggingFace Encodec.
"""
def __init__(self, model: HFEncodecModel):
super().__init__()
self.model = model
bws = self.model.config.target_bandwidths
num_codebooks = [
bw * 1000 / (self.frame_rate ... | class HFEncodecCompressionModel(CompressionModel):
"""Wrapper around HuggingFace Encodec.
"""
def __init__(self, model: HFEncodecModel):
super().__init__()
self.model = model
bws = self.model.config.target_bandwidths
num_codebooks = [
bw * 1000 / (self.frame_rate ... | bandwidth_index = self.possible_num_codebooks.index(self.num_codebooks)
bandwidth = self.model.config.target_bandwidths[bandwidth_index]
res = self.model.encode(x, None, bandwidth)
assert len(res[0]) == 1
assert len(res[1]) == 1
return res[0][0], res[1][0]
| bandwidth_index = self.possible_num_codebooks.index(self.num_codebooks)
bandwidth = self.model.config.target_bandwidths[bandwidth_index]
res = self.model.encode(x, None, bandwidth)
assert len(res[0]) == 1
assert len(res[1]) == 1
return res[0][0], res[1][0]
| 22 | 787 | 106 | 893 | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... |
13,731 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/encodec.py | 463,464 | 397,507 | encode | InterleaveStereoCompressionModel | 464,481 | 464,481 | class InterleaveStereoCompressionModel(CompressionModel):
"""Wraps a CompressionModel to support stereo inputs. The wrapped model
will be applied independently to the left and right channels, and both codebooks
will be interleaved. If the wrapped model returns a representation `[B, K ,T]` per
channel, t... | class InterleaveStereoCompressionModel(CompressionModel):
"""Wraps a CompressionModel to support stereo inputs. The wrapped model
will be applied independently to the left and right channels, and both codebooks
will be interleaved. If the wrapped model returns a representation `[B, K ,T]` per
channel, t... | B, C, T = x.shape
assert C == self.channels, f"Expecting stereo audio but audio num channels is {C}"
indices_c0, scales_c0 = self.model.encode(x[:, 0, ...].unsqueeze(1))
indices_c1, scales_c1 = self.model.encode(x[:, 1, ...].unsqueeze(1))
indices = torch.stack([indices_c0, indic... | B, C, T = x.shape
assert C == self.channels, f"Expecting stereo audio but audio num channels is {C}"
indices_c0, scales_c0 = self.model.encode(x[:, 0, ...].unsqueeze(1))
indices_c1, scales_c1 = self.model.encode(x[:, 1, ...].unsqueeze(1))
indices = torch.stack([indices_c0, indic... | 86 | 1,178 | 290 | 1,468 | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... | # 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.
"""Compression models or wrapper around existing models.
Also defines the main interface that a model must follow to be us... |
13,735 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/lm.py | 104,105 | 97,111 | make_optim_group | ScaledEmbedding | 105,111 | 105,111 | class ScaledEmbedding(nn.Embedding):
"""Boost learning rate for embeddings (with `scale`).
"""
def __init__(self, *args, lr=None, **kwargs):
super().__init__(*args, **kwargs)
self.lr = lr
def make_optim_group(self):
FILL_FUNC_BODY | class ScaledEmbedding(nn.Embedding):
"""Boost learning rate for embeddings (with `scale`).
"""
def __init__(self, *args, lr=None, **kwargs):
super().__init__(*args, **kwargs)
self.lr = lr
def make_optim_group(self):
FILL_FUNC_BODY | group = {"params": list(self.parameters())}
if self.lr is not None:
group["lr"] = self.lr
return group
| group = {"params": list(self.parameters())}
if self.lr is not None:
group["lr"] = self.lr
return group
| 14 | 96 | 49 | 145 | # 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 dataclasses import dataclass
from functools import partial
import logging
import math
import typing as tp
import to... | # 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 dataclasses import dataclass
from functools import partial
import logging
import math
import typing as tp
import to... |
13,737 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/magnet.py | 60,65 | 18,89 | set_generation_params | MAGNeT | 79,89 | 65,89 | class MAGNeT(BaseGenModel):
"""MAGNeT main model with convenient generation API.
Args:
See MusicGen class.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
# MAGNeT operates over a fixed sequence length defined in it's config.
self.duration = self.lm.cfg.datase... | class MAGNeT(BaseGenModel):
"""MAGNeT main model with convenient generation API.
Args:
See MusicGen class.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
# MAGNeT operates over a fixed sequence length defined in it's config.
self.duration = self.lm.cfg.datase... | self.generation_params = {
'use_sampling': use_sampling,
'temp': temperature,
'top_k': top_k,
'top_p': top_p,
'max_cfg_coef': max_cfg_coef,
'min_cfg_coef': min_cfg_coef,
'decoding_steps': [int(s) for s in decoding_steps],
... | """Set the generation parameters for MAGNeT.
Args:
use_sampling (bool, optional): Use sampling if True, else do argmax decoding. Defaults to True.
top_k (int, optional): top_k used for sampling. Defaults to 0.
top_p (float, optional): top_p used for sampling, when se... | 24 | 1,098 | 134 | 1,232 | # 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.
"""
Main model for using MAGNeT. This will combine all the required components
and provide easy access to the generation ... | # 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.
"""
Main model for using MAGNeT. This will combine all the required components
and provide easy access to the generation ... |
13,738 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/multibanddiffusion.py | 36,38 | 25,48 | generate | DiffusionProcess | 44,48 | 38,48 | class DiffusionProcess:
"""Sampling for a diffusion Model.
Args:
model (DiffusionUnet): Diffusion U-Net model.
noise_schedule (NoiseSchedule): Noise schedule for diffusion process.
"""
def __init__(self, model: DiffusionUnet, noise_schedule: NoiseSchedule) -> None:
self.model = ... | class DiffusionProcess:
"""Sampling for a diffusion Model.
Args:
model (DiffusionUnet): Diffusion U-Net model.
noise_schedule (NoiseSchedule): Noise schedule for diffusion process.
"""
def __init__(self, model: DiffusionUnet, noise_schedule: NoiseSchedule) -> None:
self.model = ... | return self.schedule.generate_subsampled(model=self.model, initial=initial_noise, step_list=step_list,
condition=condition)
| """Perform one diffusion process to generate one of the bands.
Args:
condition (torch.Tensor): The embeddings from the compression model.
initial_noise (torch.Tensor): The initial noise to start the process.
"""
return self.schedule.generate_subsampled(model=self... | 5 | 225 | 47 | 272 | # 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.
"""
Multi Band Diffusion models as described in
"From Discrete Tokens to High-Fidelity Audio Using Multi-Band Diffusion"
... | # 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.
"""
Multi Band Diffusion models as described in
"From Discrete Tokens to High-Fidelity Audio Using Multi-Band Diffusion"
... |
13,742 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/unet.py | 115,116 | 107,123 | forward | BLSTM | 116,123 | 116,123 | class BLSTM(nn.Module):
"""BiLSTM with same hidden units as input dim.
"""
def __init__(self, dim, layers=2):
super().__init__()
self.lstm = nn.LSTM(bidirectional=True, num_layers=layers, hidden_size=dim, input_size=dim)
self.linear = nn.Linear(2 * dim, dim)
def forward(self, x)... | class BLSTM(nn.Module):
"""BiLSTM with same hidden units as input dim.
"""
def __init__(self, dim, layers=2):
super().__init__()
self.lstm = nn.LSTM(bidirectional=True, num_layers=layers, hidden_size=dim, input_size=dim)
self.linear = nn.Linear(2 * dim, dim)
def forward(self, x)... | x = x.permute(2, 0, 1)
x = self.lstm(x)[0]
x = self.linear(x)
x = x.permute(1, 2, 0)
return x
| x = x.permute(2, 0, 1)
x = self.lstm(x)[0]
x = self.linear(x)
x = x.permute(1, 2, 0)
return x
| 18 | 123 | 73 | 196 | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... |
13,743 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/unet.py | 72,73 | 58,80 | forward | DecoderLayer | 73,80 | 73,80 | class DecoderLayer(nn.Module):
def __init__(self, chin: int, chout: int, kernel: int = 4, stride: int = 2,
norm_groups: int = 4, res_blocks: int = 1, activation: tp.Type[nn.Module] = nn.ReLU,
dropout: float = 0.):
super().__init__()
padding = (kernel - stride) // 2
... | class DecoderLayer(nn.Module):
def __init__(self, chin: int, chout: int, kernel: int = 4, stride: int = 2,
norm_groups: int = 4, res_blocks: int = 1, activation: tp.Type[nn.Module] = nn.ReLU,
dropout: float = 0.):
super().__init__()
padding = (kernel - stride) // 2
... | x = self.res_blocks(x)
x = self.norm(x)
x = self.activation(x)
x = self.convtr(x)
return x
| x = self.res_blocks(x)
x = self.norm(x)
x = self.activation(x)
x = self.convtr(x)
return x
| 14 | 272 | 57 | 329 | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... |
13,744 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/unet.py | 163,164 | 123,215 | forward | DiffusionUnet | 164,215 | 164,215 | class DiffusionUnet(nn.Module):
def __init__(self, chin: int = 3, hidden: int = 24, depth: int = 3, growth: float = 2.,
max_channels: int = 10_000, num_steps: int = 1000, emb_all_layers=False, cross_attention: bool = False,
bilstm: bool = False, transformer: bool = False,
... | class DiffusionUnet(nn.Module):
def __init__(self, chin: int = 3, hidden: int = 24, depth: int = 3, growth: float = 2.,
max_channels: int = 10_000, num_steps: int = 1000, emb_all_layers=False, cross_attention: bool = False,
bilstm: bool = False, transformer: bool = False,
... | skips = []
bs = x.size(0)
z = x
view_args = [1]
if type(step) is torch.Tensor:
step_tensor = step
else:
step_tensor = torch.tensor([step], device=x.device, dtype=torch.long).expand(bs)
for idx, encoder in enumerate(self.encoders):
... | skips = []
bs = x.size(0)
z = x
view_args = [1]
if type(step) is torch.Tensor:
step_tensor = step
else:
step_tensor = torch.tensor([step], device=x.device, dtype=torch.long).expand(bs)
for idx, encoder in enumerate(self.encoders):
... | 203 | 624 | 770 | 1,394 | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... |
13,745 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/unet.py | 94,95 | 80,107 | forward | EncoderLayer | 95,107 | 95,107 | class EncoderLayer(nn.Module):
def __init__(self, chin: int, chout: int, kernel: int = 4, stride: int = 2,
norm_groups: int = 4, res_blocks: int = 1, activation: tp.Type[nn.Module] = nn.ReLU,
dropout: float = 0.):
super().__init__()
padding = (kernel - stride) // 2
... | class EncoderLayer(nn.Module):
def __init__(self, chin: int, chout: int, kernel: int = 4, stride: int = 2,
norm_groups: int = 4, res_blocks: int = 1, activation: tp.Type[nn.Module] = nn.ReLU,
dropout: float = 0.):
super().__init__()
padding = (kernel - stride) // 2
... | B, C, T = x.shape
stride, = self.conv.stride
pad = (stride - (T % stride)) % stride
x = F.pad(x, (0, pad))
x = self.conv(x)
x = self.norm(x)
x = self.activation(x)
x = self.res_blocks(x)
return x
| B, C, T = x.shape
stride, = self.conv.stride
pad = (stride - (T % stride)) % stride
x = F.pad(x, (0, pad))
x = self.conv(x)
x = self.norm(x)
x = self.activation(x)
x = self.res_blocks(x)
return x
| 36 | 267 | 117 | 384 | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... |
13,746 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/models/unet.py | 52,53 | 33,58 | forward | ResBlock | 53,58 | 53,58 | class ResBlock(nn.Module):
def __init__(self, channels: int, kernel: int = 3, norm_groups: int = 4,
dilation: int = 1, activation: tp.Type[nn.Module] = nn.ReLU,
dropout: float = 0.):
super().__init__()
stride = 1
padding = dilation * (kernel - stride) // 2
... | class ResBlock(nn.Module):
def __init__(self, channels: int, kernel: int = 3, norm_groups: int = 4,
dilation: int = 1, activation: tp.Type[nn.Module] = nn.ReLU,
dropout: float = 0.):
super().__init__()
stride = 1
padding = dilation * (kernel - stride) // 2
... | h = self.dropout1(self.conv1(self.activation1(self.norm1(x))))
h = self.dropout2(self.conv2(self.activation2(self.norm2(h))))
return x + h
| h = self.dropout1(self.conv1(self.activation1(self.norm1(x))))
h = self.dropout2(self.conv2(self.activation2(self.norm2(h))))
return x + h
| 10 | 287 | 71 | 358 | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... | # 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.
"""
Pytorch Unet Module used for diffusion.
"""
from dataclasses import dataclass
import typing as tp
import torch
from... |
13,747 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/activations.py | 80,83 | 1,97 | get_activation_fn | 89,97 | 83,97 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch import Tensor
from typing import Union, Callable
class CustomGLU(nn.Modul... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch import Tensor
from typing import Union, Callable
class CustomGLU(nn.Modul... | if isinstance(activation, str):
if activation == "reglu":
return ReGLU()
elif activation == "geglu":
return GeGLU()
elif activation == "swiglu":
return SwiGLU()
return activation
| """Helper function to map an activation string to the activation class.
If the supplied activation is not a string that is recognized, the activation is passed back.
Args:
activation (str, or Callable[[Tensor], Tensor]): Activation to check
"""
if isinstance(activation, str):
if act... | 23 | 1,025 | 74 | 1,099 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch import Tensor
from typing import Union, Callable
class CustomGLU(nn.Modul... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch import Tensor
from typing import Union, Callable
class CustomGLU(nn.Modul... | |
13,748 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/activations.py | 38,39 | 13,44 | forward | CustomGLU | 39,44 | 39,44 | class CustomGLU(nn.Module):
"""Custom Gated Linear Unit activation.
Applies a modified gated linear unit :math:`a * f(b)` where :math:`a` is the first half
of the input matrices, :math:`b` is the second half, and :math:`f` is a provided activation
function (i.e. sigmoid, swish, etc.).
Args:
... | class CustomGLU(nn.Module):
"""Custom Gated Linear Unit activation.
Applies a modified gated linear unit :math:`a * f(b)` where :math:`a` is the first half
of the input matrices, :math:`b` is the second half, and :math:`f` is a provided activation
function (i.e. sigmoid, swish, etc.).
Args:
... | assert x.shape[self.dim] % 2 == 0 # M = N / 2
a, b = torch.chunk(x, 2, dim=self.dim)
return a * self.activation(b)
| assert x.shape[self.dim] % 2 == 0 # M = N / 2
a, b = torch.chunk(x, 2, dim=self.dim)
return a * self.activation(b)
| 22 | 340 | 66 | 406 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch import Tensor
from typing import Union, Callable
class CustomGLU(nn.Modul... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch import Tensor
from typing import Union, Callable
class CustomGLU(nn.Modul... |
13,749 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/chroma.py | 46,47 | 16,67 | forward | ChromaExtractor | 47,67 | 47,67 | class ChromaExtractor(nn.Module):
"""Chroma extraction and quantization.
Args:
sample_rate (int): Sample rate for the chroma extraction.
n_chroma (int): Number of chroma bins for the chroma extraction.
radix2_exp (int): Size of stft window for the chroma extraction (power of 2, e.g. 12 ... | class ChromaExtractor(nn.Module):
"""Chroma extraction and quantization.
Args:
sample_rate (int): Sample rate for the chroma extraction.
n_chroma (int): Number of chroma bins for the chroma extraction.
radix2_exp (int): Size of stft window for the chroma extraction (power of 2, e.g. 12 ... | T = wav.shape[-1]
# in case we are getting a wav that was dropped out (nullified)
# from the conditioner, make sure wav length is no less that nfft
if T < self.nfft:
pad = self.nfft - T
r = 0 if pad % 2 == 0 else 1
wav = F.pad(wav, (pad // 2, pad // 2 ... | T = wav.shape[-1]
# in case we are getting a wav that was dropped out (nullified)
# from the conditioner, make sure wav length is no less that nfft
if T < self.nfft:
pad = self.nfft - T
r = 0 if pad % 2 == 0 else 1
wav = F.pad(wav, (pad // 2, pad // 2 ... | 110 | 560 | 370 | 930 | # 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 einops import rearrange
from librosa import filters
import torch
from torch import nn
import tor... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import typing as tp
from einops import rearrange
from librosa import filters
import torch
from torch import nn
import tor... |
13,751 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/conv.py | 111,112 | 100,117 | forward | NormConv1d | 112,117 | 112,117 | class NormConv1d(nn.Module):
"""Wrapper around Conv1d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, causal: bool = False, norm: str = 'none',
norm_kwargs: tp.Dict[str, tp.Any] = {}, **kwargs):
... | class NormConv1d(nn.Module):
"""Wrapper around Conv1d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, causal: bool = False, norm: str = 'none',
norm_kwargs: tp.Dict[str, tp.Any] = {}, **kwargs):
... | x = self.conv(x)
x = self.norm(x)
return x
| x = self.conv(x)
x = self.norm(x)
return x
| 8 | 182 | 31 | 213 | # 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 warnings
import torch
from torch import nn
from torch.nn import functional as F
f... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import typing as tp
import warnings
import torch
from torch import nn
from torch.nn import functional as F
f... |
13,752 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/conv.py | 127,128 | 117,133 | forward | NormConv2d | 128,133 | 128,133 | class NormConv2d(nn.Module):
"""Wrapper around Conv2d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, norm: str = 'none', norm_kwargs: tp.Dict[str, tp.Any] = {}, **kwargs):
super().__init__()
self.conv =... | class NormConv2d(nn.Module):
"""Wrapper around Conv2d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, norm: str = 'none', norm_kwargs: tp.Dict[str, tp.Any] = {}, **kwargs):
super().__init__()
self.conv =... | x = self.conv(x)
x = self.norm(x)
return x
| x = self.conv(x)
x = self.norm(x)
return x
| 8 | 177 | 31 | 208 | # 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 warnings
import torch
from torch import nn
from torch.nn import functional as F
f... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import typing as tp
import warnings
import torch
from torch import nn
from torch.nn import functional as F
f... |
13,753 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/conv.py | 144,145 | 133,150 | forward | NormConvTranspose1d | 145,150 | 145,150 | class NormConvTranspose1d(nn.Module):
"""Wrapper around ConvTranspose1d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, causal: bool = False, norm: str = 'none',
norm_kwargs: tp.Dict[str, tp.Any] = {}, ... | class NormConvTranspose1d(nn.Module):
"""Wrapper around ConvTranspose1d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, causal: bool = False, norm: str = 'none',
norm_kwargs: tp.Dict[str, tp.Any] = {}, ... | x = self.convtr(x)
x = self.norm(x)
return x
| x = self.convtr(x)
x = self.norm(x)
return x
| 8 | 190 | 32 | 222 | # 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 warnings
import torch
from torch import nn
from torch.nn import functional as F
f... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import typing as tp
import warnings
import torch
from torch import nn
from torch.nn import functional as F
f... |
13,754 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/conv.py | 159,160 | 150,165 | forward | NormConvTranspose2d | 160,165 | 160,165 | class NormConvTranspose2d(nn.Module):
"""Wrapper around ConvTranspose2d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, norm: str = 'none', norm_kwargs: tp.Dict[str, tp.Any] = {}, **kwargs):
super().__init__()
... | class NormConvTranspose2d(nn.Module):
"""Wrapper around ConvTranspose2d and normalization applied to this conv
to provide a uniform interface across normalization approaches.
"""
def __init__(self, *args, norm: str = 'none', norm_kwargs: tp.Dict[str, tp.Any] = {}, **kwargs):
super().__init__()
... | x = self.convtr(x)
x = self.norm(x)
return x
| x = self.convtr(x)
x = self.norm(x)
return x
| 8 | 176 | 32 | 208 | # 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 warnings
import torch
from torch import nn
from torch.nn import functional as F
f... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import typing as tp
import warnings
import torch
from torch import nn
from torch.nn import functional as F
f... |
13,755 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/conv.py | 185,186 | 165,204 | forward | StreamableConv1d | 186,204 | 186,204 | class StreamableConv1d(nn.Module):
"""Conv1d with some builtin handling of asymmetric or causal padding
and normalization.
"""
def __init__(self, in_channels: int, out_channels: int,
kernel_size: int, stride: int = 1, dilation: int = 1,
groups: int = 1, bias: bool = Tru... | class StreamableConv1d(nn.Module):
"""Conv1d with some builtin handling of asymmetric or causal padding
and normalization.
"""
def __init__(self, in_channels: int, out_channels: int,
kernel_size: int, stride: int = 1, dilation: int = 1,
groups: int = 1, bias: bool = Tru... | B, C, T = x.shape
kernel_size = self.conv.conv.kernel_size[0]
stride = self.conv.conv.stride[0]
dilation = self.conv.conv.dilation[0]
kernel_size = (kernel_size - 1) * dilation + 1 # effective kernel size with dilations
padding_total = kernel_size - stride
extra_... | B, C, T = x.shape
kernel_size = self.conv.conv.kernel_size[0]
stride = self.conv.conv.stride[0]
dilation = self.conv.conv.dilation[0]
kernel_size = (kernel_size - 1) * dilation + 1 # effective kernel size with dilations
padding_total = kernel_size - stride
extra_... | 81 | 343 | 275 | 618 | # 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 warnings
import torch
from torch import nn
from torch.nn import functional as F
f... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import typing as tp
import warnings
import torch
from torch import nn
from torch.nn import functional as F
f... |
13,756 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/conv.py | 221,222 | 204,244 | forward | StreamableConvTranspose1d | 222,244 | 222,244 | class StreamableConvTranspose1d(nn.Module):
"""ConvTranspose1d with some builtin handling of asymmetric or causal padding
and normalization.
"""
def __init__(self, in_channels: int, out_channels: int,
kernel_size: int, stride: int = 1, causal: bool = False,
norm: str = ... | class StreamableConvTranspose1d(nn.Module):
"""ConvTranspose1d with some builtin handling of asymmetric or causal padding
and normalization.
"""
def __init__(self, in_channels: int, out_channels: int,
kernel_size: int, stride: int = 1, causal: bool = False,
norm: str = ... | kernel_size = self.convtr.convtr.kernel_size[0]
stride = self.convtr.convtr.stride[0]
padding_total = kernel_size - stride
y = self.convtr(x)
# We will only trim fixed padding. Extra padding from `pad_for_conv1d` would be
# removed at the very end, when keeping only the... | kernel_size = self.convtr.convtr.kernel_size[0]
stride = self.convtr.convtr.stride[0]
padding_total = kernel_size - stride
y = self.convtr(x)
# We will only trim fixed padding. Extra padding from `pad_for_conv1d` would be
# removed at the very end, when keeping only the... | 124 | 305 | 313 | 618 | # 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 warnings
import torch
from torch import nn
from torch.nn import functional as F
f... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import typing as tp
import warnings
import torch
from torch import nn
from torch.nn import functional as F
f... |
13,758 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/diffusion_schedule.py | 104,105 | 35,112 | return_sample | MultiBandProcessor | 105,112 | 105,112 | class MultiBandProcessor(SampleProcessor):
"""
MultiBand sample processor. The input audio is splitted across
frequency bands evenly distributed in mel-scale.
Each band will be rescaled to match the power distribution
of Gaussian noise in that band, using online metrics
computed on the first fe... | class MultiBandProcessor(SampleProcessor):
"""
MultiBand sample processor. The input audio is splitted across
frequency bands evenly distributed in mel-scale.
Each band will be rescaled to match the power distribution
of Gaussian noise in that band, using online metrics
computed on the first fe... | assert x.dim() == 3
bands = self.split_bands(x)
rescale = (self.std / self.target_std) ** self.power_std
bands = bands * rescale.view(-1, 1, 1, 1) + self.mean.view(-1, 1, 1, 1)
return bands.sum(dim=0)
| assert x.dim() == 3
bands = self.split_bands(x)
rescale = (self.std / self.target_std) ** self.power_std
bands = bands * rescale.view(-1, 1, 1, 1) + self.mean.view(-1, 1, 1, 1)
return bands.sum(dim=0)
| 29 | 1,000 | 103 | 1,103 | # 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.
"""
Functions for Noise Schedule, defines diffusion process, reverse process and data processor.
"""
from collections im... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""
Functions for Noise Schedule, defines diffusion process, reverse process and data processor.
"""
from collections im... |
13,760 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/diffusion_schedule.py | 30,31 | 25,35 | return_sample | SampleProcessor | 32,35 | 31,35 | class SampleProcessor(torch.nn.Module):
def project_sample(self, x: torch.Tensor):
"""Project the original sample to the 'space' where the diffusion will happen."""
return x
def return_sample(self, z: torch.Tensor):
FILL_FUNC_BODY | class SampleProcessor(torch.nn.Module):
def project_sample(self, x: torch.Tensor):
"""Project the original sample to the 'space' where the diffusion will happen."""
return x
def return_sample(self, z: torch.Tensor):
"""Project back from diffusion space to the actual sample space."""
FIL... | return z
| """Project back from diffusion space to the actual sample space."""
return z
| 2 | 93 | 9 | 102 | # 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.
"""
Functions for Noise Schedule, defines diffusion process, reverse process and data processor.
"""
from collections im... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""
Functions for Noise Schedule, defines diffusion process, reverse process and data processor.
"""
from collections im... |
13,761 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/lstm.py | 19,20 | 10,26 | forward | StreamableLSTM | 20,26 | 20,26 | class StreamableLSTM(nn.Module):
"""LSTM without worrying about the hidden state, nor the layout of the data.
Expects input as convolutional layout.
"""
def __init__(self, dimension: int, num_layers: int = 2, skip: bool = True):
super().__init__()
self.skip = skip
self.lstm = nn.... | class StreamableLSTM(nn.Module):
"""LSTM without worrying about the hidden state, nor the layout of the data.
Expects input as convolutional layout.
"""
def __init__(self, dimension: int, num_layers: int = 2, skip: bool = True):
super().__init__()
self.skip = skip
self.lstm = nn.... | x = x.permute(2, 0, 1)
y, _ = self.lstm(x)
if self.skip:
y = y + x
y = y.permute(1, 2, 0)
return y
| x = x.permute(2, 0, 1)
y, _ = self.lstm(x)
if self.skip:
y = y + x
y = y.permute(1, 2, 0)
return y
| 23 | 129 | 74 | 203 | # 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 import nn
class StreamableLSTM(nn.Module):
"""LSTM without worrying about the hidden state, nor the layo... | # 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 import nn
class StreamableLSTM(nn.Module):
"""LSTM without worrying about the hidden state, nor the layo... |
13,762 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/rope.py | 84,85 | 49,126 | rotate | RotaryEmbedding | 86,106 | 85,106 | class RotaryEmbedding(nn.Module):
"""Rotary positional embedding (RoPE) from [Su et al 2022](https://arxiv.org/abs/2104.09864).
Args:
dim (int): Embedding dimension (twice the number of frequencies).
max_period (float): Maximum period of the rotation frequencies.
xpos (bool): Use xPos, ... | class RotaryEmbedding(nn.Module):
"""Rotary positional embedding (RoPE) from [Su et al 2022](https://arxiv.org/abs/2104.09864).
Args:
dim (int): Embedding dimension (twice the number of frequencies).
max_period (float): Maximum period of the rotation frequencies.
xpos (bool): Use xPos, ... | T = x.shape[time_dim]
target_shape = [1] * x.dim()
target_shape[time_dim] = T
target_shape[-1] = -1
rotation = self.get_rotation(start, start + T).view(target_shape)
if self.xpos:
decay = self.xpos.get_decay(start, start + T).view(target_shape)
else:
... | """Apply rope rotation to query or key tensor."""
T = x.shape[time_dim]
target_shape = [1] * x.dim()
target_shape[time_dim] = T
target_shape[-1] = -1
rotation = self.get_rotation(start, start + T).view(target_shape)
if self.xpos:
decay = self.xpos.get... | 62 | 930 | 268 | 1,198 | # 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 import nn
import torch
class XPos(nn.Module):
"""Length-extrapolatable positional e... | # 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 import nn
import torch
class XPos(nn.Module):
"""Length-extrapolatable positional e... |
13,763 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/rope.py | 38,39 | 13,49 | get_decay | XPos | 40,49 | 39,49 | class XPos(nn.Module):
"""Length-extrapolatable positional embedding (xPos) from [Sun et al 2022](https://arxiv.org/abs/2212.10554v1).
This applies an exponential decay to the RoPE rotation matrix.
Args:
dim (int): Embedding dimension.
smoothing (float): Smoothing factor applied to the deca... | class XPos(nn.Module):
"""Length-extrapolatable positional embedding (xPos) from [Sun et al 2022](https://arxiv.org/abs/2212.10554v1).
This applies an exponential decay to the RoPE rotation matrix.
Args:
dim (int): Embedding dimension.
smoothing (float): Smoothing factor applied to the deca... | if self.decay is None or end > self.decay.shape[0]:
assert isinstance(self.decay_rates, torch.Tensor) # Satisfy type checker.
idx = torch.arange(end, device=self.decay_rates.device, dtype=self.dtype)
power = idx / self.base_scale
scale = self.decay_rates ** power... | """Create complex decay tensor, cache values for fast computation."""
if self.decay is None or end > self.decay.shape[0]:
assert isinstance(self.decay_rates, torch.Tensor) # Satisfy type checker.
idx = torch.arange(end, device=self.decay_rates.device, dtype=self.dtype)
... | 39 | 420 | 168 | 588 | # 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 import nn
import torch
class XPos(nn.Module):
"""Length-extrapolatable positional e... | # 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 import nn
import torch
class XPos(nn.Module):
"""Length-extrapolatable positional e... |
13,764 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/seanet.py | 256,257 | 156,259 | forward | SEANetDecoder | 257,259 | 257,259 | class SEANetDecoder(nn.Module):
"""SEANet decoder.
Args:
channels (int): Audio channels.
dimension (int): Intermediate representation dimension.
n_filters (int): Base width for the model.
n_residual_layers (int): nb of residual layers.
ratios (Sequence[int]): kernel size... | class SEANetDecoder(nn.Module):
"""SEANet decoder.
Args:
channels (int): Audio channels.
dimension (int): Intermediate representation dimension.
n_filters (int): Base width for the model.
n_residual_layers (int): nb of residual layers.
ratios (Sequence[int]): kernel size... | y = self.model(z)
return y
| y = self.model(z)
return y
| 5 | 1,594 | 16 | 1,610 | # 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.nn as nn
from .conv import StreamableConv1d, StreamableConvTranspos... | # 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.nn as nn
from .conv import StreamableConv1d, StreamableConvTranspos... |
13,765 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/seanet.py | 152,153 | 63,156 | forward | SEANetEncoder | 153,156 | 153,156 | class SEANetEncoder(nn.Module):
"""SEANet encoder.
Args:
channels (int): Audio channels.
dimension (int): Intermediate representation dimension.
n_filters (int): Base width for the model.
n_residual_layers (int): nb of residual layers.
ratios (Sequence[int]): kernel size... | class SEANetEncoder(nn.Module):
"""SEANet encoder.
Args:
channels (int): Audio channels.
dimension (int): Intermediate representation dimension.
n_filters (int): Base width for the model.
n_residual_layers (int): nb of residual layers.
ratios (Sequence[int]): kernel size... | return self.model(x)
| return self.model(x)
| 2 | 1,406 | 14 | 1,420 | # 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.nn as nn
from .conv import StreamableConv1d, StreamableConvTranspos... | # 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.nn as nn
from .conv import StreamableConv1d, StreamableConvTranspos... |
13,766 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/seanet.py | 59,60 | 16,63 | forward | SEANetResnetBlock | 60,63 | 60,63 | class SEANetResnetBlock(nn.Module):
"""Residual block from SEANet model.
Args:
dim (int): Dimension of the input/output.
kernel_sizes (list): List of kernel sizes for the convolutions.
dilations (list): List of dilations for the convolutions.
activation (str): Activation functio... | class SEANetResnetBlock(nn.Module):
"""Residual block from SEANet model.
Args:
dim (int): Dimension of the input/output.
kernel_sizes (list): List of kernel sizes for the convolutions.
dilations (list): List of dilations for the convolutions.
activation (str): Activation functio... | return self.shortcut(x) + self.block(x)
| return self.shortcut(x) + self.block(x)
| 4 | 686 | 22 | 708 | # 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.nn as nn
from .conv import StreamableConv1d, StreamableConvTranspos... | # 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.nn as nn
from .conv import StreamableConv1d, StreamableConvTranspos... |
13,767 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/streaming.py | 88,89 | 20,122 | set_streaming_state | StreamingModule | 90,107 | 89,107 | class StreamingModule(nn.Module):
"""Common API for streaming components.
Each streaming component has a streaming state, which is just a dict[str, Tensor].
By convention, the first dim of each tensor must be the batch size.
Don't use dots in the key names, as this would clash with submodules
(like... | class StreamingModule(nn.Module):
"""Common API for streaming components.
Each streaming component has a streaming state, which is just a dict[str, Tensor].
By convention, the first dim of each tensor must be the batch size.
Don't use dots in the key names, as this would clash with submodules
(like... | state = dict(state)
def _set(name: str, module: StreamingModule):
if name:
name += "."
module._streaming_state.clear()
for key, value in list(state.items()):
# complexity is not ideal here, but probably fine.
if key.sta... | """Set the streaming state, including that of sub-modules."""
state = dict(state)
def _set(name: str, module: StreamingModule):
if name:
name += "."
module._streaming_state.clear()
for key, value in list(state.items()):
# compl... | 49 | 806 | 179 | 985 | # 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.
"""
Streaming module API that should be implemented by all Streaming components,
"""
from contextlib import contextmanag... | # 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.
"""
Streaming module API that should be implemented by all Streaming components,
"""
from contextlib import contextmanag... |
13,768 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/modules/streaming.py | 125,126 | 122,132 | flush | StreamingSequential | 126,132 | 126,132 | class StreamingSequential(StreamingModule, nn.Sequential):
"""A streaming compatible alternative of `nn.Sequential`.
"""
def flush(self, x: tp.Optional[torch.Tensor] = None):
FILL_FUNC_BODY | class StreamingSequential(StreamingModule, nn.Sequential):
"""A streaming compatible alternative of `nn.Sequential`.
"""
def flush(self, x: tp.Optional[torch.Tensor] = None):
FILL_FUNC_BODY | for module in self:
if isinstance(module, StreamingModule):
x = module.flush(x)
elif x is not None:
x = module(x)
return x
| for module in self:
if isinstance(module, StreamingModule):
x = module.flush(x)
elif x is not None:
x = module(x)
return x
| 20 | 71 | 55 | 126 | # 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.
"""
Streaming module API that should be implemented by all Streaming components,
"""
from contextlib import contextmanag... | # 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.
"""
Streaming module API that should be implemented by all Streaming components,
"""
from contextlib import contextmanag... |
13,771 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/optim/ema.py | 17,18 | 1,86 | _get_all_non_persistent_buffers_set | 18,32 | 18,32 | # 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... | # 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... | names: set = set()
for (name, sub_module) in module.named_modules():
if name == '':
buffer_names = module._non_persistent_buffers_set
buffer_names = {f"{root}.{buff_name}" if len(root) > 0 else buff_name
for buff_name in buffer_names}
names... | names: set = set()
for (name, sub_module) in module.named_modules():
if name == '':
buffer_names = module._non_persistent_buffers_set
buffer_names = {f"{root}.{buff_name}" if len(root) > 0 else buff_name
for buff_name in buffer_names}
names... | 47 | 800 | 188 | 988 | # 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... | # 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... | |
13,772 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/optim/ema.py | 64,65 | 40,86 | step | ModuleDictEMA | 65,78 | 65,78 | class ModuleDictEMA:
"""Exponential Moving Average over a nn.ModuleDict.
You can switch to the EMA weights temporarily.
"""
def __init__(self, module_dict: nn.ModuleDict, decay: float = 0.999,
unbias: bool = True, device: tp.Union[torch.device, str] = 'cpu'):
self.decay = decay... | class ModuleDictEMA:
"""Exponential Moving Average over a nn.ModuleDict.
You can switch to the EMA weights temporarily.
"""
def __init__(self, module_dict: nn.ModuleDict, decay: float = 0.999,
unbias: bool = True, device: tp.Union[torch.device, str] = 'cpu'):
self.decay = decay... | if self.unbias:
self.count = self.count * self.decay + 1
w = 1 / self.count
else:
w = 1 - self.decay
for module_name, module in self.module_dict.items():
for key, val in _get_named_tensors(module):
if not val.is_floating_point():
... | if self.unbias:
self.count = self.count * self.decay + 1
w = 1 / self.count
else:
w = 1 - self.decay
for module_name, module in self.module_dict.items():
for key, val in _get_named_tensors(module):
if not val.is_floating_point():
... | 44 | 385 | 170 | 555 | # 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... | # 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... |
13,774 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/optim/fsdp.py | 157,158 | 149,183 | state_dict | _FSDPFixStateDict | 158,164 | 158,164 | class _FSDPFixStateDict(FSDP):
@staticmethod
def _name_without_fsdp_prefix(name: str) -> str:
from torch.distributed.fsdp._common_utils import FSDP_WRAPPED_MODULE # type: ignore
parts = name.split('.')
new_parts = [part for part in parts if part != FSDP_WRAPPED_MODULE]
return '.... | class _FSDPFixStateDict(FSDP):
@staticmethod
def _name_without_fsdp_prefix(name: str) -> str:
from torch.distributed.fsdp._common_utils import FSDP_WRAPPED_MODULE # type: ignore
parts = name.split('.')
new_parts = [part for part in parts if part != FSDP_WRAPPED_MODULE]
return '.... | state = dict(super().state_dict(*args, **kwargs))
for key, value in list(state.items()):
if is_sharded_tensor(value):
del state[key]
return state
| state = dict(super().state_dict(*args, **kwargs))
for key, value in list(state.items()):
if is_sharded_tensor(value):
del state[key]
return state
| 15 | 393 | 61 | 454 | # 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 ... | # 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 ... |
13,775 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/quantization/base.py | 40,41 | 27,63 | encode | BaseQuantizer | 42,44 | 41,44 | class BaseQuantizer(nn.Module):
"""Base class for quantizers.
"""
def forward(self, x: torch.Tensor, frame_rate: int) -> QuantizedResult:
"""
Given input tensor x, returns first the quantized (or approximately quantized)
representation along with quantized codes, bandwidth, and any ... | class BaseQuantizer(nn.Module):
"""Base class for quantizers.
"""
def forward(self, x: torch.Tensor, frame_rate: int) -> QuantizedResult:
"""
Given input tensor x, returns first the quantized (or approximately quantized)
representation along with quantized codes, bandwidth, and any ... | raise NotImplementedError()
| """Encode a given input tensor with the specified sample rate at the given bandwidth."""
raise NotImplementedError()
| 2 | 337 | 12 | 349 | # 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.
"""
Base class for all quantizers.
"""
from dataclasses import dataclass, field
import typing as tp
import torch
from t... | # 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.
"""
Base class for all quantizers.
"""
from dataclasses import dataclass, field
import typing as tp
import torch
from t... |
13,776 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/quantization/base.py | 80,81 | 63,100 | decode | DummyQuantizer | 85,87 | 81,87 | class DummyQuantizer(BaseQuantizer):
"""Fake quantizer that actually does not perform any quantization.
"""
def __init__(self):
super().__init__()
def forward(self, x: torch.Tensor, frame_rate: int):
q = x.unsqueeze(1)
return QuantizedResult(x, q, torch.tensor(q.numel() * 32 * f... | class DummyQuantizer(BaseQuantizer):
"""Fake quantizer that actually does not perform any quantization.
"""
def __init__(self):
super().__init__()
def forward(self, x: torch.Tensor, frame_rate: int):
q = x.unsqueeze(1)
return QuantizedResult(x, q, torch.tensor(q.numel() * 32 * f... | return codes.squeeze(1)
| """Decode the given codes to the quantized representation.
In the case of the DummyQuantizer, the codes are actually identical
to the input and resulting quantized representation as no quantization is done.
"""
return codes.squeeze(1)
| 2 | 413 | 14 | 427 | # 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.
"""
Base class for all quantizers.
"""
from dataclasses import dataclass, field
import typing as tp
import torch
from t... | # 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.
"""
Base class for all quantizers.
"""
from dataclasses import dataclass, field
import typing as tp
import torch
from t... |
13,778 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/quantization/core_vq.py | 142,143 | 87,222 | replace_ | EuclideanCodebook | 143,148 | 143,148 | class EuclideanCodebook(nn.Module):
"""Codebook with Euclidean distance.
Args:
dim (int): Dimension.
codebook_size (int): Codebook size.
kmeans_init (bool): Whether to use k-means to initialize the codebooks.
If set to true, run the k-means algorithm on the first training ba... | class EuclideanCodebook(nn.Module):
"""Codebook with Euclidean distance.
Args:
dim (int): Dimension.
codebook_size (int): Codebook size.
kmeans_init (bool): Whether to use k-means to initialize the codebooks.
If set to true, run the k-means algorithm on the first training ba... | modified_codebook = torch.where(
mask[..., None], sample_vectors(samples, self.codebook_size), self.embed
)
self.embed.data.copy_(modified_codebook)
| modified_codebook = torch.where(
mask[..., None], sample_vectors(samples, self.codebook_size), self.embed
)
self.embed.data.copy_(modified_codebook)
| 10 | 1,491 | 63 | 1,554 | # 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 einops import rearrange, repeat
import flashy
import torch
from torch import nn, einsum
import ... | # 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 einops import rearrange, repeat
import flashy
import torch
from torch import nn, einsum
import ... |
13,779 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/quantization/core_vq.py | 363,364 | 352,406 | forward | ResidualVectorQuantization | 364,387 | 364,387 | class ResidualVectorQuantization(nn.Module):
"""Residual vector quantization implementation.
Follows Algorithm 1. in https://arxiv.org/pdf/2107.03312.pdf
"""
def __init__(self, *, num_quantizers, **kwargs):
super().__init__()
self.layers = nn.ModuleList(
[VectorQuantization(... | class ResidualVectorQuantization(nn.Module):
"""Residual vector quantization implementation.
Follows Algorithm 1. in https://arxiv.org/pdf/2107.03312.pdf
"""
def __init__(self, *, num_quantizers, **kwargs):
super().__init__()
self.layers = nn.ModuleList(
[VectorQuantization(... | quantized_out = 0.0
residual = x
all_losses = []
all_indices = []
n_q = n_q or len(self.layers)
for i, layer in enumerate(self.layers[:n_q]):
quantized, indices, loss = layer(residual)
quantized = quantized.detach()
residual = residu... | quantized_out = 0.0
residual = x
all_losses = []
all_indices = []
n_q = n_q or len(self.layers)
for i, layer in enumerate(self.layers[:n_q]):
quantized, indices, loss = layer(residual)
quantized = quantized.detach()
residual = residu... | 70 | 409 | 270 | 679 | # 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 einops import rearrange, repeat
import flashy
import torch
from torch import nn, einsum
import ... | # 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 einops import rearrange, repeat
import flashy
import torch
from torch import nn, einsum
import ... |
13,780 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/quantization/core_vq.py | 301,302 | 222,352 | encode | VectorQuantization | 302,307 | 302,307 | class VectorQuantization(nn.Module):
"""Vector quantization implementation.
Currently supports only euclidean distance.
Args:
dim (int): Dimension
codebook_size (int): Codebook size
codebook_dim (int): Codebook dimension. If not defined, uses the specified dimension in dim.
... | class VectorQuantization(nn.Module):
"""Vector quantization implementation.
Currently supports only euclidean distance.
Args:
dim (int): Dimension
codebook_size (int): Codebook size
codebook_dim (int): Codebook dimension. If not defined, uses the specified dimension in dim.
... | x = self._preprocess(x)
x = self.project_in(x)
embed_in = self._codebook.encode(x)
return embed_in
| x = self._preprocess(x)
x = self.project_in(x)
embed_in = self._codebook.encode(x)
return embed_in
| 11 | 1,451 | 50 | 1,501 | # 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 einops import rearrange, repeat
import flashy
import torch
from torch import nn, einsum
import ... | # 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 einops import rearrange, repeat
import flashy
import torch
from torch import nn, einsum
import ... |
13,781 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/quantization/vq.py | 113,114 | 16,116 | set_num_codebooks | ResidualVectorQuantizer | 114,116 | 114,116 | class ResidualVectorQuantizer(BaseQuantizer):
"""Residual Vector Quantizer.
Args:
dimension (int): Dimension of the codebooks.
n_q (int): Number of residual vector quantizers used.
q_dropout (bool): Random quantizer drop out at train time.
bins (int): Codebook size.
deca... | class ResidualVectorQuantizer(BaseQuantizer):
"""Residual Vector Quantizer.
Args:
dimension (int): Dimension of the codebooks.
n_q (int): Number of residual vector quantizers used.
q_dropout (bool): Random quantizer drop out at train time.
bins (int): Codebook size.
deca... | assert n > 0 and n <= self.max_n_q
self.n_q = n
| assert n > 0 and n <= self.max_n_q
self.n_q = n
| 11 | 1,334 | 27 | 1,361 | # 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 .base import BaseQuantizer, QuantizedResult
from .core_vq import Resi... | # 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 .base import BaseQuantizer, QuantizedResult
from .core_vq import Resi... |
13,785 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/solvers/diffusion.py | 95,96 | 53,114 | process_data | DataProcess | 96,107 | 96,107 | class DataProcess:
"""Apply filtering or resampling.
Args:
initial_sr (int): Initial sample rate.
target_sr (int): Target sample rate.
use_resampling: Whether to use resampling or not.
use_filter (bool):
n_bands (int): Number of bands to consider.
idx_band (int):... | class DataProcess:
"""Apply filtering or resampling.
Args:
initial_sr (int): Initial sample rate.
target_sr (int): Target sample rate.
use_resampling: Whether to use resampling or not.
use_filter (bool):
n_bands (int): Number of bands to consider.
idx_band (int):... | if x is None:
return None
if self.boost:
x /= torch.clamp(x.std(dim=(1, 2), keepdim=True), min=1e-4)
x * 0.22
if self.use_filter and not metric:
x = self.filter(x)[self.idx_band]
if self.use_resampling:
x = julius.resample_frac(... | if x is None:
return None
if self.boost:
x /= torch.clamp(x.std(dim=(1, 2), keepdim=True), min=1e-4)
x * 0.22
if self.use_filter and not metric:
x = self.filter(x)[self.idx_band]
if self.use_resampling:
x = julius.resample_frac(... | 34 | 632 | 151 | 783 | # 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... | # 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... |
13,788 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/best_state.py | 46,47 | 21,82 | _validate_no_parameter_ids_overlap | BestStateDictManager | 47,53 | 47,53 | class BestStateDictManager(flashy.state.StateDictSource):
"""BestStateDictManager maintains a copy of best state_dict() for registered sources.
BestStateDictManager has two main attributes:
states (dict): State dict of the registered StateDictSource.
param_ids (dict): Dict of parameter ids for ... | class BestStateDictManager(flashy.state.StateDictSource):
"""BestStateDictManager maintains a copy of best state_dict() for registered sources.
BestStateDictManager has two main attributes:
states (dict): State dict of the registered StateDictSource.
param_ids (dict): Dict of parameter ids for ... | for registered_name, registered_param_ids in self.param_ids.items():
if registered_name != name:
overlap = set.intersection(registered_param_ids.keys(), param_ids.keys())
assert len(overlap) == 0, f"Found {len(overlap)} / {len(param_ids.keys())} overlapping parameters... | for registered_name, registered_param_ids in self.param_ids.items():
if registered_name != name:
overlap = set.intersection(registered_param_ids.keys(), param_ids.keys())
assert len(overlap) == 0, f"Found {len(overlap)} / {len(param_ids.keys())} overlapping parameters... | 32 | 842 | 122 | 964 | # 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... | # 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... |
13,790 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/cache.py | 259,260 | 224,325 | _load_one | CachedBatchLoader | 260,297 | 260,297 | class CachedBatchLoader:
"""Loader for cached mini-batches dumped with `CachedBatchWriter`.
Args:
cache_folder (Path): folder in which the cached minibatches are stored.
batch_size (int): batch size (per GPU) expected.
num_workers (int): number of workers to use for loading.
min... | class CachedBatchLoader:
"""Loader for cached mini-batches dumped with `CachedBatchWriter`.
Args:
cache_folder (Path): folder in which the cached minibatches are stored.
batch_size (int): batch size (per GPU) expected.
num_workers (int): number of workers to use for loading.
min... | zip_path = self._zip_path(index)
if not zip_path.exists():
if index < self.min_length:
raise RuntimeError(f"Cache should have at least {self.min_length} batches, but {index} doesn't exist")
return None
mode = "rb" if sys.version_info >= (3, 9) else "r"
... | zip_path = self._zip_path(index)
if not zip_path.exists():
if index < self.min_length:
raise RuntimeError(f"Cache should have at least {self.min_length} batches, but {index} doesn't exist")
return None
mode = "rb" if sys.version_info >= (3, 9) else "r"
... | 142 | 673 | 472 | 1,145 | # 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... | # 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... |
13,791 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/cache.py | 201,202 | 161,224 | save | CachedBatchWriter | 206,224 | 202,224 | class CachedBatchWriter:
"""Write pre computed caches for mini batches. This can
make loading a lot more efficient depending on your filesystem.
Args:
cache_folder (Path): folder in which the cached minibatches
will be stored.
Inside cache folder, the structure is the following:
... | class CachedBatchWriter:
"""Write pre computed caches for mini batches. This can
make loading a lot more efficient depending on your filesystem.
Args:
cache_folder (Path): folder in which the cached minibatches
will be stored.
Inside cache folder, the structure is the following:
... | all_contents = []
for rank in range(flashy.distrib.world_size()):
their_content = flashy.distrib.broadcast_object(content, src=rank)
all_contents.append(their_content)
if flashy.distrib.is_rank_zero():
idx = 0
with flashy.utils.write_and_rename(se... | """Save one mini batch. This function is distributed-aware
and will automatically merge all the items from the different
workers.
"""
all_contents = []
for rank in range(flashy.distrib.world_size()):
their_content = flashy.distrib.broadcast_object(content, src... | 51 | 496 | 225 | 721 | # 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... | # 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... |
13,792 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/cache.py | 94,95 | 39,161 | get_embed_from_cache | EmbeddingCache | 105,124 | 95,124 | class EmbeddingCache:
"""Cache around embeddings computation for faster execution.
The EmbeddingCache is storing pre-computed embeddings on disk and provides a simple API
to retrieve the pre-computed embeddings on full inputs and extract only a given chunk
using a user-provided function. When the cache ... | class EmbeddingCache:
"""Cache around embeddings computation for faster execution.
The EmbeddingCache is storing pre-computed embeddings on disk and provides a simple API
to retrieve the pre-computed embeddings on full inputs and extract only a given chunk
using a user-provided function. When the cache ... | embeds = []
for idx, path in enumerate(paths):
cache = self._get_cache_path(path)
if cache in self._current_batch_cache:
embed = self._current_batch_cache[cache]
else:
full_embed = self._compute_embed_fn(path, x, idx)
tr... | """Get embedding from cache, computing and storing it to cache if not already cached.
The EmbeddingCache first tries to load the embedding from the in-memory cache
containing the pre-computed chunks populated through `populate_embed_cache`.
If not found, the full embedding is computed an... | 66 | 1,504 | 261 | 1,765 | # 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... | # 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... |
13,793 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/checkpoint.py | 104,105 | 1,162 | flush_stale_checkpoints | 106,125 | 105,125 | # 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
... | # 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
... | if keep_last is None or keep_last <= 0:
return
checkpoint_dir = checkpoint_path.parent
suffix = ''
if flashy.distrib.rank() > 0:
suffix = f'.{flashy.distrib.rank()}'
checkpoint_files_with_epoch = []
for path in Path(checkpoint_dir).glob(f'checkpoint_*.th{suffix}'):
epoch_... | """Flush checkpoints to only keep last N checkpoints."""
if keep_last is None or keep_last <= 0:
return
checkpoint_dir = checkpoint_path.parent
suffix = ''
if flashy.distrib.rank() > 0:
suffix = f'.{flashy.distrib.rank()}'
checkpoint_files_with_epoch = []
for path in Path(che... | 67 | 1,673 | 312 | 1,985 | # 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
... | # 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
... | |
13,794 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/cluster.py | 27,28 | 1,76 | _guess_cluster_type | 28,45 | 28,45 | # 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... | # 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... | uname = os.uname()
fqdn = socket.getfqdn()
if uname.sysname == "Linux" and (uname.release.endswith("-aws") or ".ec2" in fqdn):
return ClusterType.AWS
if fqdn.endswith(".fair"):
return ClusterType.FAIR
if fqdn.endswith(".facebook.com"):
return ClusterType.RSC
if uname.s... | uname = os.uname()
fqdn = socket.getfqdn()
if uname.sysname == "Linux" and (uname.release.endswith("-aws") or ".ec2" in fqdn):
return ClusterType.AWS
if fqdn.endswith(".fair"):
return ClusterType.FAIR
if fqdn.endswith(".facebook.com"):
return ClusterType.RSC
if uname.s... | 34 | 534 | 174 | 708 | # 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... | # 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... | |
13,795 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/deadlock.py | 24,25 | 18,59 | update | DeadlockDetect | 25,28 | 25,28 | class DeadlockDetect:
def __init__(self, use: bool = False, timeout: float = 120.):
self.use = use
self.timeout = timeout
self._queue: Queue = Queue()
def update(self, stage: str):
FILL_FUNC_BODY def __enter__(self):
if self.use:
self._thread = threading.Thread(ta... | class DeadlockDetect:
def __init__(self, use: bool = False, timeout: float = 120.):
self.use = use
self.timeout = timeout
self._queue: Queue = Queue()
def update(self, stage: str):
FILL_FUNC_BODY def __enter__(self):
if self.use:
self._thread = threading.Thread(ta... | if self.use:
self._queue.put(stage)
| if self.use:
self._queue.put(stage)
| 3 | 382 | 21 | 403 | # 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... | # 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... |
13,796 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/export.py | 61,62 | 1,80 | export_lm | 64,80 | 62,80 | # 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... | # 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... | pkg = torch.load(checkpoint_path, 'cpu')
if pkg['fsdp_best_state']:
best_state = pkg['fsdp_best_state']['model']
else:
assert pkg['best_state']
best_state = pkg['best_state']['model']
new_pkg = {
'best_state': best_state,
'xp.cfg': OmegaConf.to_yaml(pkg['xp.cfg'])... | """Export only the best state from the given MusicGen or AudioGen checkpoint.
"""
pkg = torch.load(checkpoint_path, 'cpu')
if pkg['fsdp_best_state']:
best_state = pkg['fsdp_best_state']['model']
else:
assert pkg['best_state']
best_state = pkg['best_state']['model']
new_pk... | 33 | 700 | 203 | 903 | # 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... | # 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... | |
13,797 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/export_legacy.py | 55,56 | 1,71 | export_lm | 56,71 | 56,71 | # 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... | # 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... | pkg = torch.load(checkpoint_path, 'cpu')
if pkg['fsdp_best_state']:
best_state = pkg['fsdp_best_state']['model']
else:
best_state = pkg['best_state']['model']
new_pkg = {
'best_state': best_state,
'xp.cfg': OmegaConf.to_yaml(_clean_lm_cfg(pkg['xp.cfg'])),
# The fo... | pkg = torch.load(checkpoint_path, 'cpu')
if pkg['fsdp_best_state']:
best_state = pkg['fsdp_best_state']['model']
else:
best_state = pkg['best_state']['model']
new_pkg = {
'best_state': best_state,
'xp.cfg': OmegaConf.to_yaml(_clean_lm_cfg(pkg['xp.cfg'])),
# The fo... | 44 | 636 | 215 | 851 | # 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... | # 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... | |
13,798 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/notebook.py | 17,18 | 1,33 | display_audio | 25,33 | 18,33 | # 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 ... | # 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 ... | assert samples.dim() == 2 or samples.dim() == 3
samples = samples.detach().cpu()
if samples.dim() == 2:
samples = samples[None, ...]
for audio in samples:
ipd.display(ipd.Audio(audio, rate=sample_rate))
| """Renders an audio player for the given audio samples.
Args:
samples (torch.Tensor): a Tensor of decoded audio samples
with shapes [B, C, T] or [C, T]
sample_rate (int): sample rate audio should be displayed with.
"""
assert samples.dim() == 2 or samples.dim() == 3
sam... | 25 | 202 | 84 | 286 | # 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 ... | # 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 ... | |
13,799 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/profiler.py | 28,29 | 17,39 | step | Profiler | 29,32 | 29,32 | class Profiler:
"""Context manager wrapper for xformers profiler.
"""
def __init__(self, module: torch.nn.Module, enabled: bool = False):
self.profiler: tp.Optional[tp.Any] = None
if enabled:
from xformers.profiler import profile
output_dir = dora.get_xp().folder / 'p... | class Profiler:
"""Context manager wrapper for xformers profiler.
"""
def __init__(self, module: torch.nn.Module, enabled: bool = False):
self.profiler: tp.Optional[tp.Any] = None
if enabled:
from xformers.profiler import profile
output_dir = dora.get_xp().folder / 'p... | if self.profiler is not None:
self.profiler.step() # type: ignore
| if self.profiler is not None:
self.profiler.step() # type: ignore
| 9 | 265 | 31 | 296 | # 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:
... | # 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:
... |
13,801 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/audiocraft/utils/samples/manager.py | 68,69 | 48,72 | audio_reference | Sample | 69,72 | 69,72 | @dataclass
class Sample:
id: str
path: str
epoch: int
duration: float
conditioning: tp.Optional[tp.Dict[str, tp.Any]]
prompt: tp.Optional[ReferenceSample]
reference: tp.Optional[ReferenceSample]
generation_args: tp.Optional[tp.Dict[str, tp.Any]]
def __hash__(self):
return ha... | @dataclass
class Sample:
id: str
path: str
epoch: int
duration: float
conditioning: tp.Optional[tp.Dict[str, tp.Any]]
prompt: tp.Optional[ReferenceSample]
reference: tp.Optional[ReferenceSample]
generation_args: tp.Optional[tp.Dict[str, tp.Any]]
def __hash__(self):
return ha... | return audio_read(self.reference.path) if self.reference is not None else None
| return audio_read(self.reference.path) if self.reference is not None else None
| 9 | 247 | 27 | 274 | # 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 ... | # 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 ... |
13,804 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_audiocraft/audiocraft/demos/magnet_app.py | 64,65 | 55,75 | _cleanup | FileCleaner | 65,75 | 65,75 | class FileCleaner:
def __init__(self, file_lifetime: float = 3600):
self.file_lifetime = file_lifetime
self.files = []
def add(self, path: tp.Union[str, Path]):
self._cleanup()
self.files.append((time.time(), Path(path)))
def _cleanup(self):
FILL_FUNC_BODY | class FileCleaner:
def __init__(self, file_lifetime: float = 3600):
self.file_lifetime = file_lifetime
self.files = []
def add(self, path: tp.Union[str, Path]):
self._cleanup()
self.files.append((time.time(), Path(path)))
def _cleanup(self):
FILL_FUNC_BODY | now = time.time()
for time_added, path in list(self.files):
if now - time_added > self.file_lifetime:
if path.exists():
path.unlink()
self.files.pop(0)
else:
break
| now = time.time()
for time_added, path in list(self.files):
if now - time_added > self.file_lifetime:
if path.exists():
path.unlink()
self.files.pop(0)
else:
break
| 20 | 113 | 83 | 196 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under thmage license found in the
# LICENSE file in the root directory of this source tree.
import argparse
from concurrent.futures import ProcessPoolExecutor
import logging
import os
from pathlib import Path
im... | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under thmage license found in the
# LICENSE file in the root directory of this source tree.
import argparse
from concurrent.futures import ProcessPoolExecutor
import logging
import os
from pathlib import Path
im... |
13,805 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/ema.py | 60,61 | 15,67 | state_dict | ModelEMA | 61,63 | 61,63 | class ModelEMA:
"""
Perform EMA on a model. You can switch to the EMA weights temporarily
with the `swap` method.
ema = ModelEMA(model)
with ema.swap():
# compute valid metrics with averaged model.
"""
def __init__(self, model, decay=0.9999, unbias=True, device='cpu'):
... | class ModelEMA:
"""
Perform EMA on a model. You can switch to the EMA weights temporarily
with the `swap` method.
ema = ModelEMA(model)
with ema.swap():
# compute valid metrics with averaged model.
"""
def __init__(self, model, decay=0.9999, unbias=True, device='cpu'):
... | return {'state': self.state, 'count': self.count}
| return {'state': self.state, 'count': self.count}
| 5 | 483 | 20 | 503 | # 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.
# Inspired from https://github.com/rwightman/pytorch-image-models
from contextlib import contextmanager
import torch
fr... | # 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.
# Inspired from https://github.com/rwightman/pytorch-image-models
from contextlib import contextmanager
import torch
fr... |
13,806 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/_explorers.py | 13,14 | 10,65 | get_grid_metrics | MyExplorer | 16,38 | 14,38 | class MyExplorer(Explorer):
test_metrics = ['nsdr', 'sdr_med']
def get_grid_metrics(self):
FILL_FUNC_BODY def process_history(self, history):
train = {
'epoch': len(history),
}
valid = {}
test = {}
best_v_main = float('inf')
breco = float('inf')
... | class MyExplorer(Explorer):
test_metrics = ['nsdr', 'sdr_med']
def get_grid_metrics(self):
"""Return the metrics that should be displayed in the tracking table.
"""
FILL_FUNC_BODY def process_history(self, history):
train = {
'epoch': len(history),
}
valid... | return [
tt.group("train", [
tt.leaf("epoch"),
tt.leaf("reco", ".3f"),
], align=">"),
tt.group("valid", [
tt.leaf("penalty", ".1f"),
tt.leaf("ms", ".1f"),
tt.leaf("reco", ".2%"),
... | """Return the metrics that should be displayed in the tracking table.
"""
return [
tt.group("train", [
tt.leaf("epoch"),
tt.leaf("reco", ".3f"),
], align=">"),
tt.group("valid", [
tt.leaf("penalty", ".1f"),
... | 46 | 392 | 285 | 677 | # 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 dora import Explorer
import treetable as tt
class MyExplorer(Explorer):
test_metrics = ['nsdr', 'sdr_med']
... | # 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 dora import Explorer
import treetable as tt
class MyExplorer(Explorer):
test_metrics = ['nsdr', 'sdr_med']
... |
13,807 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/mdx.py | 17,19 | 1,34 | explorer | 19,34 | 19,34 | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_A =... | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_A =... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='learnlab')
# Reproduce results from MDX competition Track A
# This trains the first round of models. Once this is trained,
# you will need to schedule `mdx_refine`.
for sig in TRACK_A:
xp = main.get_xp_from_sig(si... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='learnlab')
# Reproduce results from MDX competition Track A
# This trains the first round of models. Once this is trained,
# you will need to schedule `mdx_refine`.
for sig in TRACK_A:
xp = main.get_xp_from_sig(si... | 55 | 156 | 211 | 367 | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_A =... | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_A =... | |
13,808 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/mdx_extra.py | 16,18 | 1,37 | explorer | 18,37 | 18,37 | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_B = ... | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_B = ... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='learnlab')
# Reproduce results from MDX competition Track A
# This trains the first round of models. Once this is trained,
# you will need to schedule `mdx_refine`.
for sig in TRACK_B:
while sig is not None:
... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='learnlab')
# Reproduce results from MDX competition Track A
# This trains the first round of models. Once this is trained,
# you will need to schedule `mdx_refine`.
for sig in TRACK_B:
while sig is not None:
... | 68 | 155 | 236 | 391 | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_B = ... | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from ..train import main
TRACK_B = ... | |
13,809 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/mdx_refine.py | 15,17 | 1,35 | explorer | 17,35 | 17,35 | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from .mdx import TRACK_A
from ..trai... | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from .mdx import TRACK_A
from ..trai... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='learnlab')
# Reproduce results from MDX competition Track A
# WARNING: all the experiments in the `mdx` grid must have completed.
for sig in TRACK_A:
xp = main.get_xp_from_sig(sig)
launcher(xp.argv)
fo... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='learnlab')
# Reproduce results from MDX competition Track A
# WARNING: all the experiments in the `mdx` grid must have completed.
for sig in TRACK_A:
xp = main.get_xp_from_sig(sig)
launcher(xp.argv)
fo... | 65 | 121 | 291 | 412 | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from .mdx import TRACK_A
from ..trai... | # 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.
"""
Main training for the Track A MDX models.
"""
from ._explorers import MyExplorer
from .mdx import TRACK_A
from ..trai... | |
13,810 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/mmi.py | 11,13 | 1,70 | explorer | 13,70 | 13,70 | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... | launcher.slurm_(gpus=8, time=3 * 24 * 60, partition="devlab,learnlab,learnfair") # 3 days
sub = launcher.bind_(
{
"dset": "extra_mmi_goodclean",
"test.shifts": 0,
"model": "htdemucs",
"htdemucs.dconv_mode": 3,
"htdemucs.depth": 4,
... | launcher.slurm_(gpus=8, time=3 * 24 * 60, partition="devlab,learnlab,learnfair") # 3 days
sub = launcher.bind_(
{
"dset": "extra_mmi_goodclean",
"test.shifts": 0,
"model": "htdemucs",
"htdemucs.dconv_mode": 3,
"htdemucs.depth": 4,
... | 192 | 100 | 836 | 936 | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... | |
13,811 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/mmi_ft.py | 22,24 | 1,56 | explorer | 24,56 | 24,56 | # 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 MyExplorer
from dora import Launcher
from demucs import train
def get_sub(launcher, sig):
x... | # 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 MyExplorer
from dora import Launcher
from demucs import train
def get_sub(launcher, sig):
x... | launcher.slurm_(gpus=4, time=3 * 24 * 60, partition="devlab,learnlab,learnfair") # 3 days
ft = {
'optim.lr': 1e-4,
'augment.remix.proba': 0,
'augment.scale.proba': 0,
'augment.shift_same': True,
'htdemucs.t_weight_decay': 0.05,
'batch_size': 8,
'optim.cli... | launcher.slurm_(gpus=4, time=3 * 24 * 60, partition="devlab,learnlab,learnfair") # 3 days
ft = {
'optim.lr': 1e-4,
'augment.remix.proba': 0,
'augment.scale.proba': 0,
'augment.shift_same': True,
'htdemucs.t_weight_decay': 0.05,
'batch_size': 8,
'optim.cli... | 105 | 187 | 438 | 625 | # 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 MyExplorer
from dora import Launcher
from demucs import train
def get_sub(launcher, sig):
x... | # 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 MyExplorer
from dora import Launcher
from demucs import train
def get_sub(launcher, sig):
x... | |
13,812 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/repro.py | 13,15 | 1,51 | explorer | 15,51 | 15,51 | # 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.
"""
Easier training for reproducibility
"""
from ._explorers import MyExplorer
@MyExplorer
def explorer(launcher):
FILL... | # 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.
"""
Easier training for reproducibility
"""
from ._explorers import MyExplorer
@MyExplorer
def explorer(launcher):
FILL... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='devlab,learnlab')
launcher.bind_({'ema.epoch': [0.9, 0.95]})
launcher.bind_({'ema.batch': [0.9995, 0.9999]})
launcher.bind_({'epochs': 600})
base = {'model': 'demucs', 'demucs.dconv_mode': 0, 'demucs.gelu': False,
... | launcher.slurm_(
gpus=8,
time=3 * 24 * 60,
partition='devlab,learnlab')
launcher.bind_({'ema.epoch': [0.9, 0.95]})
launcher.bind_({'ema.batch': [0.9995, 0.9999]})
launcher.bind_({'epochs': 600})
base = {'model': 'demucs', 'demucs.dconv_mode': 0, 'demucs.gelu': False,
... | 111 | 103 | 552 | 655 | # 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.
"""
Easier training for reproducibility
"""
from ._explorers import MyExplorer
@MyExplorer
def explorer(launcher):
FILL... | # 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.
"""
Easier training for reproducibility
"""
from ._explorers import MyExplorer
@MyExplorer
def explorer(launcher):
FILL... | |
13,813 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/repro_ft.py | 14,16 | 1,47 | explorer | 16,47 | 16,47 | # 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.
"""
Fine tuning experiments
"""
from ._explorers import MyExplorer
from ..train import main
@MyExplorer
def explorer(la... | # 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.
"""
Fine tuning experiments
"""
from ._explorers import MyExplorer
from ..train import main
@MyExplorer
def explorer(la... | launcher.slurm_(
gpus=8,
time=300,
partition='devlab,learnlab')
# Mus
launcher.slurm_(constraint='volta32gb')
grid = "repro"
folder = main.dora.dir / "grids" / grid
for sig in folder.iterdir():
if not sig.is_symlink():
continue
xp = main.get... | launcher.slurm_(
gpus=8,
time=300,
partition='devlab,learnlab')
# Mus
launcher.slurm_(constraint='volta32gb')
grid = "repro"
folder = main.dora.dir / "grids" / grid
for sig in folder.iterdir():
if not sig.is_symlink():
continue
xp = main.get... | 74 | 105 | 461 | 566 | # 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.
"""
Fine tuning experiments
"""
from ._explorers import MyExplorer
from ..train import main
@MyExplorer
def explorer(la... | # 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.
"""
Fine tuning experiments
"""
from ._explorers import MyExplorer
from ..train import main
@MyExplorer
def explorer(la... | |
13,814 | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs | /home/hieuvd/dung_repo/raw/stars_01/facebookresearch_demucs/demucs/demucs/grids/sdx23.py | 11,13 | 1,20 | explorer | 13,20 | 13,20 | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... | launcher.slurm_(gpus=8, time=3 * 24 * 60, partition="speechgpt,learnfair",
mem_per_gpu=None, constraint='')
launcher.bind_({"dset.use_musdb": False})
with launcher.job_array():
launcher(dset='sdx23_bleeding')
launcher(dset='sdx23_labelnoise')
| launcher.slurm_(gpus=8, time=3 * 24 * 60, partition="speechgpt,learnfair",
mem_per_gpu=None, constraint='')
launcher.bind_({"dset.use_musdb": False})
with launcher.job_array():
launcher(dset='sdx23_bleeding')
launcher(dset='sdx23_labelnoise')
| 15 | 100 | 117 | 217 | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... | # 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 MyExplorer
from dora import Launcher
@MyExplorer
def explorer(launcher: Launcher):
FILL_FUNC_BO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.