1 Star 0 Fork 0

Roger-Luo/vrn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
process.lua 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env th
local nn = require 'nn'
local image = require 'image'
cmd = torch.CmdLine()
cmd:option('--model', 'model.t7', 'Trained network model')
cmd:option('--input', 'examples/', 'Directory of images to process')
cmd:option('--output', 'output/', 'Location to dump output')
cmd:option('--device', 'gpu', 'GPU or CPU')
opt = cmd:parse(arg or {})
net = torch.load(opt.model)
if opt.device == 'gpu' then
local cunn = require 'cunn'
local cudnn = require 'cudnn'
net = net:cuda()
end
for fname in paths.iterfiles(opt.input .. '/', '*.jpg') do
fname = string.sub(fname, 1, -5)
local img = image.load(opt.input .. '/' .. fname .. '.jpg')
img = image.scale(img, 192, 192)
img = img:view(1,3,192,192):float()
if opt.device == 'gpu' then
img = img:cuda()
end
local output = net:forward(img)
local vol = (output[1]*255):byte()
local out = torch.DiskFile(opt.output .. '/' .. fname .. '.raw', 'w')
out:binary()
out:writeByte(vol:storage())
out:close()
io.write('Processed ' .. fname .. '.\n')
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/roger521/vrn.git
git@gitee.com:roger521/vrn.git
roger521
vrn
vrn
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385