forked from DmitryUlyanov/texture_nets
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtexture_sample.lua
More file actions
33 lines (26 loc) · 889 Bytes
/
Copy pathtexture_sample.lua
File metadata and controls
33 lines (26 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'cutorch'
require 'nn'
require 'cunn'
require 'cudnn' -- need to be fixed
require 'image'
require 'src/utils.lua'
local cmd = torch.CmdLine()
cmd:option('-noise_depth', 3, 'Noise depth used to train model.')
cmd:option('-model', '', 'Path to trained model.')
cmd:option('-sample_size', 256)
cmd:option('-save_path', '.', 'Path to save samples.')
local params = cmd:parse(arg)
function deprocess_many(img)
local temp = img:clone()
for i=1,temp:size(1) do
temp[i]:copy(torch.clamp(deprocess(temp[i]), 0, 1))
end
return temp
end
local model = torch.load(params.model):cuda()
local input = torch.zeros(4, params.noise_depth, params.sample_size, params.sample_size):cuda()
local samples = model:forward(input):double()
local images = deprocess_many(samples)
for i =1,images:size(1) do
image.save(params.save_path .. '/' .. i .. '.png', images[i])
end