image's input and output
Closed this issue · 1 comments
sun0912704 commented
ISosnovik commented
If you have a saved model, you need to google for how to restore from checkpoint and and how to use it with tensorflow
In results.ipynb I show how to calculate accuracy.
In the same way you can extract predictions and ground truth
#import everything
import tensorflow.compat.v1 as tf
tf.compat.v1.disable_eager_execution()
from keras.backend import learning_phase
import conv_model
import data_utils
import sampler_utils
# configure
input_size = 40
dataset_path = 'top_dataset.h5'
batch_size = 64
num_val_step = 10
model_path = 'WHERE_YOU_SAVED_THE_MODEL'
# get the model
model = conv_model.build()
input_data = tf.placeholder(tf.float32, (None, input_size, input_size, 2), name='input_data')
output_true = tf.placeholder(tf.float32, (None, input_size, input_size, 1), name='output_true')
with tf.variable_scope('topopt_model'):
output_pred = model(input_data)
# restore from checkpoint
sess = tf.InteractiveSession()
saver = tf.train.Saver()
saver.restore(sess, model_path)
# get what you need
for x, y in data_utils.DatasetIterator(dataset_path, batch_size, lambda: stop_iter):
feed_dict = {input_data: x, learning_phase(): 0}
y_pred = sess.run(output_pred, feed_dict=feed_dict)
# here x[:, :, :, 0] is input image
# x[:, :, :, 1] is input gradient
# y is ground truth
# y_pred is prediction