debug
Browse files- .idea/workspace.xml +2 -1
- preprocess.py +2 -2
- script.py +12 -11
.idea/workspace.xml
CHANGED
|
@@ -6,6 +6,7 @@
|
|
| 6 |
<component name="ChangeListManager">
|
| 7 |
<list default="true" id="23565123-73ab-4f40-a9ef-1086e0c9e1ec" name="Changes" comment="">
|
| 8 |
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
|
|
| 9 |
<change beforePath="$PROJECT_DIR$/script.py" beforeDir="false" afterPath="$PROJECT_DIR$/script.py" afterDir="false" />
|
| 10 |
</list>
|
| 11 |
<option name="SHOW_DIALOG" value="false" />
|
|
@@ -99,7 +100,7 @@
|
|
| 99 |
<updated>1742573353560</updated>
|
| 100 |
<workItem from="1742573355153" duration="587000" />
|
| 101 |
<workItem from="1742806974298" duration="2741000" />
|
| 102 |
-
<workItem from="1742810431420" duration="
|
| 103 |
</task>
|
| 104 |
<servers />
|
| 105 |
</component>
|
|
|
|
| 6 |
<component name="ChangeListManager">
|
| 7 |
<list default="true" id="23565123-73ab-4f40-a9ef-1086e0c9e1ec" name="Changes" comment="">
|
| 8 |
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
| 9 |
+
<change beforePath="$PROJECT_DIR$/preprocess.py" beforeDir="false" afterPath="$PROJECT_DIR$/preprocess.py" afterDir="false" />
|
| 10 |
<change beforePath="$PROJECT_DIR$/script.py" beforeDir="false" afterPath="$PROJECT_DIR$/script.py" afterDir="false" />
|
| 11 |
</list>
|
| 12 |
<option name="SHOW_DIALOG" value="false" />
|
|
|
|
| 100 |
<updated>1742573353560</updated>
|
| 101 |
<workItem from="1742573355153" duration="587000" />
|
| 102 |
<workItem from="1742806974298" duration="2741000" />
|
| 103 |
+
<workItem from="1742810431420" duration="9891000" />
|
| 104 |
</task>
|
| 105 |
<servers />
|
| 106 |
</component>
|
preprocess.py
CHANGED
|
@@ -13,7 +13,7 @@ def pad_audio(x, max_len=48000):
|
|
| 13 |
return padded_x
|
| 14 |
|
| 15 |
|
| 16 |
-
def
|
| 17 |
print(f'Preprocessing {audio_file}')
|
| 18 |
# Load the audio file
|
| 19 |
y, sr = librosa.load(audio_file, sr=16000)
|
|
@@ -33,7 +33,7 @@ def preprocess_new(audio_file):
|
|
| 33 |
return tensor
|
| 34 |
|
| 35 |
|
| 36 |
-
def
|
| 37 |
# Load the audio file
|
| 38 |
y, sr = librosa.load(audio_file, sr=None)
|
| 39 |
mfccs = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=13)
|
|
|
|
| 13 |
return padded_x
|
| 14 |
|
| 15 |
|
| 16 |
+
def preprocess(audio_file):
|
| 17 |
print(f'Preprocessing {audio_file}')
|
| 18 |
# Load the audio file
|
| 19 |
y, sr = librosa.load(audio_file, sr=16000)
|
|
|
|
| 33 |
return tensor
|
| 34 |
|
| 35 |
|
| 36 |
+
def preprocess_old(audio_file):
|
| 37 |
# Load the audio file
|
| 38 |
y, sr = librosa.load(audio_file, sr=None)
|
| 39 |
mfccs = librosa.feature.mfcc(y=y, sr=sr, n_mfcc=13)
|
script.py
CHANGED
|
@@ -54,15 +54,16 @@ config = {
|
|
| 54 |
model = RawNet(config, device)
|
| 55 |
|
| 56 |
print('Load model weights')
|
| 57 |
-
model_path = '/tmp/checkpoints/RAWNET_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth'
|
| 58 |
-
model.load_state_dict(torch.load(model_path, map_location=device))
|
| 59 |
|
| 60 |
model.eval()
|
| 61 |
|
| 62 |
print('Loaded RawNet2 Weights')
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 66 |
|
| 67 |
# iterate over the dataset
|
| 68 |
out = []
|
|
@@ -90,13 +91,13 @@ for el in tqdm.tqdm(dataset_remote):
|
|
| 90 |
# positive score correspond to synthetic prediction
|
| 91 |
# negative score correspond to pristine prediction
|
| 92 |
|
| 93 |
-
# OLD MODEL
|
| 94 |
-
score = model(tensor.to(device)).cpu().item()
|
| 95 |
-
#
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
|
| 101 |
# we require a hard decision to be submited. so you need to pick a threshold
|
| 102 |
pred = "generated" if score > model.threshold else "pristine"
|
|
|
|
| 54 |
model = RawNet(config, device)
|
| 55 |
|
| 56 |
print('Load model weights')
|
| 57 |
+
# model_path = '/tmp/checkpoints/RAWNET_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth'
|
| 58 |
+
# model.load_state_dict(torch.load(model_path, map_location=device))
|
| 59 |
|
| 60 |
model.eval()
|
| 61 |
|
| 62 |
print('Loaded RawNet2 Weights')
|
| 63 |
|
| 64 |
+
# # EVALUATE OLD MODEL
|
| 65 |
+
# del model
|
| 66 |
+
# model = Model().to(device)
|
| 67 |
|
| 68 |
# iterate over the dataset
|
| 69 |
out = []
|
|
|
|
| 91 |
# positive score correspond to synthetic prediction
|
| 92 |
# negative score correspond to pristine prediction
|
| 93 |
|
| 94 |
+
# # OLD MODEL
|
| 95 |
+
# score = model(tensor.to(device)).cpu().item()
|
| 96 |
+
# RAWNNET2 MODEL
|
| 97 |
+
score = model(tensor.to(device))[:, 1].cpu()
|
| 98 |
+
print(f'SCORE OUT: {score}')
|
| 99 |
+
score = score.mean().item()
|
| 100 |
+
print(f'SCORE FINAL: {score}')
|
| 101 |
|
| 102 |
# we require a hard decision to be submited. so you need to pick a threshold
|
| 103 |
pred = "generated" if score > model.threshold else "pristine"
|