Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- Input: MFCC 13ch, length 100 → shape (B, 13, 100)
|
| 2 |
+
- Delta: (X - mean) / (std + 1e-8)
|
| 3 |
+
- Labels: see `labels.json` (index ↔ label 1:1)
|
| 4 |
+
|
| 5 |
+
## Usage
|
| 6 |
+
```python
|
| 7 |
+
import json, torch, numpy as np
|
| 8 |
+
from huggingface_hub import hf_hub_download
|
| 9 |
+
from importlib.machinery import SourceFileLoader
|
| 10 |
+
|
| 11 |
+
repo = "<USER>/audio-emotion-pytorch"
|
| 12 |
+
w = hf_hub_download(repo, "pytorch_model.pth")
|
| 13 |
+
m = hf_hub_download(repo, "model.py")
|
| 14 |
+
lab = hf_hub_download(repo, "labels.json")
|
| 15 |
+
|
| 16 |
+
labels = json.load(open(lab, encoding="utf-8"))
|
| 17 |
+
Model = SourceFileLoader("amodel", m).load_module().PyTorchAudioModel
|
| 18 |
+
|
| 19 |
+
model = Model(num_labels=len(labels)).eval()
|
| 20 |
+
state = torch.load(w, map_location="cpu")
|
| 21 |
+
model.load_state_dict(state)
|
| 22 |
+
# x: tensor (1,13,100) → probs = softmax(model(x), dim=1)
|