[to #42322933] fix cv-action-recongnition-pipeline run inference with the cpu

修复识别模型CPU 加载推理问题
        Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9279667
This commit is contained in:
yongfei.zyf
2022-07-05 20:16:10 +08:00
committed by yingda.chen
parent 3cbc04c6f6
commit f9a2383bfe

View File

@@ -33,7 +33,8 @@ class ActionRecognitionPipeline(Pipeline):
'cuda' if torch.cuda.is_available() else 'cpu')
self.infer_model = BaseVideoModel(cfg=self.cfg).to(self.device)
self.infer_model.eval()
self.infer_model.load_state_dict(torch.load(model_path)['model_state'])
self.infer_model.load_state_dict(
torch.load(model_path, map_location=self.device)['model_state'])
self.label_mapping = self.cfg.label_mapping
logger.info('load model done')