Python 如何将图像批作为本地文件传递到profile.runctx?
我想向profile.runctx-Ex发送一批图像Python 如何将图像批作为本地文件传递到profile.runctx?,python,unit-testing,profiling,faster-rcnn,Python,Unit Testing,Profiling,Faster Rcnn,我想向profile.runctx-Ex发送一批图像 我有一个名为推断的函数,它接受序列图像作为输入。如何在profile.runctx中将一系列图像作为参数传递?您在问题的示例代码中遗漏了许多细节,但下面是一个猜测: import profile def inference(image_batches, size): for i in range(size): print('image_batches[{}]: {}'.format(i, image_batches
我有一个名为推断的函数,它接受序列图像作为输入。如何在profile.runctx中将一系列图像作为参数传递?您在问题的示例代码中遗漏了许多细节,但下面是一个猜测:
import profile
def inference(image_batches, size):
for i in range(size):
print('image_batches[{}]: {}'.format(i, image_batches[i]))
return 42
image_batch = ['image1', 'image2']
batch_size = 2
profile.runctx('print(inference(image_batch, batch_size)); print()',
globals(), locals())
或者,您可以做一些更明确的事情,例如:
profile.runctx('print(inference(image_batch, batch_size)); print()',
globals(), {'image_batch': ['image1', 'image2'],
'batch_size': 2})
profile.runctx('print(inference(image_batch, batch_size)); print()',
globals(), {'image_batch': ['image1', 'image2'],
'batch_size': 2})