一、问题现象(附报错日志上下文):
使用昇腾模型压缩工具时报错
[ERROR][RecordScaleOffset][143] Invalid record file path。
二、软件版本:
-- CANN 版本: CANN 5.0.3
--Python 版本: Python 3.7.5
--操作系统版本 :Ubuntu 18.04
三、测试步骤:
下载昇腾模型压缩工具,参考sample对onnx模型进行量化
运行代码时出现record文件路径无效的问题
检查过文件权限,文件夹与record文件皆可读可写。
主函数代码:
def main():
print("[INFO] Do original model test:")
AP_top1, AR_top1 = onnx_forward(ori_model, 10)
config_file = './tmp/config.json'
skip_layers = []
batch_num = 2
amct.create_quant_config(config_file=config_file,
model_file=ori_model,
skip_layers=skip_layers,
batch_num=batch_num,
activation_offset=True,
config_defination=None)
scale_offset_record_file = './tmp/record.txt'
modified_model = './tmp/modified_model.onnx'
amct.quantize_model(config_file=config_file,
model_file=ori_model,
modified_onnx_file=modified_model,
record_file=scale_offset_record_file)
onnx_forward(modified_model, batch_num)
quant_model_path = './model/modified_RetinaNet_model_416.onnx'
amct.save_model(modified_onnx_file=modified_model,
record_file=scale_offset_record_file,
save_path=quant_model_path)
print('[INFO] Do quantized model test:')
new_AP_top1, new_AR_top1 = onnx_forward(quant_model_path, 10)
print('[INFO] ResNet101 before quantize AP_top1:{:>10} AR_top1:{:>10}'.format(AP_top1, AR_top1))
print('[INFO] ResNet101 after quantize AP_top1:{:>10} AR_top1:{:>10}'.format(new_AP_top1, new_AR_top1))
你好,quantize_model这个接口的record_file这个参数是要求是量化因子记录文件路径及名称两部分,
需要按照下面这种方式去传入参数
可以参考这种处理方式
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
已将参数修改
PATH = os.path.realpath('./')
OUTPUTS = os.path.join(PATH, 'outputs')
TMP = os.path.join(OUTPUTS, 'tmp')
config_file = './config/config.json'
scale_offset_record_file = os.path.join(TMP, 'record.txt')#'./tmp/record.txt'
modified_model = os.path.join(TMP, 'modified_model.onnx')
quant_model_path = os.path.join(OUTPUTS, 'modified_RetinaNet_model_608.onnx')
但仍然会出现上述问题
record文件只包含scale_w和offset_w两个值,且offset_w全是0
现在的报错是说你的record_file这个参数中的路径是无效的,你可以将TMP打印输出一下,看看是不是合法的路径
是合法的,路径就是我创建的tmp文件夹,我运行例程resnet_101的时候也会报这个错误
请确认onnxruntime 版本与资料中的一致
你好,请问该问题是否已经解决?当前暂时把该issue先关闭,如有需要,可以再打开,或者重新提新的issue,谢谢
登录 后才可以发表评论