Skip to content

Instantly share code, notes, and snippets.

@carsontang
carsontang / region_mean_subtraction.m
Created February 18, 2018 00:56
Describing rcnn_im_crop's mean subtraction from a region
# Crop the region out of the image with the bbox coordinates
# bbox = [x1 y1 x2 y2]
# size(im) = HEIGHT x WIDTH x NUM_CHANNELS
# window = im(y1:y2, x1:x2, all_channels)
# For every channel, crop out the height and the width
window = im(bbox(2):bbox(4), bbox(1):bbox(3), :);
# Warp the region
tmp = imresize(window, [crop_height crop_width], ...
@carsontang
carsontang / selective_search.m
Created February 3, 2018 17:24
Search for patches within an image (aka a region) that might be an object we're trying to detect
% compute selective search candidates
fprintf('Computing candidate regions...');
th = tic();
fast_mode = true;
boxes = selective_search_boxes(im, fast_mode);
dets = spp_detect(im, spp_model, spm_im_size, use_gpu);
spp_model_file = '.\data\spp_model\VOC2007\spp_model.mat';
if ~exist(spp_model_file, 'file')
error('%s not exist ! \n', spp_model_file);
end
try
load(spp_model_file);
catch err
fprintf('load spp_model_file : %s\n', err.message);
end
caffe_net_file = fullfile(pwd, 'data\cnn_model\Zeiler_conv5\Zeiler_conv5');
import os
import sys
from django.conf import settings
DEBUG = os.environ.get('DEBUG', 'on') == 'on'
SECRET_KEY = os.environ.get('SECRET_KEY', os.urandom(32))
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost').split(',')
import cairo
import numpy as np
from PIL import Image
# imdata is a 2D numpy array of dtype np.uint8 containing grayscale pixel intensities on [0, 255]
# repeat for each of R, G, B, and add a deck of 255s for alpha
cairo_imdata = np.dstack([imdata, imdata, imdata, np.ones_like(imdata)*255])
surface = cairo.ImageSurface.create_for_data(cairo_imdata, cairo.FORMAT_ARGB32, *(reversed(imdata.shape)))
@carsontang
carsontang / manim.patch
Created October 22, 2017 22:04
changes to make manim work
diff --git a/constants.py b/constants.py
index b6bb6f1..c68f453 100644
--- a/constants.py
+++ b/constants.py
@@ -62,7 +62,7 @@ RIGHT_SIDE = SPACE_WIDTH*RIGHT
# Change this to point to where you want
# animation files to output
-MOVIE_DIR = os.path.join(os.path.expanduser('~'), "Dropbox/3b1b_videos/animations/")
+MOVIE_DIR = os.path.join(os.path.expanduser('~'), "dev/3b1b_videos/animations/")
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=latex 2017.5.23) 4 OCT 2017 10:35
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**/Users/ctang/dev/manim/files/Tex/8663884173924170067.tex
(/Users/ctang/dev/manim/files/Tex/8663884173924170067.tex
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/standalone/standalone.cls
Document Class: standalone 2015/07/15 v1.2 Class to compile TeX sub-files stand
@carsontang
carsontang / solver.py
Created July 19, 2017 06:04
In CS231n assignment 2, FullyConnectedNets, change an "epoch" to be one full pass of all the training data. Without this patch, an "epoch" = num iterations per epoch, which isn't exactly the full definition
diff --git a/assignment2/cs231n/solver.py b/assignment2/cs231n/solver.py
index 1733b52..905c109 100644
--- a/assignment2/cs231n/solver.py
+++ b/assignment2/cs231n/solver.py
@@ -132,6 +132,7 @@ class Solver(object):
self.checkpoint_name = kwargs.pop('checkpoint_name', None)
self.print_every = kwargs.pop('print_every', 10)
self.verbose = kwargs.pop('verbose', True)
+ self.train_sample_indexes_seen_in_epoch = None
@carsontang
carsontang / solver.patch
Created July 19, 2017 05:15
patch that prints out what percent of all training samples are seen during an "epoch"
diff --git a/assignment2/cs231n/solver.py b/assignment2/cs231n/solver.py
index 1733b52..5a73fab 100644
--- a/assignment2/cs231n/solver.py
+++ b/assignment2/cs231n/solver.py
@@ -132,6 +132,7 @@ class Solver(object):
self.checkpoint_name = kwargs.pop('checkpoint_name', None)
self.print_every = kwargs.pop('print_every', 10)
self.verbose = kwargs.pop('verbose', True)
+ self.train_sample_indexes_seen_in_epoch = None