diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-25 20:21:33 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-25 20:21:33 +0200 |
| commit | 286640c558a1266d6e842b8e129cee39af93cec2 (patch) | |
| tree | fc8559941357fc7b5c4a886f9f76f51180568b6b | |
| parent | ab6368872d2c99fd1880a2615080ed5aeda911c5 (diff) | |
smooth sequences
| -rw-r--r-- | process-sequences.sh | 11 | ||||
| -rw-r--r-- | run.py | 32 |
2 files changed, 36 insertions, 7 deletions
diff --git a/process-sequences.sh b/process-sequences.sh index 406aca8..cd359a8 100644 --- a/process-sequences.sh +++ b/process-sequences.sh @@ -3,13 +3,13 @@ function process() { sequence_b="$2" rm renders/* python run.py \ - --mix-videos True \ + --average-videos True \ --first "../pix2pixhd/sequences/$sequence_a/" \ --second "../pix2pixhd/sequences/$sequence_b/" \ --steps 32 \ --dilate 4 \ - --smooth True \ - --video-out "morph_dilate_4_smooth_${sequence_a}.mp4" + --video-out "average_smooth_${sequence_a}.mp4" + # --smooth True \ scp renders/* jules@lmno:asdf/neural/morph/ } function process_self() { @@ -18,15 +18,14 @@ function process_self() { b_offset="$3" rm renders/* python run.py \ - --mix-videos True \ + --average-videos True \ --first "../pix2pixhd/sequences/$sequence/" \ --second "../pix2pixhd/sequences/$sequence/" \ --a-offset "$a_offset" \ --b-offset "$b_offset" \ --steps 32 \ --dilate 4 \ - --smooth True \ - --video-out "morph_dilate_4_smooth_self_${b_offset}_${sequence}.mp4" + --video-out "average_self_${b_offset}_${sequence}.mp4" scp renders/* jules@lmno:asdf/neural/morph/ } @@ -26,6 +26,7 @@ arguments_smooth = False arguments_aOffset = 0 arguments_bOffset = 0 arguments_mixVideos = False +arguments_averageVideos = False for strOption, strArgument in getopt.getopt(sys.argv[1:], '', [ strParameter[2:] + '=' for strParameter in sys.argv[1::2] ])[0]: print("{}: {}".format(strOption, strArgument)) @@ -49,6 +50,8 @@ for strOption, strArgument in getopt.getopt(sys.argv[1:], '', [ strParameter[2:] arguments_smooth = bool(strArgument) elif strOption == '--mix-videos': arguments_mixVideos = bool(strArgument) + elif strOption == '--average-videos': + arguments_averageVideos = bool(strArgument) elif strOption == '--a-offset': arguments_aOffset = int(strArgument) elif strOption == '--b-offset': @@ -108,6 +111,26 @@ def process_two_videos(moduleNetwork, tensorOutput, a, b, a_offset, b_offset, st steps *= dilate return recurse_videos(moduleNetwork, tensorOutput, a, b, a_offset, b_offset, steps, steps, steps/2, dilate) +def average_two_videos(moduleNetwork, tensorOutput, a, b, a_offset, b_offset, steps, dilate): + global index + index += 1 + if (index % 10) == 0: + print("{}...".format(index)) + frames = [] + steps *= dilate + for i in range(0, steps * dilate, dilate): + a_fn = os.path.join(a, "frame_{:0>5}.png".format(int(frame_index + a_offset))) + b_fn = os.path.join(b, "frame_{:0>5}.png".format(int(frame_index + b_offset))) + print("{} => {}".format(a_fn, b_fn)) + a_np = load_image(a_fn) + b_np = load_image(b_fn) + tensorInputFirst = torch.FloatTensor(a_np) + tensorInputSecond = torch.FloatTensor(b_np) + process(moduleNetwork, tensorInputFirst, tensorInputSecond, tensorOutput) + middle_np = tensorOutput.clamp(0.0, 1.0).numpy() + frames.append(middle_np) + return frames + def process_tree(moduleNetwork, a, b, tensorOutput, steps, dilate): global index index += 1 @@ -201,7 +224,14 @@ elif arguments_mixVideos: outputPath = './renders/' + arguments_strVideoOut frames = process_two_videos(moduleNetwork, tensorOutput, arguments_strFirst, arguments_strSecond, arguments_aOffset, arguments_bOffset, arguments_steps, arguments_dilate) frames = smooth_frames(moduleNetwork, tensorOutput, frames, arguments_smooth) - print("dilate... {}".format(arguments_dilate)) + frames = dilate_frames(moduleNetwork, tensorOutput, frames, arguments_dilate) + store_frames(frames, outputPath) +elif arguments_averageVideos: + print("average two videos...") + print("{} => {}".format(arguments_strFirst, arguments_strSecond)) + outputPath = './renders/' + arguments_strVideoOut + frames = average_two_videos(moduleNetwork, tensorOutput, arguments_strFirst, arguments_strSecond, arguments_aOffset, arguments_bOffset, arguments_steps, arguments_dilate) + frames = smooth_frames(moduleNetwork, tensorOutput, frames, arguments_smooth) frames = dilate_frames(moduleNetwork, tensorOutput, frames, arguments_dilate) store_frames(frames, outputPath) elif arguments_steps == 0: |
