Update README.md
Browse files
README.md
CHANGED
|
@@ -78,8 +78,8 @@ cd EAR_VAE2
|
|
| 78 |
# Install dependencies
|
| 79 |
pip install -r requirements.txt
|
| 80 |
|
| 81 |
-
# Download pretrained weights
|
| 82 |
-
|
| 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 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
| 99 |
model = EarVAE2(config)
|
| 100 |
-
ckpt = torch.load(
|
| 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
|
|
|
|
|
|
|
|
|
|
| 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 |
|