Skip to content

Instantly share code, notes, and snippets.

View culurciello's full-sized avatar

Eugenio Culurciello culurciello

View GitHub Profile
@culurciello
culurciello / testffi.lua
Last active August 29, 2015 13:57
torchFFI vs regular lua code: HUGE improvement
-- test of FFI vs regular lua code
-- EC march 21st 2014
torch.setdefaulttensortype('torch.FloatTensor')
require 'sys'
require 'image'
require 'torchffi'
local bit = require('bit')
local ffi = require('ffi')
-- E. Culurciello Oct 2014
-- video file loading in macos
-- a cheap ffmpeg hack / alternative:
require("image")
local lfs = require "lfs"
video = {}
function video:init(args)
--------------------------------------------------------------------------------
-- E. Culurciello, October 2014
-- socket test in node.js and Lua
--------------------------------------------------------------------------------
require 'image'
local async = require 'async'
-- tcp client:
async.tcp.connect({host='127.0.0.1', port=6969}, function(client)
// Example of sending to Lua code and receiving results:
// E. Culurciello, November 2014
// server and socket test:
// http://www.hacksparrow.com/tcp-socket-programming-in-node-js.html
var net = require('net');
var HOST = '127.0.0.1';
var PORT = 6969;
// Create a server instance, and chain the listen function to it
@culurciello
culurciello / precision-network.lua
Created March 5, 2015 15:47
precision test for Torch7 and new hardware
--[[ precision-test
Compare precision of hardware and software implementation
run with: qlua precision-network.lua
--]]
require 'nn'
require 'pl'
require 'image'
-- net cpu/gpu speed test
-- E. Culurciello, March 2015
require 'nn'
require('cunn')
torch.setdefaulttensortype('torch.FloatTensor')
net = torch.load('../../models/home-A1l/model.net')
net_gpu = torch.load('../../models/home-A1l/model.net')
net_gpu:cuda()
@culurciello
culurciello / gist:20c4acfc05e54dde1244
Last active August 29, 2015 14:21
pseudo-object segmentations on output of convnet
local mask = function (inputImage, mask, th)
local temp
mask = mask[1]
k = image.gaussian{size = 7, normalize = true}:float()
mask = image.convolve(mask, k, 'same'):repeatTensor(3,1,1)
temp = mask:gt(th):float():mul(.8):add(.2)
return inputImage:clone():cmul(temp)
end
@culurciello
culurciello / ssd-test.lua
Last active August 29, 2015 14:22
SSD torch7 batch test
--------------------------------------------------------------------------------
-- E. Culurciello SSD speed test for batch 128
-------------------------------------------------------------------------------
print('SSD test program in for Torch7 batches')
torch.manualSeed(1)
torch.setdefaulttensortype('torch.FloatTensor')
torch.setnumthreads(8)
to resize 1080p videos:
ffmpeg -i pool.mp4 -vf scale=640:360 pool-small.mp4
to match odroid fps (12fps): need to speed up video:
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
1:
ffmpeg -i dog.mp4 -vf scale=640:360 -filter:v "setpts=0.5*PTS" dog-2x.mp4
because it does not scale with this command, so we need to do more:
2: