EvaluationModel.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:A-Neural-Algorithm-of-Artistic-Style 作者: kbedi95 项目源码 文件源码
def __init__(self, content_path, style_path):

        # 4D representations of the given content and style images
        self.content_image = utils.preprocess(plt.imread(content_path))[np.newaxis]
        self.style_image = utils.preprocess(plt.imread(style_path))[np.newaxis]

        # The session and graph used for evaluating the content and style of the
        # given content and style images
        self.evaluation_g = tf.Graph()
        self.evaluation_sess = tf.Session(graph=self.evaluation_g)

        # The outputs (:0) of the intermediate layers of the VGG16 model used to represent the
        # content and style of an input to the model
        self.content_layer = config["content_layer"]
        self.style_layers = config["style_layers"]

        with self.evaluation_g.as_default():

            # Import the VGG16 ImageNet predictor model graph into the evaluation_g member variable
            tf.import_graph_def(utils.get_vgg_model(), name="vgg")

            # The input to the VGG16 predictor model is the output (:0) of the first operation of the graph
            self.input_tensor = [op.name for op in self.evaluation_g.get_operations()][0] + ":0"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号