TensorRT с TensorFlow не получают результата при выводе

Я хочу использовать tensorrt для ускорения вывода модели тензорного потока. Но я не получил никакого результата, когда сделал это, вот мой код. Ячейки возврата и баллы - все None. Я неправильно использую TensorRT и tensorflow?

import tensorflow as tf
import tensorflow.contrib.tensorrt as trt
import os
from PIL import Image
import numpy as np

with tf.Session() as sess:
    with tf.gfile.GFile('model/ssd_inceptionv2.pb',  'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
    trt_graph = trt.create_inference_graph(
            input_graph_def=graph_def,
            outputs=["detection_boxes", "detection_classes"])
    output_node = tf.import_graph_def(
            trt_graph,
            return_elements=["detection_boxes", "detecction_classes"], name='')
    input = tf.get_default_graph().get_tensor_by_name('image_tensor:0')

    for root, dirs, files in os.walk('dataset/test'):
        for f in files:
            if not f.endswith('.jpg'):
                continue
            print f
            image = Image.open(os.path.join(root, f))
            print image
            image = image.resize((300, 300), Image.ANTIALIAS)
            im_width, im_height = image.size
            image = np.array(image.getdata()).reshape((im_height, im_width, 3)).astype(np.uint8)
            image = np.expand_dims(image, axis=0)
            boxes, scores = sess.run(output_node, feed_dict={input: image})
            boxes, scores = np.squeeze(boxes), np.squeeze(scores)
            print boxes, scores
            for i, s in enumerate(scores):
                if s > 0.5:
                    print boxes[i], s

person tidy    schedule 19.01.2019    source источник
comment
Вы смогли ее решить?   -  person Anurag Paul    schedule 07.08.2019


Ответы (1)


Проблема в определении output_node. Элементы return_elements должны быть определены как return_elments=["detection_boxes:0", "detection_classes:0"]

person amogh bhagwat    schedule 18.07.2019