华为计算微信公众号
昇腾AI开发者公众号
华为计算微博
华为计算今日头条
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) /tmp/ipykernel_26663/2494281208.py in <cell line: 3>() 3 if infer_mode == 'image': 4 img_path = '4.jpg' ----> 5 infer_image(img_path, model, labels_dict, cfg) 6 elif infer_mode == 'camera': 7 infer_camera(model, labels_dict, cfg) /tmp/ipykernel_26663/663515810.py in infer_image(img_path, model, class_names, cfg) 57 img, scale_ratio, pad_size = preprocess_image(image, cfg) 58 # 模型推理 ---> 59 output = model.infer([img])[0] 60 61 output = torch.tensor(output) /usr/local/miniconda3/lib/python3.9/site-packages/ais_bench/infer/interface.py in infer(self, feeds, mode, custom_sizes) 160 elif mode == 'dymdims': 161 self.session.set_dynamic_dims(dyshapes) --> 162 return self.run(inputs, out_array=True) 163 164 class MemorySummary: /usr/local/miniconda3/lib/python3.9/site-packages/ais_bench/infer/interface.py in run(self, feeds, out_array) 92 else: 93 inputs = feeds ---> 94 outputs = self.session.run(self.outputs_names, inputs) 95 if out_array == True: 96 # convert to host tensor RuntimeError: [-1][ACL: general failure]
用的板子里自带的样例文件。把图片预处理换成了
def preprocess_image(image, cfg, bgr2rgb=True): """图片预处理""" img, scale_ratio, pad_size = letterbox(image, new_shape=cfg['input_shape']) if bgr2rgb: img = img[:, :, ::-1] img = img.transpose(2, 0, 1) # HWC2CHW img = np.ascontiguousarray(img, dtype=np.float32)/255.0 # 这里增加了/255.0,为了提高速度,sample样例这里的/255放到模型里面进去了 return img, scale_ratio, pad_size
我在原生的yolov5里添加了注意力机制,在pc上训练好后,pt转onnx,再用act转om,用样例代码尝试调用出错
model_path = 'best.om'
label_path = './1.txt'
此处best是我的om文件,1.txt是标签文件,图片路径改成了一张自己的测试集图片
本帖最后由 匿名用户 于 2023/12/25 09:41:14 编辑
我要发帖子
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) /tmp/ipykernel_26663/2494281208.py in <cell line: 3>() 3 if infer_mode == 'image': 4 img_path = '4.jpg' ----> 5 infer_image(img_path, model, labels_dict, cfg) 6 elif infer_mode == 'camera': 7 infer_camera(model, labels_dict, cfg) /tmp/ipykernel_26663/663515810.py in infer_image(img_path, model, class_names, cfg) 57 img, scale_ratio, pad_size = preprocess_image(image, cfg) 58 # 模型推理 ---> 59 output = model.infer([img])[0] 60 61 output = torch.tensor(output) /usr/local/miniconda3/lib/python3.9/site-packages/ais_bench/infer/interface.py in infer(self, feeds, mode, custom_sizes) 160 elif mode == 'dymdims': 161 self.session.set_dynamic_dims(dyshapes) --> 162 return self.run(inputs, out_array=True) 163 164 class MemorySummary: /usr/local/miniconda3/lib/python3.9/site-packages/ais_bench/infer/interface.py in run(self, feeds, out_array) 92 else: 93 inputs = feeds ---> 94 outputs = self.session.run(self.outputs_names, inputs) 95 if out_array == True: 96 # convert to host tensor RuntimeError: [-1][ACL: general failure]用的板子里自带的样例文件。把图片预处理换成了
def preprocess_image(image, cfg, bgr2rgb=True): """图片预处理""" img, scale_ratio, pad_size = letterbox(image, new_shape=cfg['input_shape']) if bgr2rgb: img = img[:, :, ::-1] img = img.transpose(2, 0, 1) # HWC2CHW img = np.ascontiguousarray(img, dtype=np.float32)/255.0 # 这里增加了/255.0,为了提高速度,sample样例这里的/255放到模型里面进去了 return img, scale_ratio, pad_size我在原生的yolov5里添加了注意力机制,在pc上训练好后,pt转onnx,再用act转om,用样例代码尝试调用出错
model_path = 'best.om'
label_path = './1.txt'
此处best是我的om文件,1.txt是标签文件,图片路径改成了一张自己的测试集图片