【问题标题】:How to use subprocess on the GPU for batch inferencing?如何使用 GPU 上的子进程进行批量推理?
【发布时间】:2021-02-14 03:54:48
【问题描述】:

我正在使用 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。

【问题讨论】:

    标签: python tensorflow computer-vision object-detection yolo


    【解决方案1】:

    是的,你可以。您必须通过路径将所有测试图像加载到 tf.dataset.Dataset 对象中。我不知道你从哪里得到 YoloV4,但我认为它必须提供一个函数来一次读取整个数据集对象。尝试打开文件darknet找到它

    【讨论】:

    • 您能详细说明一下吗?加载数据集后我该怎么办?
    • darknet command 我假设它是一个 Python 脚本/包。其中应该有一个可以加载数据集的函数。您打开它,然后在您的笔记本中调用该函数。
    猜你喜欢
    • 1970-01-01
    • 2020-10-25
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-21
    • 2015-05-10
    相关资源
    最近更新 更多