Skip to content

Instantly share code, notes, and snippets.

View Natooz's full-sized avatar
🕺

Nathan Fradet Natooz

🕺
View GitHub Profile
@Natooz
Natooz / benchmark_midi_parsing.py
Last active December 10, 2023 14:31
Benchmarking MIDI parsing libraries Symusic VS Miditoolkit
#!/usr/bin/python3 python
"""Benchmark for Python MIDI parsing libraries.
"""
import random
from pathlib import Path
from time import time
from typing import Sequence
@Natooz
Natooz / slurm_loop_sbatch.sh
Created August 4, 2023 17:45
Script launching a SLURM sbatch jobs until it is completed. This can be useful in case the SLURM environment allows jobs to run only a limited amount of time.
#!/bin/bash
# Here the job is relaunched if it was not 100% completed, that is until a specific file exists
# The --wait argument allows to hang the execution until the job execution ends, before resubmitting it if needed
# Set vars
NAME=$1
JOB_FILE="train_$NAME.sh"
TRAIN_FILE="runs/gen_MMD/TSD_$NAME/train_results.json"
@Natooz
Natooz / estimate_training_time.py
Last active August 2, 2023 15:59
Estimate training time distributed (multi node / multi-GPU)
"""
Small script estimating the training time of models, depending on number of nodes / GPUs / batch size...
"""
from pprint import pformat
from math import ceil
def sec_to_hours(nb_sec: float, no_seconds: bool = False) -> str:
@Natooz
Natooz / test_chords_detection.py
Created March 13, 2023 15:28
Test chord detection methods
#!/usr/bin/python3 python
"""Test chord detection methods
"""
from dataclasses import dataclass
from typing import List, Tuple, Dict, cast
from copy import copy