Skip to content

Commit

Permalink
[ADD] config file for filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCretois committed Jul 7, 2023
1 parent e29a450 commit dd6ffed
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CONFIG.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
######################################
# PATHS FOR THE DIFFERENT COMPONENTS #
######################################

# List of paths to initialise the model
path_tokenizer_file: "./assets/bpe_simple_vocab_16e6.txt.gz"
path_audioclip: './assets/AudioCLIP-Full-Training.pt'
path_snowmobile_model: "./assets/snowmobile_model.pth"
3 changes: 2 additions & 1 deletion analyze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ exec docker run \
--gpus all \
-v ./logs:/app/logs \
-v "$FOLDER_TO_EXPOSE":/data \
ghcr.io/ninanor/snowmobile_analyzer:main \
snowmobile \
--input /data/"$FILENAME"

#ghcr.io/ninanor/snowmobile_analyzer:main


8 changes: 7 additions & 1 deletion audioclip/model/custom_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@

from model import AudioCLIP

# Open the config file
import yaml
from yaml import FullLoader
with open("./CONFIG.yaml") as f:
cfg = yaml.load(f, Loader=FullLoader)

class CustomAudioCLIP(pl.LightningModule):
def __init__(self, num_target_classes, model_arguments=None):
super().__init__()
model_arguments = {} if model_arguments is None else model_arguments
self.aclp = AudioCLIP(pretrained=f'/app/assets/AudioCLIP-Full-Training.pt', **model_arguments)
self.aclp = AudioCLIP(pretrained=cfg["path_audioclip"], **model_arguments)
self.num_target_classes = num_target_classes
self._build_model()

Expand Down
8 changes: 7 additions & 1 deletion audioclip/utils/simple_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
import ftfy
import regex as re

# Open the config file
import yaml
from yaml import FullLoader
with open("./CONFIG.yaml") as f:
cfg = yaml.load(f, Loader=FullLoader)

@lru_cache()
def default_bpe():
return os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'assets', 'bpe_simple_vocab_16e6.txt.gz')
return cfg["path_tokenizer_file"]
#return os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'assets', 'bpe_simple_vocab_16e6.txt.gz')


@lru_cache()
Expand Down
19 changes: 19 additions & 0 deletions example/SNOWMOBILE_RESULTS/example_audio_ANALYZED.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
start_detection,end_detection,label,confidence,hr
0,3,1,0.97691464,0.19687336119166438
3,6,1,0.9611957,0.16774687365839228
6,9,1,0.9939383,0.36043088267512735
9,12,1,0.99498135,0.47373295662640913
12,15,1,0.99076325,0.3646539816725187
15,18,1,0.99004626,0.17752296324623074
21,24,1,0.999651,0.29822320508183836
24,27,1,0.99951804,0.3069427548594896
27,30,1,0.99987257,0.32149264560634827
30,33,1,0.9999827,0.3938179195958813
33,36,1,0.9997253,0.38632521474145276
36,39,1,0.9927994,0.685510328529914
39,42,1,0.9832097,0.5133540409044806
42,45,1,0.9991579,0.42189265222346845
45,48,1,0.99997604,0.17324206247276597
48,51,1,0.9999901,0.2518335613798428
51,54,1,0.9902189,0.15691590619107337
54,57,1,0.98673064,0.1867643074938098
Empty file added logs/logfile.log
Empty file.
8 changes: 7 additions & 1 deletion src/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
import traceback
import logging

# Open the config file
import yaml
from yaml import FullLoader
with open("./CONFIG.yaml") as f:
cfg = yaml.load(f, Loader=FullLoader)

logging.basicConfig(filename='logs/logfile.log', level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s')

Expand Down Expand Up @@ -193,7 +199,7 @@ def analyzeFile(

# Initiate model
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_path = "/app/assets/snowmobile_model.pth"
model_path = cfg["path_snowmobile_model"]

model = initModel(model_path=model_path, device=device)

Expand Down

0 comments on commit dd6ffed

Please sign in to comment.