server.py 文件源码

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

项目:woipv 作者: Panaetius 项目源码 文件源码
def __init__(self, host, port):
        serv_host = FLAGS.host
        serv_port = FLAGS.port
        model_name = FLAGS.model_name
        model_version = FLAGS.model_version
        self.request_timeout = FLAGS.request_timeout

        config = tf.ConfigProto(log_device_placement=False)
        config.gpu_options.allow_growth = True
        self.sess = tf.Session(config=config)

        init = tf.global_variables_initializer()

        config = Config()
        self.woipv = WoipvPspNetModel(config)

        self.input_tensor = tf.placeholder(tf.string, name="input_tensor")
        processed = tf.cast(tf.decode_raw(self.input_tensor, tf.uint8), tf.float32)
        processed = tf.reshape(processed, [288, 288, 3])
        self.image_op = processed
        processed = tf.image.per_image_standardization(processed)
        processed = tf.expand_dims(processed, axis=0)
        self.result_op = tf.nn.sigmoid(self.woipv.inference(processed))
        self.sess.run(init)

        ckpt = tf.train.get_checkpoint_state("/training/woipv_train")
        ckpt_name = os.path.basename(ckpt.model_checkpoint_path)

        variables_to_restore = tf.global_variables()
        chkpt_saver = tf.train.Saver(variables_to_restore,
                        write_version=tf.train.SaverDef.V2)
        chkpt_saver.restore(self.sess, ckpt.model_checkpoint_path)

        self._host = host
        self._port = port
        self._app = bottle.Bottle()
        self._route()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号