Skip to content

Instantly share code, notes, and snippets.

Will Price willprice

Block or report user

Report or block willprice

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
willprice /
Created Mar 20, 2020
Collate a list of dictionaries into a dictionary of lists
__all__ = ['collate_dicts']
from typing import List, Dict, Any
from collections import defaultdict
def collate_dicts(ds: List[Dict[Any, Any]]) -> Dict[Any, List[Any]]:
ds: A list of dictionarys all with the same keys.
willprice /
Last active Feb 12, 2020
Script to read Charades CSV files (Charades_v1_train.csv, Charades_v1_test.csv) into a pandas DataFrame where each row represents a single action
import pandas as pd
from csv import DictReader
from collections import defaultdict
import numpy as np
def read_charades_csv(path):
def parse_action(action_str):
cls, start, stop = action_str.split(' ')
return {
'class': int(cls[1:]),
'start': float(start),
willprice /
Created Oct 9, 2019
Matplotlib snippet for visualising matrices nicely.
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(context='paper', style='whitegrid')
def grid_show(grid, horizontal_labels, vertical_labels=None, cmap='binary', grid_color='#efefef'):
ax = plt.gca()
image = ax.imshow(grid,
willprice /
Created Oct 1, 2019
PIL Image stacking
from PIL import Image
def vstack(images):
if len(images) == 0:
raise ValueError("Need 0 or more images")
if isinstance(images[0], np.ndarray):
images = [Image.fromarray(img) for img in images]
width = max([img.size[0] for img in images])
height = sum([img.size[1] for img in images])
willprice /
Created Sep 9, 2019
Remove old kernels from ubuntu
set +ex
OLD_KERNELS=$(dpkg -l | grep -i 'linux-image-[[:digit:]]' | awk '{ print $2 }' | sort -rV | tail -n "+$(($KEEP_LAST_N + 1))")
if [ -n "$OLD_KERNELS" ]; then
apt-get -qy remove --purge $OLD_KERNELS
apt-get -qy autoremove --purge

PBS Pro command cheat sheet

List nodes and their features

$ pbsnodes

willprice /
Last active Mar 1, 2020
Kinetics Dataset Labels (name to ID)

Kinetics Numeric/String labels

These are mapping files that go between class IDs to class names. These are generated from the training CSV files from each dataset by collecting the unique classes, sorting them, and then numbering them from 0 upwards.

willprice /
Created Jul 22, 2019
Set tick spacing on matplotlib axis
from matplotlib import ticker

Find the node assigned to a job

$ sacct -j <jobid> --format NodeList
You can’t perform that action at this time.