earlab commited on
Commit
62d2872
·
verified ·
1 Parent(s): ca2fe59

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +20 -10
README.md CHANGED
@@ -78,8 +78,8 @@ cd EAR_VAE2
78
  # Install dependencies
79
  pip install -r requirements.txt
80
 
81
- # Download pretrained weights (coming soon)
82
- # huggingface-cli download eps-acoustic-revolution-lab/ear-vae2-small --local-dir checkpoints/
83
  ```
84
 
85
  ## Usage
@@ -87,17 +87,22 @@ pip install -r requirements.txt
87
  ### Python API
88
 
89
  ```python
 
90
  import torch
 
91
  from ear_vae2 import EarVAE2
92
 
93
- # Load model (full model, with refiner — see configs/ear_vae2.json)
94
- config = {
95
- "C0": 64, "D": 128, "use_vae": True,
96
- "refiner": {"type": "banded", "dim": 256, "intermediate_dim": 1024,
97
- "num_layers": 12, "layer_norm_eps": 1e-5},
98
- }
 
 
 
99
  model = EarVAE2(config)
100
- ckpt = torch.load("ear_vae2.pt", map_location="cpu")
101
  model.load_state_dict(ckpt["gen"] if "gen" in ckpt else ckpt)
102
  model.eval().cuda()
103
 
@@ -111,8 +116,13 @@ reconstructed = reconstructed[:, :, :orig_len]
111
 
112
  ### Command Line
113
 
 
 
114
  ```bash
115
- python inference.py --checkpoint ear_vae2.pt --config configs/ear_vae2.json --input input.wav --output output.wav
 
 
 
116
  ```
117
 
118
 
 
78
  # Install dependencies
79
  pip install -r requirements.txt
80
 
81
+ # Download config + pretrained weights from the Hub
82
+ huggingface-cli download earlab/EAR_VAE2 --local-dir checkpoints/
83
  ```
84
 
85
  ## Usage
 
87
  ### Python API
88
 
89
  ```python
90
+ import json
91
  import torch
92
+ from huggingface_hub import hf_hub_download
93
  from ear_vae2 import EarVAE2
94
 
95
+ REPO_ID = "earlab/EAR_VAE2"
96
+
97
+ # Resolve config and weights from the Hub (cached locally after the first call)
98
+ config_path = hf_hub_download(REPO_ID, "config.json")
99
+ ckpt_path = hf_hub_download(REPO_ID, "weights/ear_vae2.pt")
100
+
101
+ with open(config_path) as f:
102
+ config = json.load(f)["model"]["gen"]["config"]
103
+
104
  model = EarVAE2(config)
105
+ ckpt = torch.load(ckpt_path, map_location="cpu")
106
  model.load_state_dict(ckpt["gen"] if "gen" in ckpt else ckpt)
107
  model.eval().cuda()
108
 
 
116
 
117
  ### Command Line
118
 
119
+ Using the `checkpoints/` directory populated in the Installation step:
120
+
121
  ```bash
122
+ python inference.py \
123
+ --checkpoint checkpoints/weights/ear_vae2.pt \
124
+ --config checkpoints/config.json \
125
+ --input input.wav --output output.wav
126
  ```
127
 
128