Я обучен набору данных для сценария обучения подделке лица, так как он разработан на tenorflow 1.4, и, согласно моему пониманию, сценарий подготовки тензорного потока и сценарий вывода различны, поэтому я не могу сохранить модель из контрольной точки для репозитория ниже. или направление того, как это сделать, очень помогло бы.
https://github.com/yaojieliu/ECCV2018-FaceDeSpoofing
import data_train
import Architecture as arch
import cv2
import tensorflow as tf
import os
trained_checkpoint_prefix = 'checkpoints2\\model.ckpt-18'
export_dir = os.path.join('models', '12')
chk_dir = 'ECCV-Dec\\checkpoints2D'
width = 256
height = 256
depth = 3
loaded_graph = tf.Graph()
with tf.Session(graph=loaded_graph) as sess:
# Restore from checkpoints
labels = [1]
inputs = tf.placeholder(tf.float32, [None, None, 3], name="input")
# inputs = tf.placeholder(tf.float32, [256, 256, 3], name="concat")
img = tf.reshape(inputs, [256, 256, 3]) / 256
#disorted_image = tf.cast(tf.transpose(img, [1, 2, 0]), tf.float32) / 256
hsv_image = tf.image.rgb_to_hsv(img)
float_image = tf.concat([hsv_image, img], axis=2)
float_image.set_shape([256, 256, 6])
num_preprocess_threads = 16
images_, labels = tf.train.batch([float_image, labels], batch_size=6, capacity=4+(3*6),num_threads=num_preprocess_threads)
slabels = labels
Label_Amin = labels
# using inference method Arcitecture.py file
dmaps, smaps, sc, dmaps_1, smaps_1, A, B, bin_labels, Nsc, Lsc, Allsc, sc_fake, sc_real, conv11_fir = arch.inference(images_, labels, labels, training_nn=True, training_class=False, _reuse=False)
bin_labels3 = tf.ones([6, 1])
#calculate cross entropy
cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=tf.reshape(tf.cast(bin_labels3, tf.int32), [-1]), logits=tf.cast(sc_fake, tf.float32),name='cross_entropy_per_example')
loss22 = tf.reduce_mean(cross_entropy, name='Mean_2')*1
loader = tf.train.import_meta_graph(trained_checkpoint_prefix + '.meta')
loader.restore(sess, trained_checkpoint_prefix)
#creating model I/O tensor infos
model_input = tf.saved_model.utils.build_tensor_info(inputs)
model_output = tf.saved_model.utils.build_tensor_info(loss22)
signature = tf.saved_model.signature_def_utils.build_signature_def(inputs={'images': model_input},outputs={'scores': model_output},method_name=tf.saved_model.signature_constants.REGRESS_METHOD_NAME)
builder.add_meta_graph_and_variables(sess,[tf.saved_model.tag_constants.SERVING],signature_def_map={'predict_images': signature})
builder.save()