当前位置: 首页>>代码示例>>Python>>正文


Python Model.create_graph方法代码示例

本文整理汇总了Python中Model.Model.create_graph方法的典型用法代码示例。如果您正苦于以下问题:Python Model.create_graph方法的具体用法?Python Model.create_graph怎么用?Python Model.create_graph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.Model的用法示例。


在下文中一共展示了Model.create_graph方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DatasetLoader

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import create_graph [as 别名]
FLAGS = flags.FLAGS
flags.DEFINE_integer('batch_size', 100, 'batch size')
flags.DEFINE_string('test_files_glob', './input/test*.tfrecords', 'glob for TFRecords files containing testing data')
flags.DEFINE_string('model_file', './model.ckpt', 'path to load trained model parameters from')
flags.DEFINE_integer('read_threads', multiprocessing.cpu_count(), 'number of reading threads')
flags.DEFINE_string('summary', './tensorboard_test', 'Tensorboard output directory')

# Testing input
dataset_loader = DatasetLoader()
keep_prob_holder = tf.placeholder(tf.float32, shape = ())
image_batch, label_batch = dataset_loader.input_batch(
    glob(FLAGS.test_files_glob), FLAGS.batch_size, FLAGS.read_threads)
label_batch = tf.cast(label_batch, tf.float32)

# Model, correctness predicate, and correctness aggregator
inferred_labels = Model.create_graph(image_batch, keep_prob_holder)
correct_prediction = tf.equal(tf.argmax(inferred_labels, 1), tf.argmax(tf.cast(label_batch, tf.float32), 1))
accuracy_op = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
correct_images = tf.boolean_mask(image_batch, correct_prediction)
incorrect_images = tf.boolean_mask(image_batch, tf.logical_not(correct_prediction))
tf.summary.image('Correct Inference', correct_images, max_outputs = 20)
tf.summary.image('Incorrect Inference', incorrect_images, max_outputs = 20)

# Run graph
average = Average()
TFRunner.run(
    accuracy_op,
    feed_dict = {keep_prob_holder: 1.0},
    restore_checkpoint = FLAGS.model_file,
    batch_result_callback = average.add,
    summary = FLAGS.summary,
开发者ID:lightcycle,项目名称:MachineLearning,代码行数:33,代码来源:Test.py

示例2: Flask

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import create_graph [as 别名]
from flask import Flask, jsonify, render_template, request
import tensorflow as tf
import sys
sys.path.append('../train')
from Model import Model

app = Flask(__name__)

keep_prob_placeholder = tf.constant(1.0, tf.float32)
image_placeholder = tf.placeholder(tf.uint8, [None, 256, 256, 3])
output = Model.create_graph(image_placeholder, keep_prob_placeholder)

sess = tf.Session()

saver = tf.train.Saver(sharded=True)
saver.restore(sess, '../train/model.ckpt')


def infer(image):
    return sess.run(output, feed_dict={image_placeholder: image}).flatten().tolist()


def process_jpeg(stream):
    image = tf.image.decode_jpeg(stream.getvalue(), channels=3)
    image.set_shape([258, 344, 3])
    image = tf.image.resize_image_with_crop_or_pad(image, 256, 256)
    image = tf.expand_dims(image, 0)
    return image.eval(session = sess)


@app.route('/api/photo_orientation', methods=['POST'])
开发者ID:lightcycle,项目名称:MachineLearning,代码行数:33,代码来源:Demo.py


注:本文中的Model.Model.create_graph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。