Skip to content

Commit

Permalink
add utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
diego0020 committed Apr 29, 2015
1 parent e45c8ee commit 8b5fdff
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/extract_hw_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash

rm -rf homework_1
mkdir homework_1
hws=$(find . -wholename "*/lab0_intro/questions.md")
for hw in ${hws[*]}
do
name=${hw:2}
slash_i=$(( `expr index "$name" /` - 1 ))
name=${name:0:$slash_i}
echo $name
cp $hw homework_1/$name.md
done
21 changes: 21 additions & 0 deletions scripts/fetch_repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/bash

echo NOT AVAILABLE > errors.txt

while read u
do
REPO=https://github.com/$u/lab_vision
#test connection
echo $REPO
wget -q --spider $REPO
status=$?
if [ $status -eq 0 ]
then
rm -rf $u
git clone --progress https://github.com/$u/lab_vision $u
else
echo Not available
echo $u >> errors.txt
fi
sleep 10
done < gh_users.txt
23 changes: 23 additions & 0 deletions scripts/offuscate_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import hmac
import base64
import glob
import hashlib
from itertools import izip
import csv

in_dir='/home/pabloa/imagenet_tiny/test'
out_dir='/home/pabloa/imagenet_tiny/test_o'
cats_file='/home/pabloa/imagenet_tiny/cats_o.csv'
key='gBWJPpeNYUeotZfCXacO'

os.chdir(in_dir)

imgs = glob.glob('*/*.JPEG')
hashes = [base64.urlsafe_b64encode(hmac.new(key,f,hashlib.sha1).hexdigest()) for f in imgs ]
for f,o in izip(imgs,hashes):
os.symlink(os.path.join(in_dir,f),os.path.join(out_dir,o+".JPEG"))

with open(cats_file,"wb") as csv_file:
w=csv.writer(csv_file)
w.writerows(l for l in izip(hashes,(os.path.split(f)[0] for f in imgs)) )
11 changes: 11 additions & 0 deletions scripts/rand_patches.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function ps=rand_patches(im,pw,ph,np)
w=size(im,1);
h=size(im,2);
ps=zeros(pw,ph,np);
for i=1:np
p_x=randi(w-pw);
p_y=randi(h-ph);
p=im(p_x:p_x+pw-1,p_y:p_y+ph-1);
ps(:,:,i)=p;
end
end

0 comments on commit 8b5fdff

Please sign in to comment.