Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference on tensorflow 2.x #23

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions test_code/cartoonize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
try:
import tensorflow.compat.v1 as tf
except ImportError:
import tensorflow as tf

import os
import cv2
import numpy as np
import tensorflow as tf
import network
import guided_filter
from tqdm import tqdm
Expand All @@ -23,6 +27,13 @@ def resize_crop(image):


def cartoonize(load_folder, save_folder, model_path):
try:
tf.disable_eager_execution()
except:
None

tf.reset_default_graph()

input_photo = tf.placeholder(tf.float32, [1, None, None, 3])
network_out = network.unet_generator(input_photo)
final_out = guided_filter.guided_filter(input_photo, network_out, r=1, eps=5e-3)
Expand Down Expand Up @@ -63,6 +74,3 @@ def cartoonize(load_folder, save_folder, model_path):
if not os.path.exists(save_folder):
os.mkdir(save_folder)
cartoonize(load_folder, save_folder, model_path)



6 changes: 5 additions & 1 deletion test_code/guided_filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import tensorflow as tf
try:
import tensorflow.compat.v1 as tf
except ImportError:
import tensorflow as tf

import numpy as np


Expand Down
11 changes: 8 additions & 3 deletions test_code/network.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import tensorflow as tf
try:
import tensorflow.compat.v1 as tf
import tf_slim as slim
except ImportError:
import tensorflow as tf
import tensorflow.contrib.slim as slim

import numpy as np
import tensorflow.contrib.slim as slim



Expand Down Expand Up @@ -59,4 +64,4 @@ def unet_generator(inputs, channel=32, num_blocks=4, name='generator', reuse=Fal
if __name__ == '__main__':


pass
pass