如何解决如何在 GPU 上使用子进程进行批量推理?
我正在使用 YOLOv4 在 Colab 上训练对象检测模型。这是我用来在测试集上运行测试的:
#/test has images that we can test our detector on
test_folder = "/content/logorec/Worlds-2020-Logos/"
test_images = [f for f in os.listdir(test_folder) if f.endswith('.png')]
import random
img_path = ''
for i in range(0,len(test_images)):
img_path = test_folder + test_images[i];
!./darknet detect cfg/custom-yolov4-detector.cfg backup/custom-yolov4-detector_last.weights {img_path} -dont-show
imShow('predictions.jpg')
如您所见,问题在于它一次测试 1 个文件。对于非常大的测试集来说,这是非常低效的。有没有办法可以批量(同时)而不是按顺序运行推理?我目前可以使用 Tesla V100 GPU。
解决方法
是的,你可以。您必须通过路径将所有测试图像加载到 tf.dataset.Dataset 对象中。我不知道你从哪里得到 YoloV4,但我认为它必须提供一个函数来一次读取整个数据集对象。尝试打开文件 darknet
以找到它
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。