Keras / Tensorflow-批量生成imagenet的预测(我只得到一个结果)

问题描述 投票:0回答:2

我通过一次调用就为视频中的所有关键帧生成了imagenet标签,并具有以下代码:

 # all keras/tf/mobilenet imports
model_imagenet = MobileNetV2(weights='imagenet')

frames_list = []
for frame in frame_set:
    frame_img = frame.to_image()
    frame_pil = frame_img.resize((224,224), Image.ANTIALIAS)
    ts = int(frame.pts)
    x = image.img_to_array(frame_pil)
    x = np.expand_dims(x, axis=0)
    x = preprocess_input(x)
    frames_list.append(x)

print(len(frames_list))                

preds_list = model_imagenet.predict_on_batch(frames_list)
print("[*]",preds_list)

结果显示如下:

frames_list count: 125

因此,预测是一排1000维(图像网络类),难道不是125行吗?:

[[1.15425530e-04 1.83317825e-04 4.28701424e-05 2.87547664e-05
                    :
  7.91769926e-05 1.30803732e-04 4.81895368e-05 3.06891889e-04]]

这将为批处理中的单个行生成预测。我已经尝试了predictpredict_on_batch的相同结果。

如何通过Keras / Tensorflow / Mobilenet一次获得200帧的批量预测?

tensorflow keras image-recognition imagenet
2个回答
1
投票

ImageNet是一个流行的数据库,包含1000个不同的类别。


0
投票

[好,这是我解决的方法,希望这对其他人有帮助:

© www.soinside.com 2019 - 2024. All rights reserved.