Skip to content

Instantly share code, notes, and snippets.

View MiniXC's full-sized avatar
🏠
Working from home

Christoph Minixhofer MiniXC

🏠
Working from home
  • Edinburgh
View GitHub Profile
@MiniXC
MiniXC / librispeech_speakers.txt
Created April 17, 2024 14:10
librispeech_speakers.txt
; Some pipe(|) separated metadata about all LibriVox readers, whose work was used
; in the corpus.
;
; The meaning of the fields in left-to-right order is as follows:
;
; reader_id: the ID of the reader in the LibriVox's database
; gender: 'F' for female, 'M' for male
; subset: the corpus subset to which the reader's audio is assigned
; duration: total number of minutes of speech by the reader, included in the corpus
; name: the name under which the reader is registered in LibriVox
@MiniXC
MiniXC / update_tpus.sh
Created November 13, 2023 14:53
update_tpus.sh
#!/bin/bash
if ! test -f /etc/hosts.bak; then
sudo cp /etc/hosts /etc/hosts.bak
fi
sudo cp /etc/hosts.bak /etc/hosts
YAML_INFO="
`gcloud compute tpus tpu-vm list --zone=us-central1-f --format=yaml`
# add to your bashrc
function pyroblast() {
pkill -f ".*python.*"
pkill -f ".*wandb.*"
accelerate launch "$@"
}
import json
import sys
from accelerate import Accelerator
import torch
from tqdm.auto import tqdm
from datasets import load_dataset
from speech_collator import SpeechCollator
from speech_collator.measures import EnergyMeasure, PitchMeasure, SRMRMeasure, SNRMeasure
from transformers import HfArgumentParser

possibly later

  • include what the graph is showing in the title (better for screenshots)
  • option to remove outliers (came across some in the data)
  • moving average (although we have to be careful with that)

bigger changes

  • more than one tag at the same time
  • control for tags other than fandom (e.g. a pairing)

small changes

@MiniXC
MiniXC / ram_police.sh
Last active March 19, 2024 09:54
ram_police.sh
if [ $# -eq 0 ]; then
tmux new-session -d -s ram_police
tmux send-keys -t ram_police "bash ram_police.sh true" ENTER
tmux capture-pane -t ram_police
else
free_ram=$(free -g | grep -m1 -E "[[:digit:]]" | tail -c4)
ram_limit=10
clear
echo "RAM POLICE WITH $ram_limit GB MIN."
@MiniXC
MiniXC / night_vale_ts.csv
Created January 8, 2022 17:49
Welcome to Night Vale Timestamps
number url episode_start weather_start weather_end episode_end
1 https://youtu.be/Ujksjzqrhys 37 740 911 1193
2 https://youtu.be/due3u22Licw 37 791 961 1150
3 https://youtu.be/jAPOTuVeBJc 39 866 1082 1188
4 https://youtu.be/KXDrp59tD0g 38 888 1162 1320
5 https://youtu.be/STw7cm3TSO8 34 863 1092 1200
6 https://youtu.be/Xmm6izeRcos 30 1017 1200 1307
7 https://youtu.be/4ZiJ0_CAw6k 35 942 1207 1402
8 https://youtu.be/hpC7qMZogDY 35 1009 1252 1375
9 https://youtu.be/54N9MRarrS8 35 947 1208 1356
We can't make this file beautiful and searchable because it's too large.
,y_pred,y_pred_rounded,fips,date,y_true,week
0,-0.043328024446964264,0,1001,2017-06-30,0.0,0
1,0.507280170917511,1,1001,2017-12-27,1.0,0
2,0.028431229293346405,0,1001,2018-06-25,0.0,0
3,-0.017092008143663406,0,1003,2017-06-30,0.0,0
4,0.6950212121009827,1,1003,2017-12-27,1.0382,0
5,0.31889382004737854,0,1003,2018-06-25,0.382,0
6,-0.0005514370277523994,0,1005,2017-06-30,0.0,0
7,0.820785403251648,1,1005,2017-12-27,1.0974,0
8,0.07871026545763016,0,1005,2018-06-25,0.0,0
We can't make this file beautiful and searchable because it's too large.
,y_pred,y_pred_rounded,fips,date,y_true,week
0,0.03677709400653839,0,1001,2017-06-30,0.0,0
1,0.42399361729621887,0,1001,2017-12-27,1.0,0
2,0.017427001148462296,0,1001,2018-06-25,0.0,0
3,0.036498844623565674,0,1003,2017-06-30,0.0,0
4,0.7784255743026733,1,1003,2017-12-27,1.0382,0
5,0.3446190059185028,0,1003,2018-06-25,0.382,0
6,0.03354061394929886,0,1005,2017-06-30,0.0,0
7,0.744026780128479,1,1005,2017-12-27,1.0974,0
8,0.03732544928789139,0,1005,2018-06-25,0.0,0
import torch
from torch import Tensor
from torch import nn
from torch.nn import functional as F
class FocalLoss(nn.Module):
""" see https://arxiv.org/abs/1708.02002
based on https://github.com/AdeelH/pytorch-multi-class-focal-loss/blob/master/focal_loss.py
"""
def __init__(self,