diff options
| author | Cameron <cysmith1010@gmail.com> | 2016-11-16 17:18:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-16 17:18:43 -0700 |
| commit | 4b79b2fb188cc980ac9596af888445d8d7fdb0ea (patch) | |
| tree | 6fe4325c91fc13197e46229b12a9a2f9624e3a97 /neural_style.py | |
| parent | 160d9aff117a9542f4c27e342f3549359218b675 (diff) | |
Update neural_style.py
Diffstat (limited to 'neural_style.py')
| -rw-r--r-- | neural_style.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/neural_style.py b/neural_style.py index 8164b2c..5373e5e 100644 --- a/neural_style.py +++ b/neural_style.py @@ -551,7 +551,7 @@ def normalize(weights): denom = sum(weights) if denom > 0.: return [float(i) / denom for i in weights] - else: return [0. for _ in weights] + else: return [0.] * len(weights) def maybe_make_directory(dir_path): if not os.path.exists(dir_path): @@ -568,29 +568,30 @@ def stylize(content_img, style_imgs, init_img, frame=None): with tf.device(args.device), tf.Session() as sess: # setup network net = build_vgg19(content_img) - + # style loss if args.style_mask: L_style = sum_masked_style_losses(sess, net, style_imgs) else: L_style = sum_style_losses(sess, net, style_imgs) - + # content loss L_content = sum_content_losses(sess, net, content_img) - + # denoising loss L_tv = sum_total_variation_losses(sess, net, init_img) - + # loss weights alpha = args.content_weight beta = args.style_weight - theta = args.tv_weight + theta = args.tv_weight # total loss L_total = alpha * L_content L_total += beta * L_style L_total += theta * L_tv - + + # video temporal loss if args.video and frame > 1: gamma = args.temporal_weight L_temporal = sum_shortterm_temporal_losses(sess, net, frame, init_img) |
