Skip to content

Instantly share code, notes, and snippets.

"""A minimal profiler to compare speed differences between reading a video with opencv
and DALI.
For both dataloaders, the goal is to read an mp4 video and then load batches of frames
onto the GPU.
"""
import os
import logging
import time
import subprocess
@albanie
albanie / monkey_patch_for_hickle.py
Last active May 24, 2020 08:42
Proposal to add 'escape_slash' argument support to hickle.load and hickle.dump
"""A small wrapper around hickle to allow the usage of python dictionaries with
slashes in key names.
Feature proposal: https://github.com/telegraphic/hickle/issues/124
Hickle license: https://github.com/telegraphic/hickle/blob/master/LICENSE
Author: Samuel Albanie
"""
# ---------------------------------------------
# Monkey patch
# ---------------------------------------------
@albanie
albanie / toDagNN.m
Created September 21, 2017 10:22
toDagNN (working progress)
function dag = toDagNN(net, customObj)
%TODAGNN Converts a compiled AutoNN network to a DagNN object
% DAG = toDagNN(NETOUTPUTS) converts a set of Autonn outputs
% (i.e. a set of recursively nested layer objects), into a dagnn object,
% DAG.
% TODO(samuel): clean up
if nargin < 2
@albanie
albanie / py_inspect_layer.py
Created February 18, 2017 19:42
A simple inspection layer for caffe debugging
from __future__ import print_function
import matplotlib
matplotlib.use('Agg')
import colorsys
import caffe
import json
import pdb
import time
import sys
@albanie
albanie / py_inspect_layer.py
Created February 18, 2017 19:42
A simple inspection layer for caffe debugging
from __future__ import print_function
import matplotlib
matplotlib.use('Agg')
import colorsys
import caffe
import json
import pdb
import time
import sys
function issue_814
% demo for @segman
% fix random seed to get repeatable result
rng(1) ;
sample = rand(21, 21, 3, 'single') ;
label = [ 1 1 1 1 1 ;
1 1 1 1 1 ;
1 2 2 2 1 ;
@albanie
albanie / py_blank_data_layer.py
Last active November 12, 2016 20:44
Python caffe layers: numerical gradient checking
import caffe
import pdb
import numpy as np
class PyBlankDataLayer(caffe.Layer):
"""
A blank python data layer that initialises once with zeros
according during construction and does no further operations
(useful for layer testing).
"""
@albanie
albanie / periodic_signal.py
Created February 25, 2015 08:42
Show that the result of summing two periodic signals is periodic
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np, math
"""Define the periodic function"""
def f(t):
return math.cos(2 * math.pi * t) + 0.5 * math.cos( 4 * math.pi * t)
"""Define inputs, find outputs and plot graph"""
inputs = np.linspace(-2, 2, 100)