Skip to content

Instantly share code, notes, and snippets.

View kashefy's full-sized avatar

Youssef Kashef kashefy

  • Berlin, Germany
View GitHub Profile
@kashefy
kashefy / rename_img_files
Created June 16, 2015 13:03
traversing subdirectories and renaming image files with strange windows-specific character
'''
Created on Jun 16, 2015
@author: kashefy
'''
import argparse
import os
def list_paths(root_path):
@kashefy
kashefy / val_59.txt
Created August 7, 2015 10:23
Entities from the PASCAL-Context db assigned to the validation set. Obtained from http://www.cs.stanford.edu/~roozbeh/pascal-context/59_context_labels.tar.gz
2008_000002
2008_000003
2008_000007
2008_000009
2008_000016
2008_000021
2008_000026
2008_000027
2008_000032
2008_000034
@kashefy
kashefy / fileSystemUtils.py
Created September 29, 2015 14:07
file system utilities
import os
def gen_paths(dir_src, func_filter=None):
if func_filter is None:
def func_filter(fileName):
return True
dst = []
@kashefy
kashefy / mnist_ae_tied_weights_trainval.prototxt
Last active January 29, 2016 18:59
network definition for an Auto-encoder with tied weights. The weight are tied by sharing parameter names in 'permissive mode' and setting the decoder's ip params to use tranposed weigts.
name: "MNISTAutoencoderTiedWeights"
layer {
name: "mnist"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
template <typename Dtype>
void printMat(const Dtype* data, int rows, int cols) {
int j = 0;
std::cout<<"np.array([";
for (int r=0; r<rows; r++) {
std::cout<<"[";
for (int c=0; c<cols; c++) {
std::cout<<data[j++];
if (c<cols-1) std::cout<<",";
}
@kashefy
kashefy / 59_labels.txt
Last active February 20, 2016 13:25
The 59 labels subset for PASCAL Context dataset. Originally from here: http://www.cs.stanford.edu/~roozbeh/pascal-context/59_labels.txt
1: aeroplane
2: bicycle
3: bird
4: boat
5: bottle
6: bus
7: car
8: cat
9: chair
10: cow
@kashefy
kashefy / lower_samplerate_cmds.py
Last active May 26, 2016 08:44
downsample sound files using ffmpeg
def is_wav(p):
return os.path.splitext(p)[-1] == '.wav'
def lower_samplerate_cmds(dir_src, samplerate, dir_dst, fpath_exec_script):
paths = fs.gen_paths(dir_src, is_wav)
commands = []
for fpath in paths:
path_dst = os.path.join(dir_dst, os.path.basename(fpath))
@kashefy
kashefy / moving_avg.py
Last active July 29, 2016 13:06
Moving average for a time series
import numpy as np
def moving_avg(x, window_size):
window = np.ones(int(window_size)) / float(window_size)
return np.convolve(x, window, 'valid')
@kashefy
kashefy / find_circV
Created January 6, 2017 10:29
grep -nHIrF --include=*.m -- circV
./auditory-front-end/src/Processors/pitchProc.m:236: pObj.maxConfBuf = circVBuf(bufferDurSec*pObj.FsHzIn,1);
./auditory-front-end/src/Processors/pitchProc.m:237: pObj.maxConf = circVBufArrayInterface(pObj.maxConfBuf);
./auditory-front-end/src/Signals/circVBuf.m:1:classdef circVBuf < handle
./auditory-front-end/src/Signals/circVBuf.m:2: %circVBuf class defines a circular double buffered vector buffer
./auditory-front-end/src/Signals/circVBuf.m:51: % example 1 - loop over new vectors of a circVBuf (slow because of copy):
./auditory-front-end/src/Signals/circVBuf.m:52: % for ix=circVBufObj.VBuf.new:circVBuf.VBuf.lst
./auditory-front-end/src/Signals/circVBuf.m:53: % vec(:) = circVBuf.VBuf.raw(:,bId);
./auditory-front-end/src/Signals/circVBuf.m:57: % new = circVBuf.VBuf.new;
./auditory-front-end/src/Signals/circVBuf.m:58: % lst = circVBuf.VBuf.lst;
./auditory-front-end/src/Signals/circVBuf.m:59: % mean = mean(circVBuf.VBuf.raw(3:7,new:lst));
@kashefy
kashefy / tf_restore.py
Created September 7, 2017 09:04
Try out saving and restoring Tensorflow variables defined using tf.get_variable
'''
Created on Aug 18, 2017
@author: kashefy
'''
import os
import shutil
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np