tlemagueresse
commited on
Commit
·
7b23ae2
1
Parent(s):
1583464
Update files for external import
Browse files
examples/chainsaw.wav
ADDED
Binary file (72 kB). View file
|
|
examples/environment.wav
ADDED
Binary file (72 kB). View file
|
|
example_usage_fastmodel.py → examples/example_usage_fastmodel.py
RENAMED
@@ -5,13 +5,13 @@ from codecarbon import EmissionsTracker
|
|
5 |
from datasets import load_dataset
|
6 |
from sklearn.metrics import accuracy_score
|
7 |
|
8 |
-
from
|
9 |
|
10 |
dataset = load_dataset("rfcx/frugalai")
|
11 |
train_dataset = dataset["train"]
|
12 |
test_dataset = dataset["test"]
|
13 |
tracker = EmissionsTracker(allow_multiple_runs=True)
|
14 |
-
with open("config.json", "r") as file:
|
15 |
config = json.load(file)
|
16 |
model = FastModel(
|
17 |
config["audio_processing_params"],
|
@@ -32,4 +32,4 @@ print(accuracy_score(true_label, predictions))
|
|
32 |
print("energy_consumed_wh", emissions_data.energy_consumed * 1000)
|
33 |
print("emissions_gco2eq", emissions_data.emissions * 1000)
|
34 |
|
35 |
-
save_pipeline(model, Path("
|
|
|
5 |
from datasets import load_dataset
|
6 |
from sklearn.metrics import accuracy_score
|
7 |
|
8 |
+
from model import FastModel, save_pipeline
|
9 |
|
10 |
dataset = load_dataset("rfcx/frugalai")
|
11 |
train_dataset = dataset["train"]
|
12 |
test_dataset = dataset["test"]
|
13 |
tracker = EmissionsTracker(allow_multiple_runs=True)
|
14 |
+
with open("../config.json", "r") as file:
|
15 |
config = json.load(file)
|
16 |
model = FastModel(
|
17 |
config["audio_processing_params"],
|
|
|
32 |
print("energy_consumed_wh", emissions_data.energy_consumed * 1000)
|
33 |
print("emissions_gco2eq", emissions_data.emissions * 1000)
|
34 |
|
35 |
+
save_pipeline(model, Path("../"))
|
example_usage_fastmodel_hf.py → examples/example_usage_fastmodel_hf.py
RENAMED
@@ -1,12 +1,16 @@
|
|
1 |
from datasets import load_dataset
|
|
|
2 |
from sklearn.metrics import accuracy_score
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
10 |
|
11 |
# Perform predictions for a single WAV file
|
12 |
map_labels = {0: "chainsaw", 1: "environment"}
|
|
|
1 |
from datasets import load_dataset
|
2 |
+
from huggingface_hub import hf_hub_download
|
3 |
from sklearn.metrics import accuracy_score
|
4 |
+
import importlib.util
|
5 |
|
6 |
+
repo_id = "tlmk22/QuefrencyGuardian"
|
7 |
+
model_file = "model.py"
|
8 |
+
model_path = hf_hub_download(repo_id=repo_id, filename=model_file)
|
9 |
+
spec = importlib.util.spec_from_file_location("model", model_file)
|
10 |
+
fastmodel_module = importlib.util.module_from_spec(spec)
|
11 |
+
spec.loader.exec_module(fastmodel_module)
|
12 |
+
FastModelHuggingFace = fastmodel_module.FastModelHuggingFace
|
13 |
+
fast_model = FastModelHuggingFace.from_pretrained(repo_id)
|
14 |
|
15 |
# Perform predictions for a single WAV file
|
16 |
map_labels = {0: "chainsaw", 1: "environment"}
|
fast_model.py → model.py
RENAMED
File without changes
|