Skip to content

Instantly share code, notes, and snippets.

View culurciello's full-sized avatar

Eugenio Culurciello culurciello

View GitHub Profile
@culurciello
culurciello / gist:5189137
Last active November 8, 2016 14:29
test of torch numerical performance
#!/usr/bin/env torch
require 'nn'
require 'image'
require 'xlua'
require 'pl'
opt = lapp[[
-t,--threads (default 8) number of threads
-p,--type (default float) float or cuda
local cv = require 'cv'
require 'cv.highgui'
require 'cv.imgproc'
require 'cv.imgcodecs'
require 'image'
-- local image = cv.imread{arg[1] or 'demo/lena.jpg', cv.IMREAD_GRAYSCALE}
imgT = image.lena()
imgT = image.lena()
imgTg = imgT[2] -- convert to grayscale and remove the first dimension
@culurciello
culurciello / gist:8410551
Last active January 3, 2016 04:39
apple accelerate matrix matrix multiply example
/*
Test of C code speed with Apple Accelerate Framework and openmp
https://developer.apple.com/library/mac/documentation/Accelerate/Reference/BLAS_Ref/Reference/reference.html#//apple_ref/c/func/cblas_sgemm
compile with:
gcc -Ofast -fopenmp -flax-vector-conversions -framework Accelerate acctest.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@culurciello
culurciello / mactest.c
Last active January 3, 2016 01:29
test of computer speed with dummy math/lin algebra code
/*
Test of C code speed
compile with: gcc -Ofast -fopenmp -mavx mactest.c
or gfortran -O3 -fopenmp mactest.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>
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:
@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)
@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
-- 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 / 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'