RedisAI无法将模型作为blob加载。如何排除故障?

2024-06-28 20:31:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Python运行以下代码:

import redis 
conn = redis.Redis(host=url.hostname, port=url.port)

with open('models/tiny-yolo-voc.pb', 'rb') as f:
        model = f.read()
        res = conn.execute_command('AI.MODELSET', 'yolo:model', 'TF', args.device, 'INPUTS', 'input', 'OUTPUTS', 'output', model)

并得到一个错误:

Exception has occurred: ResponseError Insufficient arguments, missing model BLOB File "/home/baruchk/EdgeRealtimeVideoAnalytics/app/init.py", line 36, in res = conn.execute_command('AI.MODELSET', 'yolo:model', 'TF', args.device, 'INPUTS', 'input', 'OUTPUTS', 'output', model)

查看调试器,我可以看到模型,如下所示:

b'version https://git-lfs.github.com/spec/v1\noid sha256:5a48ca053cf228a10023f11f92274efdaac7a0f991d7f15066add62523612137\nsize 63481382\n'

有人知道发生了什么吗?我加载模型的方式是否有问题?格式


Tags: redisurlexecutemodelportdevicetfargs
1条回答
网友
1楼 · 发布于 2024-06-28 20:31:46

我相信你忘记了BLOB关键字。请参见docs中的此处。 所以你的代码应该是

import redis 
conn = redis.Redis(host=url.hostname, port=url.port)

with open('models/tiny-yolo-voc.pb', 'rb') as f:
        model = f.read()
        res = conn.execute_command('AI.MODELSET', 'yolo:model', 'TF', args.device, 'INPUTS', 'input', 'OUTPUTS', 'output', 'BLOB', model)

相关问题 更多 >