python - 如何将图像批次作为本地人传递给 profile.runctx?
问题描述
我想向profile.runctx
Ex发送一批图像
profile.runctx('print (inference(image_batch,batch_size)); print()',
globals(),
{'image_batch':'how to send image batch?','batch_size':128})
我有一个函数inference
,它接受一个序列图像批次作为输入。如何将一系列图像作为参数传递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})
推荐阅读
- amazon-web-services - 文件网关与卷网关示例
- vue.js - 存储和检索用户角色
- r - 在 optim() R 函数中键入“关闭”错误
- wordpress - 如果 Wordpress 网站上 API 的 JSON 或 CSV 中存在 x 数据,如何返回 true
- javascript - 单击第二个退出时,YouTube 屏幕应该变黑
- shell - shell 脚本从输出中删除重复的列
- javascript - Web3js 签名交易
- java - 如何在 Java 中自定义排序列表
- java - Java 净现值
- javascript - 如何在 React 中登录页面后配置侧边栏导航中的路由?