Feature Extraction
Transformers
Safetensors
audio_embeddings
audio
custom_code
self-supervised-learning
audio-embeddings
best-rq-2
audioset
Instructions to use ltuncay/BEST-RQ-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ltuncay/BEST-RQ-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="ltuncay/BEST-RQ-2", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ltuncay/BEST-RQ-2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download audio-embeddings/tests/conftest.py from ltuncay/BEST-RQ-2: direct link, hf CLI and curl.
- Browser
- Download file 3.89 kB
-
https://huggingface.co/ltuncay/BEST-RQ-2/resolve/main/audio-embeddings/tests/conftest.py
- Command line
-
hf download hf://ltuncay/BEST-RQ-2/audio-embeddings/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/ltuncay/BEST-RQ-2/resolve/main/audio-embeddings/tests/conftest.py
3.89 kB
| """This file prepares config fixtures for other tests.""" | |
| from pathlib import Path | |
| import pytest | |
| import rootutils | |
| from hydra import compose, initialize | |
| from hydra.core.global_hydra import GlobalHydra | |
| from omegaconf import DictConfig, open_dict | |
| def cfg_train_global() -> DictConfig: | |
| """A pytest fixture for setting up a default Hydra DictConfig for training. | |
| :return: A DictConfig object containing a default Hydra configuration for training. | |
| """ | |
| with initialize(version_base="1.3", config_path="../configs"): | |
| cfg = compose(config_name="train.yaml", return_hydra_config=True, overrides=[]) | |
| # set defaults for all tests | |
| with open_dict(cfg): | |
| cfg.paths.root_dir = str(rootutils.find_root(indicator=".project-root")) | |
| cfg.trainer.max_epochs = 1 | |
| cfg.trainer.limit_train_batches = 0.01 | |
| cfg.trainer.limit_val_batches = 0.1 | |
| cfg.trainer.limit_test_batches = 0.1 | |
| cfg.trainer.accelerator = "cpu" | |
| cfg.trainer.devices = 1 | |
| cfg.data.num_workers = 0 | |
| cfg.data.pin_memory = False | |
| cfg.extras.print_config = False | |
| cfg.extras.enforce_tags = False | |
| cfg.logger = None | |
| return cfg | |
| def cfg_eval_global() -> DictConfig: | |
| """A pytest fixture for setting up a default Hydra DictConfig for evaluation. | |
| :return: A DictConfig containing a default Hydra configuration for evaluation. | |
| """ | |
| with initialize(version_base="1.3", config_path="../configs"): | |
| cfg = compose( | |
| config_name="eval.yaml", return_hydra_config=True, overrides=["ckpt_path=."] | |
| ) | |
| # set defaults for all tests | |
| with open_dict(cfg): | |
| cfg.paths.root_dir = str(rootutils.find_root(indicator=".project-root")) | |
| cfg.trainer.max_epochs = 1 | |
| cfg.trainer.limit_test_batches = 0.1 | |
| cfg.trainer.accelerator = "cpu" | |
| cfg.trainer.devices = 1 | |
| cfg.data.num_workers = 0 | |
| cfg.data.pin_memory = False | |
| cfg.extras.print_config = False | |
| cfg.extras.enforce_tags = False | |
| cfg.logger = None | |
| return cfg | |
| def cfg_train(cfg_train_global: DictConfig, tmp_path: Path) -> DictConfig: | |
| """A pytest fixture built on top of the `cfg_train_global()` fixture, which accepts a temporary | |
| logging path `tmp_path` for generating a temporary logging path. | |
| This is called by each test which uses the `cfg_train` arg. Each test generates its own temporary logging path. | |
| :param cfg_train_global: The input DictConfig object to be modified. | |
| :param tmp_path: The temporary logging path. | |
| :return: A DictConfig with updated output and log directories corresponding to `tmp_path`. | |
| """ | |
| cfg = cfg_train_global.copy() | |
| with open_dict(cfg): | |
| cfg.paths.output_dir = str(tmp_path) | |
| cfg.paths.log_dir = str(tmp_path) | |
| yield cfg | |
| GlobalHydra.instance().clear() | |
| def cfg_eval(cfg_eval_global: DictConfig, tmp_path: Path) -> DictConfig: | |
| """A pytest fixture built on top of the `cfg_eval_global()` fixture, which accepts a temporary | |
| logging path `tmp_path` for generating a temporary logging path. | |
| This is called by each test which uses the `cfg_eval` arg. Each test generates its own temporary logging path. | |
| :param cfg_train_global: The input DictConfig object to be modified. | |
| :param tmp_path: The temporary logging path. | |
| :return: A DictConfig with updated output and log directories corresponding to `tmp_path`. | |
| """ | |
| cfg = cfg_eval_global.copy() | |
| with open_dict(cfg): | |
| cfg.paths.output_dir = str(tmp_path) | |
| cfg.paths.log_dir = str(tmp_path) | |
| yield cfg | |
| GlobalHydra.instance().clear() | |