ModelScope的pipeline加载自己训练的模型时出了问题怎么办?
您试试下面方法:
pipeline里的model='xxx' # xxx为保存训练时设置的work_dir在pipeline下加入下面代码
checkpoint = load_checkpoint(
p.model,
'/x/xxx/xxxx/xxxxx/best_accuracy_top-1_epoch_1.pth', # work_dir下的best开头的.pth文件
map_location='cpu')
if 'CLASSES' in checkpoint.get('meta', {}):
CLASSES = checkpoint['meta']['CLASSES']
p.model.CLASSES=CLASSES
# 后面使用pipeline推理
p('img_path')
-此回答整理自钉群“魔搭ModelScope开发者联盟群 ①”