summaryrefslogtreecommitdiff
path: root/run.py
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-25 15:30:59 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-25 15:30:59 +0200
commit284dc5fe46bdaaf78f0416bfc6a5067a868b9062 (patch)
tree3459069cb90198a4e084c121a64ef9236fac4ba1 /run.py
parent60ff067355997fc7dbd3e5309616ddd3812e2634 (diff)
go hey
Diffstat (limited to 'run.py')
-rw-r--r--run.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/run.py b/run.py
index aad97a7..dc61660 100644
--- a/run.py
+++ b/run.py
@@ -49,7 +49,9 @@ if not os.path.exists('./renders'):
moduleNetwork = Network(arguments_strModel).cuda()
tensorOutput = torch.FloatTensor()
-def process_tree(moduleNetwork, tensorInputFirst, tensorInputSecond, tensorOutput, steps):
+def process_tree(moduleNetwork, a, b, tensorOutput, steps):
+ tensorInputFirst = torch.FloatTensor(a)
+ tensorInputSecond = torch.FloatTensor(b)
process(moduleNetwork, tensorInputFirst, tensorInputSecond, tensorOutput)
tensorMiddle = (numpy.rollaxis(tensorOutput.clamp(0.0, 1.0).numpy(), 0, 3)[:,:,::-1] * 255.0).astype(numpy.uint8)
if steps < 2:
@@ -76,12 +78,14 @@ if arguments_strVideo and arguments_strVideoOut:
writer.close()
else:
# Process image
- tensorInputFirst = torch.FloatTensor(numpy.rollaxis(numpy.asarray(PIL.Image.open(arguments_strFirst))[:,:,::-1], 2, 0).astype(numpy.float32) / 255.0)
- tensorInputSecond = torch.FloatTensor(numpy.rollaxis(numpy.asarray(PIL.Image.open(arguments_strSecond))[:,:,::-1], 2, 0).astype(numpy.float32) / 255.0)
if arguments_steps == 0:
+ tensorInputFirst = torch.FloatTensor(numpy.rollaxis(numpy.asarray(PIL.Image.open(arguments_strFirst))[:,:,::-1], 2, 0).astype(numpy.float32) / 255.0)
+ tensorInputSecond = torch.FloatTensor(numpy.rollaxis(numpy.asarray(PIL.Image.open(arguments_strSecond))[:,:,::-1], 2, 0).astype(numpy.float32) / 255.0)
process(moduleNetwork, tensorInputFirst, tensorInputSecond, tensorOutput)
PIL.Image.fromarray((numpy.rollaxis(tensorOutput.clamp(0.0, 1.0).numpy(), 0, 3)[:,:,::-1] * 255.0).astype(numpy.uint8)).save(arguments_strOut)
else:
+ tensorInputFirst = numpy.rollaxis(numpy.asarray(PIL.Image.open(arguments_strFirst))[:,:,::-1], 2, 0).astype(numpy.float32) / 255.0
+ tensorInputSecond = numpy.rollaxis(numpy.asarray(PIL.Image.open(arguments_strSecond))[:,:,::-1], 2, 0).astype(numpy.float32) / 255.0
tree = process_tree(moduleNetwork, tensorInputFirst, tensorInputSecond, tensorOutput, arguments_steps)
writer = FFMPEG_VideoWriter('./renders/' + arguments_strVideoOut, (1024, 512), 25)
writer.write_frame(tensorInputFirst)