avex 0.5.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- avex/__init__.py +51 -0
- avex/api/__init__.py +1 -0
- avex/api/configs/__init__.py +0 -0
- avex/api/configs/official_models/BEATs_iter3_plus_AS2M.yml +17 -0
- avex/api/configs/official_models/BEATs_iter3_plus_AS2M_finetuned_on_AS2M_cpt2.yml +17 -0
- avex/api/configs/official_models/__init__.py +1 -0
- avex/api/configs/official_models/esp_aves2_eat_all.yml +17 -0
- avex/api/configs/official_models/esp_aves2_eat_bio.yml +17 -0
- avex/api/configs/official_models/esp_aves2_effnetb0_all.yml +22 -0
- avex/api/configs/official_models/esp_aves2_effnetb0_audioset.yml +21 -0
- avex/api/configs/official_models/esp_aves2_effnetb0_bio.yml +22 -0
- avex/api/configs/official_models/esp_aves2_naturelm_audio_v1_beats.yml +16 -0
- avex/api/configs/official_models/esp_aves2_sl_beats_all.yml +19 -0
- avex/api/configs/official_models/esp_aves2_sl_beats_bio.yml +17 -0
- avex/api/configs/official_models/esp_aves2_sl_eat_all_ssl_all.yml +18 -0
- avex/api/configs/official_models/esp_aves2_sl_eat_bio_ssl_all.yml +18 -0
- avex/api/list_models.py +73 -0
- avex/cli.py +79 -0
- avex/configs.py +1349 -0
- avex/data/__init__.py +27 -0
- avex/data/animalspeak_column_patch.py +124 -0
- avex/data/audio_utils.py +341 -0
- avex/data/augmentations.py +541 -0
- avex/data/cloudpathlib_retry_patch.py +104 -0
- avex/data/configs.py +232 -0
- avex/data/data_utils.py +116 -0
- avex/data/dataset.py +623 -0
- avex/data/text_label_from_features.py +141 -0
- avex/data/transforms.py +284 -0
- avex/evaluation/__init__.py +0 -0
- avex/evaluation/clustering.py +221 -0
- avex/evaluation/embedding_manager.py +404 -0
- avex/evaluation/embedding_utils.py +1572 -0
- avex/evaluation/finetune.py +799 -0
- avex/evaluation/retrieval.py +662 -0
- avex/io/__init__.py +49 -0
- avex/io/file_utils.py +50 -0
- avex/io/filesystem.py +89 -0
- avex/io/paths.py +178 -0
- avex/metrics/__init__.py +0 -0
- avex/metrics/beans_metrics.py +324 -0
- avex/metrics/metric_factory.py +48 -0
- avex/metrics/sklearn_metrics.py +393 -0
- avex/models/__init__.py +0 -0
- avex/models/atst_frame/__init__.py +31 -0
- avex/models/atst_frame/atst_encoder.py +162 -0
- avex/models/atst_frame/atst_frame.py +1901 -0
- avex/models/aves_model.py +280 -0
- avex/models/base_model.py +387 -0
- avex/models/beats/__init__.py +30 -0
- avex/models/beats/backbone.py +906 -0
- avex/models/beats/beats.py +267 -0
- avex/models/beats/modules.py +343 -0
- avex/models/beats_model.py +406 -0
- avex/models/birdmae.py +267 -0
- avex/models/birdnet.py +560 -0
- avex/models/clip.py +189 -0
- avex/models/eat/__init__.py +4 -0
- avex/models/eat/audio_processor.py +143 -0
- avex/models/eat_hf.py +436 -0
- avex/models/efficientnet.py +342 -0
- avex/models/get_model.py +182 -0
- avex/models/perch.py +332 -0
- avex/models/probes/__init__.py +28 -0
- avex/models/probes/attention_probe.py +141 -0
- avex/models/probes/base_probes.py +414 -0
- avex/models/probes/embedding_projectors.py +565 -0
- avex/models/probes/linear_probe.py +84 -0
- avex/models/probes/lstm_probe.py +126 -0
- avex/models/probes/mlp_probe.py +110 -0
- avex/models/probes/transformer_probe.py +131 -0
- avex/models/probes/utils/__init__.py +22 -0
- avex/models/probes/utils/factory.py +186 -0
- avex/models/probes/utils/registry.py +93 -0
- avex/models/resnet.py +157 -0
- avex/models/surfperch.py +334 -0
- avex/models/utils/__init__.py +39 -0
- avex/models/utils/factory.py +165 -0
- avex/models/utils/load.py +559 -0
- avex/models/utils/registry.py +694 -0
- avex/preprocessing/__init__.py +0 -0
- avex/preprocessing/activity_detector.py +0 -0
- avex/preprocessing/preprocessor_base.py +0 -0
- avex/run_evaluate.py +1084 -0
- avex/run_train.py +181 -0
- avex/training/__init__.py +0 -0
- avex/training/checkpoint_manager.py +263 -0
- avex/training/clustering_evaluator.py +251 -0
- avex/training/distributed.py +328 -0
- avex/training/losses.py +358 -0
- avex/training/metrics_tracker.py +250 -0
- avex/training/optimisers.py +107 -0
- avex/training/train.py +751 -0
- avex/training/trainer_factory.py +180 -0
- avex/training/training_strategies.py +301 -0
- avex/training/training_utils.py +74 -0
- avex/utils/__init__.py +15 -0
- avex/utils/experiment_logger.py +223 -0
- avex/utils/experiment_tracking.py +755 -0
- avex/utils/utils.py +309 -0
- avex-0.5.0a1.dist-info/METADATA +259 -0
- avex-0.5.0a1.dist-info/RECORD +104 -0
- avex-0.5.0a1.dist-info/WHEEL +4 -0
- avex-0.5.0a1.dist-info/entry_points.txt +4 -0
avex/__init__.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Representation Learning Framework
|
|
3
|
+
|
|
4
|
+
A comprehensive Python-based system for training, evaluating, and analyzing
|
|
5
|
+
audio representation learning models with support for both supervised and
|
|
6
|
+
self-supervised learning paradigms.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from importlib.metadata import version
|
|
10
|
+
|
|
11
|
+
from .models.utils.factory import (
|
|
12
|
+
build_model,
|
|
13
|
+
build_model_from_spec,
|
|
14
|
+
)
|
|
15
|
+
from .models.utils.load import load_label_mapping, load_model
|
|
16
|
+
from .models.utils.registry import (
|
|
17
|
+
describe_model,
|
|
18
|
+
get_checkpoint_path,
|
|
19
|
+
get_model_class,
|
|
20
|
+
get_model_spec,
|
|
21
|
+
list_model_classes,
|
|
22
|
+
list_model_layers,
|
|
23
|
+
list_models,
|
|
24
|
+
register_model,
|
|
25
|
+
register_model_class,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__version__ = version("avex")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
# Model loading
|
|
33
|
+
"load_model",
|
|
34
|
+
# Registry management
|
|
35
|
+
"register_model",
|
|
36
|
+
"get_model_spec",
|
|
37
|
+
"list_models",
|
|
38
|
+
"describe_model",
|
|
39
|
+
"list_model_layers",
|
|
40
|
+
# Model class management
|
|
41
|
+
"register_model_class",
|
|
42
|
+
"get_model_class",
|
|
43
|
+
"list_model_classes",
|
|
44
|
+
# Model factory
|
|
45
|
+
"build_model",
|
|
46
|
+
"build_model_from_spec",
|
|
47
|
+
# Checkpoint management
|
|
48
|
+
"get_checkpoint_path",
|
|
49
|
+
# Label mapping management
|
|
50
|
+
"load_label_mapping",
|
|
51
|
+
]
|
avex/api/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""API module for representation learning."""
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
# BEATs iter3+AS2M SSL pretrained backbone
|
|
3
|
+
# Self-supervised learning checkpoint without fine-tuning
|
|
4
|
+
# Weights from HuggingFace: https://huggingface.co/lpepino/beats_ckpts
|
|
5
|
+
checkpoint_path: hf://lpepino/beats_ckpts/BEATs_iter3_plus_AS2M.pt
|
|
6
|
+
|
|
7
|
+
model_spec:
|
|
8
|
+
name: beats
|
|
9
|
+
pretrained: true
|
|
10
|
+
fine_tuned: false
|
|
11
|
+
device: cuda
|
|
12
|
+
audio_config:
|
|
13
|
+
sample_rate: 16000
|
|
14
|
+
representation: raw
|
|
15
|
+
normalize: false
|
|
16
|
+
target_length_seconds: 10
|
|
17
|
+
window_selection: random
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
# BEATs iter3+AS2M fine-tuned backbone
|
|
3
|
+
# Fine-tuned on AudioSet 2M classification
|
|
4
|
+
# Weights from HuggingFace: https://huggingface.co/THUdyh/Ola_speech_encoders
|
|
5
|
+
checkpoint_path: hf://THUdyh/Ola_speech_encoders/BEATs_iter3_plus_AS2M_finetuned_on_AS2M_cpt2.pt
|
|
6
|
+
|
|
7
|
+
model_spec:
|
|
8
|
+
name: beats
|
|
9
|
+
pretrained: true
|
|
10
|
+
fine_tuned: true
|
|
11
|
+
device: cuda
|
|
12
|
+
audio_config:
|
|
13
|
+
sample_rate: 16000
|
|
14
|
+
representation: raw
|
|
15
|
+
normalize: false
|
|
16
|
+
target_length_seconds: 10
|
|
17
|
+
window_selection: random
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Official model configurations."""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: EAT trained on all (AudioSet + bio) data.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-eat-all/esp-aves2-eat-all.safetensors
|
|
5
|
+
|
|
6
|
+
model_spec:
|
|
7
|
+
name: eat_hf
|
|
8
|
+
pretrained: false
|
|
9
|
+
device: cuda
|
|
10
|
+
eat_norm_mean: -5.553
|
|
11
|
+
eat_norm_std: 4.606
|
|
12
|
+
audio_config:
|
|
13
|
+
sample_rate: 16000
|
|
14
|
+
representation: raw
|
|
15
|
+
normalize: false
|
|
16
|
+
target_length_seconds: 10
|
|
17
|
+
window_selection: random
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: EAT trained on bio data.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-eat-bio/esp-aves2-eat-bio.safetensors
|
|
5
|
+
|
|
6
|
+
model_spec:
|
|
7
|
+
name: eat_hf
|
|
8
|
+
pretrained: false
|
|
9
|
+
device: cuda
|
|
10
|
+
eat_norm_mean: -5.553
|
|
11
|
+
eat_norm_std: 4.606
|
|
12
|
+
audio_config:
|
|
13
|
+
sample_rate: 16000
|
|
14
|
+
representation: raw
|
|
15
|
+
normalize: false
|
|
16
|
+
target_length_seconds: 10
|
|
17
|
+
window_selection: random
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: EfficientNet B0 trained on all (AudioSet + bio) data.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-effnetb0-all/esp-aves2-effnetb0-all.safetensors
|
|
5
|
+
class_mapping_path: hf://EarthSpeciesProject/esp-aves2-effnetb0-all/label_map.json
|
|
6
|
+
|
|
7
|
+
model_spec:
|
|
8
|
+
name: efficientnet
|
|
9
|
+
pretrained: false
|
|
10
|
+
device: cuda
|
|
11
|
+
efficientnet_variant: b0
|
|
12
|
+
audio_config:
|
|
13
|
+
sample_rate: 16000
|
|
14
|
+
n_fft: 800
|
|
15
|
+
hop_length: 160
|
|
16
|
+
win_length: 800
|
|
17
|
+
window: hann
|
|
18
|
+
n_mels: 128
|
|
19
|
+
representation: mel_spectrogram
|
|
20
|
+
normalize: true
|
|
21
|
+
target_length_seconds: 10
|
|
22
|
+
window_selection: random
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: EfficientNet B0 trained on AudioSet.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-effnetb0-audioset/esp-aves2-effnetb0-audioset.safetensors
|
|
5
|
+
|
|
6
|
+
model_spec:
|
|
7
|
+
name: efficientnet
|
|
8
|
+
pretrained: false
|
|
9
|
+
device: cuda
|
|
10
|
+
efficientnet_variant: b0
|
|
11
|
+
audio_config:
|
|
12
|
+
sample_rate: 16000
|
|
13
|
+
n_fft: 800
|
|
14
|
+
hop_length: 160
|
|
15
|
+
win_length: 800
|
|
16
|
+
window: hann
|
|
17
|
+
n_mels: 128
|
|
18
|
+
representation: mel_spectrogram
|
|
19
|
+
normalize: true
|
|
20
|
+
target_length_seconds: 10
|
|
21
|
+
window_selection: random
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: EfficientNet B0 trained on bio data.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-effnetb0-bio/esp-aves2-effnetb0-bio.safetensors
|
|
5
|
+
class_mapping_path: hf://EarthSpeciesProject/esp-aves2-effnetb0-bio/label_map.json
|
|
6
|
+
|
|
7
|
+
model_spec:
|
|
8
|
+
name: efficientnet
|
|
9
|
+
pretrained: false
|
|
10
|
+
device: cuda
|
|
11
|
+
efficientnet_variant: b0
|
|
12
|
+
audio_config:
|
|
13
|
+
sample_rate: 16000
|
|
14
|
+
n_fft: 800
|
|
15
|
+
hop_length: 160
|
|
16
|
+
win_length: 800
|
|
17
|
+
window: hann
|
|
18
|
+
n_mels: 128
|
|
19
|
+
representation: mel_spectrogram
|
|
20
|
+
normalize: true
|
|
21
|
+
target_length_seconds: 10
|
|
22
|
+
window_selection: random
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: BEATs with NatureLM (audio v1).
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-naturelm-audio-v1-beats/esp-aves2-naturelm-audio-v1-beats.safetensors
|
|
5
|
+
|
|
6
|
+
model_spec:
|
|
7
|
+
name: beats
|
|
8
|
+
pretrained: false
|
|
9
|
+
device: cuda
|
|
10
|
+
use_naturelm: true
|
|
11
|
+
audio_config:
|
|
12
|
+
sample_rate: 16000
|
|
13
|
+
representation: raw
|
|
14
|
+
normalize: false
|
|
15
|
+
target_length_seconds: 10
|
|
16
|
+
window_selection: random
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: Supervised/linear-probe BEATs (all) model.
|
|
3
|
+
#
|
|
4
|
+
# Weights are hosted on the Hugging Face Hub as a safetensors file.
|
|
5
|
+
# The loader supports `hf://` URIs via huggingface_hub's fsspec filesystem.
|
|
6
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-sl-beats-all/esp-aves2-sl-beats-all.safetensors
|
|
7
|
+
class_mapping_path: hf://EarthSpeciesProject/esp-aves2-sl-beats-all/label_map.json
|
|
8
|
+
|
|
9
|
+
model_spec:
|
|
10
|
+
name: beats
|
|
11
|
+
pretrained: false
|
|
12
|
+
fine_tuned: true
|
|
13
|
+
device: cuda
|
|
14
|
+
audio_config:
|
|
15
|
+
sample_rate: 16000
|
|
16
|
+
representation: raw
|
|
17
|
+
normalize: false
|
|
18
|
+
target_length_seconds: 10
|
|
19
|
+
window_selection: random
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: Supervised/linear-probe BEATs (bio) model.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-sl-beats-bio/esp-aves2-sl-beats-bio.safetensors
|
|
5
|
+
class_mapping_path: hf://EarthSpeciesProject/esp-aves2-sl-beats-bio/label_map.json
|
|
6
|
+
|
|
7
|
+
model_spec:
|
|
8
|
+
name: beats
|
|
9
|
+
pretrained: false
|
|
10
|
+
fine_tuned: true
|
|
11
|
+
device: cuda
|
|
12
|
+
audio_config:
|
|
13
|
+
sample_rate: 16000
|
|
14
|
+
representation: raw
|
|
15
|
+
normalize: false
|
|
16
|
+
target_length_seconds: 10
|
|
17
|
+
window_selection: random
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: EAT SSL (all data) + linear head.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-sl-eat-all-ssl-all/esp-aves2-sl-eat-all-ssl-all.safetensors
|
|
5
|
+
class_mapping_path: hf://EarthSpeciesProject/esp-aves2-sl-eat-all-ssl-all/label_map.json
|
|
6
|
+
|
|
7
|
+
model_spec:
|
|
8
|
+
name: eat_hf
|
|
9
|
+
pretrained: false
|
|
10
|
+
device: cuda
|
|
11
|
+
eat_norm_mean: -5.553
|
|
12
|
+
eat_norm_std: 4.606
|
|
13
|
+
audio_config:
|
|
14
|
+
sample_rate: 16000
|
|
15
|
+
representation: raw
|
|
16
|
+
normalize: false
|
|
17
|
+
target_length_seconds: 10
|
|
18
|
+
window_selection: random
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
# ESP-AVES2: EAT SSL (bio) + linear head.
|
|
3
|
+
# Weights on Hugging Face Hub (safetensors). Load via hf:// URIs.
|
|
4
|
+
checkpoint_path: hf://EarthSpeciesProject/esp-aves2-sl-eat-bio-ssl-all/esp-aves2-sl-eat-bio-ssl-all.safetensors
|
|
5
|
+
class_mapping_path: hf://EarthSpeciesProject/esp-aves2-sl-eat-bio-ssl-all/label_map.json
|
|
6
|
+
|
|
7
|
+
model_spec:
|
|
8
|
+
name: eat_hf
|
|
9
|
+
pretrained: false
|
|
10
|
+
device: cuda
|
|
11
|
+
eat_norm_mean: -5.553
|
|
12
|
+
eat_norm_std: 4.606
|
|
13
|
+
audio_config:
|
|
14
|
+
sample_rate: 16000
|
|
15
|
+
representation: raw
|
|
16
|
+
normalize: false
|
|
17
|
+
target_length_seconds: 10
|
|
18
|
+
window_selection: random
|
avex/api/list_models.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CLI helper to list available models in the registry.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python -m avex.api.list_models
|
|
7
|
+
python -m avex.api.list_models --detailed
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
import click
|
|
13
|
+
|
|
14
|
+
from avex.models.utils.registry import list_models
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def print_models(detailed: bool = False) -> None:
|
|
18
|
+
"""Print available models in the registry.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
detailed: If True, show detailed model information
|
|
22
|
+
"""
|
|
23
|
+
models = list_models()
|
|
24
|
+
|
|
25
|
+
if not models:
|
|
26
|
+
print("No models registered in the registry.")
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
print(f"Available models ({len(models)}):")
|
|
30
|
+
print("=" * 50)
|
|
31
|
+
|
|
32
|
+
for name, model_spec in models.items():
|
|
33
|
+
print(f"\nš¦ {name}")
|
|
34
|
+
|
|
35
|
+
if detailed:
|
|
36
|
+
print(f" Name: {model_spec.name}")
|
|
37
|
+
print(f" Pretrained: {model_spec.pretrained}")
|
|
38
|
+
print(f" Device: {model_spec.device}")
|
|
39
|
+
|
|
40
|
+
if hasattr(model_spec, "audio_config") and model_spec.audio_config:
|
|
41
|
+
audio_cfg = model_spec.audio_config
|
|
42
|
+
print(" Audio Config:")
|
|
43
|
+
print(f" Sample Rate: {audio_cfg.sample_rate}")
|
|
44
|
+
print(f" Representation: {audio_cfg.representation}")
|
|
45
|
+
print(f" Target Length: {audio_cfg.target_length_seconds}s")
|
|
46
|
+
print(f" Normalize: {audio_cfg.normalize}")
|
|
47
|
+
|
|
48
|
+
if hasattr(model_spec, "use_naturelm"):
|
|
49
|
+
print(f" NatureLM: {model_spec.use_naturelm}")
|
|
50
|
+
else:
|
|
51
|
+
# Simple format
|
|
52
|
+
pretrained_str = "ā" if model_spec.pretrained else "ā"
|
|
53
|
+
print(f" Pretrained: {pretrained_str} | Device: {model_spec.device}")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@click.command()
|
|
57
|
+
@click.option(
|
|
58
|
+
"--detailed",
|
|
59
|
+
"-d",
|
|
60
|
+
is_flag=True,
|
|
61
|
+
help="Show detailed model information",
|
|
62
|
+
)
|
|
63
|
+
def main(detailed: bool) -> None:
|
|
64
|
+
"""List available models in the representation learning registry."""
|
|
65
|
+
try:
|
|
66
|
+
print_models(detailed=detailed)
|
|
67
|
+
except Exception as e:
|
|
68
|
+
click.echo(f"Error listing models: {e}", err=True)
|
|
69
|
+
sys.exit(1)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
main()
|
avex/cli.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command-line interface for representation learning experiments.
|
|
3
|
+
|
|
4
|
+
This module provides a unified CLI for both training and evaluation tasks.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import os
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
import click
|
|
12
|
+
|
|
13
|
+
# Get log level from environment variable, default to INFO
|
|
14
|
+
log_level = os.environ.get("LOG_LEVEL", "INFO").upper()
|
|
15
|
+
numeric_level = getattr(logging, log_level, logging.INFO)
|
|
16
|
+
|
|
17
|
+
logging.basicConfig(
|
|
18
|
+
level=numeric_level,
|
|
19
|
+
format="%(asctime)s | %(levelname)s | %(name)s: %(message)s",
|
|
20
|
+
datefmt="%Y-%m-%d %H:%M:%S",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@click.group()
|
|
27
|
+
def cli() -> None:
|
|
28
|
+
"""Representation learning CLI for training and evaluation."""
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@cli.command()
|
|
33
|
+
@click.option(
|
|
34
|
+
"--config",
|
|
35
|
+
"-c",
|
|
36
|
+
type=click.Path(exists=True, path_type=Path),
|
|
37
|
+
default="configs/run_configs/clip_base.yml",
|
|
38
|
+
help="Path to the training config file",
|
|
39
|
+
)
|
|
40
|
+
@click.option(
|
|
41
|
+
"--patch",
|
|
42
|
+
"-p",
|
|
43
|
+
"patches",
|
|
44
|
+
type=str,
|
|
45
|
+
multiple=True,
|
|
46
|
+
help="Patch config values in format 'key=value'. Can be used multiple times.",
|
|
47
|
+
)
|
|
48
|
+
def train(config: Path, patches: tuple[str, ...]) -> None:
|
|
49
|
+
"""Train an audio representation model."""
|
|
50
|
+
from avex.run_train import main as train_main
|
|
51
|
+
|
|
52
|
+
train_main(config_path=config, patches=patches)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@cli.command()
|
|
56
|
+
@click.option(
|
|
57
|
+
"--config",
|
|
58
|
+
"-c",
|
|
59
|
+
type=click.Path(exists=True, path_type=Path),
|
|
60
|
+
required=True,
|
|
61
|
+
help="Path to evaluation config file",
|
|
62
|
+
)
|
|
63
|
+
@click.option(
|
|
64
|
+
"--patch",
|
|
65
|
+
"-p",
|
|
66
|
+
"patches",
|
|
67
|
+
type=str,
|
|
68
|
+
multiple=True,
|
|
69
|
+
help="Patch config values in format 'key=value'. Can be used multiple times.",
|
|
70
|
+
)
|
|
71
|
+
def evaluate(config: Path, patches: tuple[str, ...]) -> None:
|
|
72
|
+
"""Run linear-probe / fine-tuning experiments."""
|
|
73
|
+
from avex.run_evaluate import main as eval_main
|
|
74
|
+
|
|
75
|
+
eval_main(config_path=config, patches=patches)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
cli()
|