【发布时间】:2021-03-03 01:48:27
【问题描述】:
我有一个训练有素的 RCNN (Keras-Retinanet) 模型,我一次只能预测一张图像。
boxes, scores, labels = model.predict_on_batch(np.expand_dims(image, axis=0))
完整的脚本是here。
有没有办法一次预测多张图像?
谢谢
【问题讨论】:
标签: tensorflow keras prediction faster-rcnn
我有一个训练有素的 RCNN (Keras-Retinanet) 模型,我一次只能预测一张图像。
boxes, scores, labels = model.predict_on_batch(np.expand_dims(image, axis=0))
完整的脚本是here。
有没有办法一次预测多张图像?
谢谢
【问题讨论】:
标签: tensorflow keras prediction faster-rcnn
您在那里扩展 dims 的原因是为了人为地添加批处理维度。只需将一堆图像堆叠在一起,然后将其传递给此函数即可得到一批结果。
换一种说法,现在你正在传递: [图片]。
您可以改为传入: [image_1, image_2, image_3, ...](作为一个 numpy,而不是 python 数组)
【讨论】:
File "detector.py", line 85, in <module> boxes, scores, labels = model.predict_on_batch(image, image1, image2, image3) TypeError: predict_on_batch() takes 2 positional arguments but 5 were given
imgs = [] imgs.append(image) imgs.append(image1) 并得到这个错误ValueError: Input 0 of layer conv1 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [800, 800, 3]