import tensorflow as tf from style_transfer import StyleTransfer import utils # enable eager execution tf.enable_eager_execution() print('Eager execution: {}'.format(tf.executing_eagerly())) painter = StyleTransfer() threshold = painter.miss_percentage_threshold while True: best_img, miss_percentage = painter.run() if best_img is not None: utils.remove_earlier_checkpoints('./checkpoints') if miss_percentage > threshold: painter.learning_rate = painter.learning_rate * painter.lr_decay_rate
st = StyleTransfer(sess, net, ITERATIONS, CONTENT_LAYERS, STYLE_LAYERS, content_image, style_image, CONTENT_LAYER_WEIGHTS, STYLE_LAYER_WEIGHTS, CONTENT_LOSS_WEIGHT, STYLE_LOSS_WEIGHT, TV_LOSS_WEIGHT, OPTIMIZER, learning_rate=LEARNING_RATE, init_img_type=INIT_TYPE, preserve_colors=PRESERVE_COLORS, cvt_type=CVT_TYPE, content_factor_type=CONTENT_FACTOR_TYPE, save_it=SAVE_IT, save_it_dir=SAVE_IT_DIR) mixed_image = st.run() summary = st.loss_summary() sess.close() save_image(mixed_image, OUTPUT_IMAGE_PATH) with open(LOSS_SUMMARY_PATH, "wb") as handle: pickle.dump(summary, handle, protocol=pickle.HIGHEST_PROTOCOL)
from style_transfer import StyleTransfer if __name__ == '__main__': ST = StyleTransfer('input/style1.jpg', 'input/face.jpg', 'input/mask_style1.jpg', 'input/mask_face.jpg') ST.run()