-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.py
More file actions
executable file
·40 lines (30 loc) · 1.02 KB
/
custom.py
File metadata and controls
executable file
·40 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import numpy as np
import tensorflow as tf
from tensorflow.contrib import predictor
from pathlib import Path
from config import *
from helper import *
from utils import *
from model_fn import *
tf.enable_eager_execution()
def main(unused_argv):
# Export model_fn to only use decoder
export_tf_model(FLAGS.export_path)
# Find latest frozen pb
subdirs = [x for x in Path(FLAGS.export_path + '/frozen_pb').iterdir()
if x.is_dir() and 'temp' not in str(x)]
latest = str(sorted(subdirs)[-1])
# Create predictor
predict_fn = predictor.from_saved_model(latest)
# Read image
x = load_img('./imgs/human.jpg')[None] / 255.0
dict_in = {'x': x, 'z': np.zeros(z_dim)[None]}
# Make predictions and fetch results from output dict
predictions = predict_fn(dict_in)
x = predictions['x']
y = predictions['y']
# Show all source v.s. generated results
compare(x, y)
if __name__ == '__main__':
tf.app.flags.DEFINE_string('mode', 'TEST', 'TRAIN/TEST')
tf.app.run()