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/test_eval.py from ltuncay/BEST-RQ-2: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/ltuncay/BEST-RQ-2/resolve/main/audio-embeddings/tests/test_eval.py
- Command line
-
hf download hf://ltuncay/BEST-RQ-2/audio-embeddings/tests/test_eval.py
-
curl -L -o test_eval.py https://huggingface.co/ltuncay/BEST-RQ-2/resolve/main/audio-embeddings/tests/test_eval.py
1.34 kB
| import os | |
| from pathlib import Path | |
| import pytest | |
| from hydra.core.hydra_config import HydraConfig | |
| from omegaconf import DictConfig, open_dict | |
| from src.eval import evaluate | |
| from src.train import train | |
| def test_train_eval( | |
| tmp_path: Path, cfg_train: DictConfig, cfg_eval: DictConfig | |
| ) -> None: | |
| """Tests training and evaluation by training for 1 epoch with `train.py` then evaluating with | |
| `eval.py`. | |
| :param tmp_path: The temporary logging path. | |
| :param cfg_train: A DictConfig containing a valid training configuration. | |
| :param cfg_eval: A DictConfig containing a valid evaluation configuration. | |
| """ | |
| assert str(tmp_path) == cfg_train.paths.output_dir == cfg_eval.paths.output_dir | |
| with open_dict(cfg_train): | |
| cfg_train.trainer.max_epochs = 1 | |
| cfg_train.test = True | |
| HydraConfig().set_config(cfg_train) | |
| train_metric_dict, _ = train(cfg_train) | |
| assert "last.ckpt" in os.listdir(tmp_path / "checkpoints") | |
| with open_dict(cfg_eval): | |
| cfg_eval.ckpt_path = str(tmp_path / "checkpoints" / "last.ckpt") | |
| HydraConfig().set_config(cfg_eval) | |
| test_metric_dict, _ = evaluate(cfg_eval) | |
| assert test_metric_dict["test/acc"] > 0.0 | |
| assert ( | |
| abs(train_metric_dict["test/acc"].item() - test_metric_dict["test/acc"].item()) | |
| < 0.001 | |
| ) | |