-
-
Save teologov/ac28cf4d80a175d7b5268d6f7a19460d to your computer and use it in GitHub Desktop.
Revisions
-
htoyryla revised this gist
Oct 30, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,9 +12,9 @@ require 'image' local cmd = torch.CmdLine() cmd:option('-generated_image', '', 'Image to copy colors to') cmd:option('-original_image', '', 'Image to copy colors from') cmd:option('-output_image', 'out.png') -
htoyryla revised this gist
Oct 30, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,9 +11,9 @@ require 'image' local cmd = torch.CmdLine() cmd:option('-generated_image', '', 'Style target image') cmd:option('-original_image', '', 'Content target image') cmd:option('-output_image', 'out.png') -
htoyryla created this gist
Oct 30, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ -- this program takes an original image, such as a photo, -- and a generated image, such as generated by jcjohnson/fast-neural-style -- and copies the original colors to the generated image -- like when using the original_colors param in jcjohnson/neural-style -- -- by hannu töyrylä @htoyryla 30 oct 2016 -- require 'torch' require 'image' local cmd = torch.CmdLine() cmd:option('-generated_image', 'examples/inputs/seated-nude.jpg', 'Style target image') cmd:option('-original_image', 'examples/inputs/tubingen.jpg', 'Content target image') cmd:option('-output_image', 'out.png') local function main(params) local generated_image = image.load(params.generated_image, 3) local oimg = image.load(params.original_image, 3) local original_image = image.scale(oimg, generated_image:size(3), generated_image:size(2)) disp = original_colors(original_image, generated_image) image.save(params.output_image, disp) end function original_colors(content, generated) local generated_y = image.rgb2yuv(generated)[{{1, 1}}] local content_uv = image.rgb2yuv(content)[{{2, 3}}] return image.yuv2rgb(torch.cat(generated_y, content_uv, 1)) end local params = cmd:parse(arg) main(params)