Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting TorchVision MobilenetV3 SSD-Lite #5928

Open
anderflash opened this issue Mar 5, 2025 · 0 comments
Open

Exporting TorchVision MobilenetV3 SSD-Lite #5928

anderflash opened this issue Mar 5, 2025 · 0 comments

Comments

@anderflash
Copy link

error log | 日志或报错信息 | ログ

terminate called after throwing an instance of 'c10::Error'
  what():  forward() Expected a value of type 'List[Tensor]' for argument 'images.1' but instead found type 'Tensor'.
Position: 1
Declaration: forward(__torch__.torchvision.models.detection.ssd.SSD self.1, Tensor[] images.1, Dict(str, Tensor)[]? targets.1) -> ((Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor) 5494)
Exception raised from checkArg at /project/pytorch-v2.5.0/aten/src/ATen/core/function_schema_inl.h:17 (most recent call first):
frame #0: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x2d76da0]
frame #1: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x2d765e9]
frame #2: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x4a41f5]
frame #3: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x80f07c]
frame #4: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x80f24f]
frame #5: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x80f51e]
frame #6: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x28d3507]
frame #7: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x5f1c87]
frame #8: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x619104]
frame #9: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x4acad9]
frame #10: <unknown function> + 0x2a1ca (0x7fc6981431ca in /lib/x86_64-linux-gnu/libc.so.6)
frame #11: __libc_start_main + 0x8b (0x7fc69814328b in /lib/x86_64-linux-gnu/libc.so.6)
frame #12: /home/acmt/conda/envs/sy-bm-people-counter/lib/python3.12/site-packages/pnnx/pnnx() [0x4f4f57]

context | 编译/运行环境 | バックグラウンド

Hi,

I'm trying to export the official TorchVision's MobileV3 SSD-lite. However I get the above error. The function ssdlite320_mobilenet_v3_large returns a SSD instance, which contains

    def forward(
        self, images: List[Tensor], targets: Optional[List[Dict[str, Tensor]]] = None
    ) -> Tuple[Dict[str, Tensor], List[Dict[str, Tensor]]]:

So, is it the images type which is the culprit? The problem is that it calls Torchvision's transforms and backbone, which also receives this List[Tensor]. Since it's the official Torchvision code, I don't have control over that. So how to proceed?

how to reproduce | 复现步骤 | 再現方法

import torch
from torchvision.models.detection import (
    SSDLite320_MobileNet_V3_Large_Weights,
    ssdlite320_mobilenet_v3_large,
)
import pnnx


model = ssdlite320_mobilenet_v3_large(
    weights=SSDLite320_MobileNet_V3_Large_Weights.DEFAULT
)
x = torch.rand(1, 3, 320, 320)
model_scripted = torch.jit.script(model, x)
pnnx.export(model_scripted, "ssdlite320_mobilenet_v3_large.pt", x)

more | 其他 | その他

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant