This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------- | |
-- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ precision-test | |
Compare precision of hardware and software implementation | |
run with: qlua precision-network.lua | |
--]] | |
require 'nn' | |
require 'pl' | |
require 'image' |