Open wuxiaolianggit opened 2 years ago
您好,大佬,如何把人脸检测的模型转成torchscript模型啊 @djmmoss @muhammad-tayyab @hylrh2008 @bobo0810 @wjtan99
参考https://github.com/bobo0810/Classification/blob/main/Models/Backend/torchscript.py
@好的,大佬,多谢啊,我试一下啊 ,大佬我好像有你的微信。@ @bobo0810
Traceback (most recent call last):
File "D:/python_code/yolov5-face-master/detect_face_jit.py", line 152, in
_37, _38, _39, _40, = _36
return (_40, [_37, _38, _39])
File "code/__torch__/models/yolo.py", line 76, in forward
_53 = torch.sigmoid(torch.index(_49, _52))
_54 = torch.to(CONSTANTS.c0, torch.device("cuda"), 4, False, False, None)
_55 = torch.view(_53, [3, 100, 100, 6])
~~~~~~~~~~ <--- HERE
_56 = torch.to(_54, dtype=4, layout=0, device=torch.device("cuda:0"), pin_memory=None, non_blocking=False, copy=False, memory_format=None)
_57 = annotate(List[Optional[Tensor]], [None, None, None, None, _56])
Traceback of TorchScript, original code (most recent call last):
D:\python_code\yolov5-face-master\models\yolo.py(88): forward
E:\python_code\pytorch-image-classification\venv\lib\site-packages\torch\nn\modules\module.py(709): _slow_forward
E:\python_code\pytorch-image-classification\venv\lib\site-packages\torch\nn\modules\module.py(725): _call_impl
D:\python_code\yolov5-face-master\models\yolo.py(196): forward_once
D:\python_code\yolov5-face-master\models\yolo.py(180): forward
E:\python_code\pytorch-image-classification\venv\lib\site-packages\torch\nn\modules\module.py(709): _slow_forward
E:\python_code\pytorch-image-classification\venv\lib\site-packages\torch\nn\modules\module.py(725): _call_impl
E:\python_code\pytorch-image-classification\venv\lib\site-packages\torch\jit\_trace.py(934): trace_module
E:\python_code\pytorch-image-classification\venv\lib\site-packages\torch\jit\_trace.py(733): trace
D:/python_code/yolov5-face-master/export2.py(89): <module>
RuntimeError: shape '[3, 100, 100, 6]' is invalid for input of size 108000
转换成功,但是推理的时候会报错,这个怎么解决啊,大佬@ @bobo0810
尝试debug排查原因吧
好的,多谢大佬 @bobo0810
The model will generate face feature points (16 size vector) in addition to bounding box and non-max-suppression is a bit different than standard Yolov5. So if you plan to use torchscript model in another app, you need to add that functionality too, otherwise you will not be able to get good quality detections
Thank you for your reply. I understand. @muhammad-tayyab
您好,大佬,如何把人脸检测的模型转成torchscript模型啊 @djmmoss @muhammad-tayyab @hylrh2008 @bobo0810 @wjtan99