davesalvi commited on
Commit
e309e64
·
1 Parent(s): a5c90ab

update script.py

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. .idea/misc.xml +3 -0
  3. .idea/workspace.xml +20 -19
  4. script.py +25 -13
.gitignore CHANGED
@@ -1,6 +1,8 @@
1
  # Ignore weights
2
  checkpoints/RAWNET_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth
3
 
 
 
4
  # Byte-compiled / optimized / DLL files
5
  __pycache__/
6
  *.py[cod]
 
1
  # Ignore weights
2
  checkpoints/RAWNET_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth
3
 
4
+ .idea
5
+
6
  # Byte-compiled / optimized / DLL files
7
  __pycache__/
8
  *.py[cod]
.idea/misc.xml CHANGED
@@ -1,4 +1,7 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <project version="4">
 
 
 
3
  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
4
  </project>
 
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <project version="4">
3
+ <component name="Black">
4
+ <option name="sdkName" value="Python 3.9" />
5
+ </component>
6
  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
7
  </project>
.idea/workspace.xml CHANGED
@@ -5,8 +5,9 @@
5
  </component>
6
  <component name="ChangeListManager">
7
  <list default="true" id="23565123-73ab-4f40-a9ef-1086e0c9e1ec" name="Changes" comment="">
8
- <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/test.py" beforeDir="false" />
 
10
  </list>
11
  <option name="SHOW_DIALOG" value="false" />
12
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -30,29 +31,29 @@
30
  <component name="MarkdownSettingsMigration">
31
  <option name="stateVersion" value="1" />
32
  </component>
33
- <component name="ProjectColorInfo"><![CDATA[{
34
- "associatedIndex": 8
35
- }]]></component>
36
  <component name="ProjectId" id="2udL9TBw08aLOM9GtJKtPFHLCAg" />
37
  <component name="ProjectViewState">
38
  <option name="hideEmptyMiddlePackages" value="true" />
39
  <option name="showLibraryContents" value="true" />
40
  </component>
41
- <component name="PropertiesComponent"><![CDATA[{
42
- "keyToString": {
43
- "RunOnceActivity.OpenProjectViewOnStart": "true",
44
- "RunOnceActivity.ShowReadmeOnStart": "true",
45
- "WebServerToolWindowFactoryState": "true",
46
- "last_opened_file_path": "/Users/davidesalvi/Desktop/PHD/projects/polimi-ispl/ispl_safe",
47
- "node.js.detected.package.eslint": "true",
48
- "node.js.detected.package.tslint": "true",
49
- "node.js.selected.package.eslint": "(autodetect)",
50
- "node.js.selected.package.tslint": "(autodetect)",
51
- "nodejs_package_manager_path": "npm",
52
- "settings.editor.selected.configurable": "web.server",
53
- "vue.rearranger.settings.migration": "true"
54
  }
55
- }]]></component>
56
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
57
  <component name="TaskManager">
58
  <task active="true" id="Default" summary="Default task">
 
5
  </component>
6
  <component name="ChangeListManager">
7
  <list default="true" id="23565123-73ab-4f40-a9ef-1086e0c9e1ec" name="Changes" comment="">
8
+ <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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" />
13
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
 
31
  <component name="MarkdownSettingsMigration">
32
  <option name="stateVersion" value="1" />
33
  </component>
34
+ <component name="ProjectColorInfo">{
35
+ &quot;associatedIndex&quot;: 8
36
+ }</component>
37
  <component name="ProjectId" id="2udL9TBw08aLOM9GtJKtPFHLCAg" />
38
  <component name="ProjectViewState">
39
  <option name="hideEmptyMiddlePackages" value="true" />
40
  <option name="showLibraryContents" value="true" />
41
  </component>
42
+ <component name="PropertiesComponent">{
43
+ &quot;keyToString&quot;: {
44
+ &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
45
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
46
+ &quot;WebServerToolWindowFactoryState&quot;: &quot;true&quot;,
47
+ &quot;last_opened_file_path&quot;: &quot;/Users/davidesalvi/Desktop/PHD/projects/polimi-ispl/ispl_safe&quot;,
48
+ &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
49
+ &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
50
+ &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
51
+ &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
52
+ &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
53
+ &quot;settings.editor.selected.configurable&quot;: &quot;web.server&quot;,
54
+ &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
55
  }
56
+ }</component>
57
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
58
  <component name="TaskManager">
59
  <task active="true" id="Default" summary="Default task">
script.py CHANGED
@@ -1,22 +1,24 @@
1
- import pandas as pd
2
- from datasets import load_dataset
3
- import numpy as np
4
- import tqdm.auto as tqdm
5
- import os
6
  import io
7
- import torch
8
  import time
9
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Import your model and anything else you want
11
  # You can even install other packages included in your repo
12
- # However, during the evaluation the container will not have access to the internet.
13
  # So you must include everything you need in your model repo. Common python libraries will be installed.
14
  # Feel free to contact us to add dependencies to the requiremnts.txt
15
- # For testing, this is the docker image that will be used https://github.com/huggingface/competitions/blob/main/Dockerfile
16
- # It can be pulled here https://hub.docker.com/r/huggingface/competitions/tags
17
-
18
- from models import Model
19
- from preprocess import preprocess
20
 
21
 
22
  # load the dataset. dataset will be automatically downloaded to /tmp/data during evaluation
@@ -26,8 +28,18 @@ dataset_remote = load_dataset(DATASET_PATH,split = "test",streaming = True)
26
 
27
  # load your model
28
  device = "cuda:0"
29
- model = Model().to(device)
30
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # iterate over the dataset
33
  out = []
 
 
 
 
 
 
1
  import io
 
2
  import time
3
 
4
+ import torch
5
+ import tqdm.auto as tqdm
6
+ from datasets import load_dataset
7
+
8
+ from models import Model
9
+ from preprocess import preprocess
10
+ from pathlib import Path
11
+
12
+ from src.rawnet_model import RawNet
13
+ from src.utils import *
14
+
15
  # Import your model and anything else you want
16
  # You can even install other packages included in your repo
17
+ # However, during the evaluation the container will not have access to the internet.
18
  # So you must include everything you need in your model repo. Common python libraries will be installed.
19
  # Feel free to contact us to add dependencies to the requiremnts.txt
20
+ # For testing, this is the docker image that will be used https://github.com/huggingface/competitions/blob/main/Dockerfile
21
+ # It can be pulled here https://hub.docker.com/r/huggingface/competitions/tags
 
 
 
22
 
23
 
24
  # load the dataset. dataset will be automatically downloaded to /tmp/data during evaluation
 
28
 
29
  # load your model
30
  device = "cuda:0"
 
31
 
32
+ # DEFINE RAWNET2 MODEL
33
+ this_folder = Path(__file__).parent
34
+ config_path = this_folder / 'config' / 'rawnet_config.yaml'
35
+ config = read_yaml(config_path)
36
+ model = RawNet(config['model'], device)
37
+
38
+ model_path = this_folder / 'checkpoints' / 'RAWNET_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth'
39
+ model.load_state_dict(torch.load(model_path, map_location=device))
40
+
41
+ # Define old model
42
+ model = Model().to(device)
43
 
44
  # iterate over the dataset
45
  out = []