RuntimeError: Could not export Python function call 'F'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__: E:\bolang\yolov7-coupling\utils\activations.py(65): forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(860): _slow_forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(887): _call_impl E:\bolang\yolov7-coupling\models\common.py(112): fuseforward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(860): _slow_forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(887): _call_impl E:\bolang\yolov7-coupling\models\yolo.py(744): forward_once E:\bolang\yolov7-coupling\models\yolo.py(707): forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(860): _slow_forward E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\nn\modules\module.py(887): _call_impl E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\jit\_trace.py(934): trace_module E:\anaconda\envs\pytorch-1.8.1\lib\site-packages\torch\jit\_trace.py(733): trace E:\bolang\yolov7-coupling\utils\torch_utils.py(363): __init__ E:\bolang\yolov7-coupling\detect.py(39): detect E:\bolang\yolov7-coupling\detect.py(196): <module>
时间: 2023-08-08 17:13:02 浏览: 275
解密Python中的描述符(descriptor)
这个错误是由于在导出模型时出现了问题。错误信息中提到了一个名为'F'的 Python 函数调用,但没有添加 `@script` 或 `@script_method` 注释。如果这是一个 `nn.ModuleList`,请将其添加到 `__constants__` 中。请检查您的代码中与这些部分相关的部分,并确保按照 PyTorch 的导出要求进行操作。
阅读全文