Skip to content

Instantly share code, notes, and snippets.

View szagoruyko's full-sized avatar

Sergey Zagoruyko szagoruyko

View GitHub Profile
diff --git a/torchfile.py b/torchfile.py
index cba1145..61fea4a 100644
--- a/torchfile.py
+++ b/torchfile.py
@@ -378,6 +378,16 @@ class T7Reader:
obj = lst
self.objects[index] = obj
return obj
+ elif typeidx >= 50:
+ size = typeidx
-- 2014 Sergey Zagoruyko, ENPC-UPEM, IMAGINE, Paris
-- Creates a t7 file from local image patches dataset
-- http://www.cs.ubc.ca/~mbrown/patchdata/patchdata.html
-- usage:
-- th create_dataset_file.lua *dataset_name*
-- where dataset_name is notredame, liberty or yosemite
-- which is also a folder with the same name, containing:
-- info.txt, m_50_500000_500000_0.txt and 1024x1024 bmp images
-- saves data.t7 file in the corresponding folder
require 'sys'

Setting up cron to clear page cache periodically

This is usefull for ImageNet training when it loads a ton of images which are kept in page memory until training starts to lag.

Assume we are on Ubuntu.

First, create a cron job from root:

sudo crontab -e
local tablex = require 'pl.tablex'
require 'cunn'
require 'cudnn'
local utils = dofile '/opt/projects/coco/fastrcnn/models/model_utils.lua'
dofile'/home/zagoruys/projects/cifar2.torch/augmentation.lua'
local net = torch.load'./model_35.t7'
cudnn.convert(net, nn)
@szagoruyko
szagoruyko / torch-opencv-blogpost.md
Created June 1, 2016 08:53 — forked from shrubb/torch-opencv-blogpost.md
"OpenCV bindings" post for Torch blog

OpenCV Bindings for Torch

The OpenCV library implements tons of useful image processing and computer vision algorithms, as well as the high-level GUI API. Written in C++, it has bindings in Python, Java, MATLAB/Octave, C#, Perl and Ruby. We present the Lua bindings that are based on Torch, made by VisionLabs with support from Facebook and Google Deepmind.

By combining OpenCV with scientific computation abilities of Torch, one gets an even more powerful framework capable of handling computer vision routines (e.g. face detection), interfacing video streams (including cameras), easier data visualization, GUI interaction and many more. In addition, most of the computationally intensive algorithms are available on GPU via Cutorch. All these features may be essentially useful for those dealing with deep learning applied to images.

Usage Examples

@szagoruyko
szagoruyko / torch-opencv-blogpost.md
Last active May 30, 2017 16:52 — forked from shrubb/torch-opencv-blogpost.md
"OpenCV bindings" post for Torch blog

OpenCV Bindings for Torch

The OpenCV library implements tons of useful image processing and computer vision algorithms, as well as the high-level GUI API. Written in C++, it has bindings in Python, Java, MATLAB/Octave, C#, Perl and Ruby. We present the Lua bindings that are based on Torch, made by VisionLabs with support from Facebook and Google Deepmind.

By combining OpenCV with scientific computation abilities of Torch, one gets an even more powerful framework capable of handling computer vision routines (e.g. face detection), interfacing video streams (including cameras), easier data visualization, GUI interaction and many more. In addition, most of the computationally intensive algorithms are available on GPU via Cutorch. All these features may be essentially useful for those dealing with deep learning applied to images.

Usage Examples

require 'xlua'
local grad = require 'autograd'
local tablex = require 'pl.tablex'
grad.optimize(true)
local function cast(x)
if type(x) == 'table' then
for k,v in pairs(x) do x[k] = cast(v) end
return x
else
roc = function(scores)
local L,I = torch.sort(scores[{{}, 1}], 1, true)
local labels = scores[{{},2}]:index(1,I)
local fprev = - math.huge
local FP = 0.0
local TP = 0.0
local n = labels:size(1)
local N = n/2
local P = n/2
local j = 1