topel commited on
Commit
1b66305
1 Parent(s): 1e97b39

Update Readme

Browse files
Files changed (1) hide show
  1. README.md +15 -3
README.md CHANGED
@@ -46,6 +46,7 @@ import torch
46
  import torchaudio
47
 
48
  from audioset_convnext_inf.pytorch.convnext import ConvNeXt
 
49
 
50
  model = ConvNeXt.from_pretrained("topel/ConvNeXt-Tiny-AT", use_auth_token="ACCESS_TOKEN_GOES_HERE", map_location='cpu')
51
 
@@ -95,19 +96,30 @@ probs = output["clipwise_output"]
95
  # Equivalent: probs = torch.sigmoid(logits)
96
  print("probs size:", probs.size())
97
 
 
 
 
98
  threshold = 0.25
99
  sample_labels = np.where(probs[0].clone().detach().cpu() > threshold)[0]
100
- print("Predicted labels using activity threshold 0.25:\n")
101
- print(sample_labels)
 
 
102
  ```
103
 
104
  Output:
105
  ```
106
  logits size: torch.Size([1, 527])
107
  probs size: torch.Size([1, 527])
 
108
  Predicted labels using activity threshold 0.25:
109
 
110
- [ 0 137 138 139 151 506]
 
 
 
 
 
111
  ```
112
 
113
 
 
46
  import torchaudio
47
 
48
  from audioset_convnext_inf.pytorch.convnext import ConvNeXt
49
+ from audioset_convnext_inf.utils.utilities import read_audioset_label_tags
50
 
51
  model = ConvNeXt.from_pretrained("topel/ConvNeXt-Tiny-AT", use_auth_token="ACCESS_TOKEN_GOES_HERE", map_location='cpu')
52
 
 
96
  # Equivalent: probs = torch.sigmoid(logits)
97
  print("probs size:", probs.size())
98
 
99
+ current_dir=os.getcwd()
100
+ lb_to_ix, ix_to_lb, id_to_ix, ix_to_id = read_audioset_label_tags(os.path.join(current_dir, "class_labels_indices.csv"))
101
+
102
  threshold = 0.25
103
  sample_labels = np.where(probs[0].clone().detach().cpu() > threshold)[0]
104
+ print("\nPredicted labels using activity threshold 0.25:\n")
105
+ # print(sample_labels)
106
+ for l in sample_labels:
107
+ print("%s: %.3f"%(ix_to_lb[l], probs[0,l]))
108
  ```
109
 
110
  Output:
111
  ```
112
  logits size: torch.Size([1, 527])
113
  probs size: torch.Size([1, 527])
114
+
115
  Predicted labels using activity threshold 0.25:
116
 
117
+ Speech: 0.626
118
+ Music: 0.842
119
+ Musical instrument: 0.362
120
+ Plucked string instrument: 0.307
121
+ Ukulele: 0.703
122
+ Inside, small room: 0.305
123
  ```
124
 
125