-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Open
Labels
oncall: jitAdd this issue/PR to JIT oncall triage queueAdd this issue/PR to JIT oncall triage queue
Description
🐛 Describe the bug
When I use torchvision.models.detection.retinanet_resnet50_fpn() to generate the model, it raise error.
My code:
input_=torch.ones(3,300,400)
input_1 = torch.ones(3,500,400)
model=torchvision.models.detection.retinanet_resnet50_fpn()
print(model([input_, input_1])) # all outputs are empty list '[]'
model.cpu()
model.eval()
traced_model = torch.jit.trace(model, input_data)
torch.jit.save(traced_model, model_file)
Error log:
[{'boxes': tensor([], size=(0, 4), grad_fn=<StackBackward0>), 'scores': tensor([], grad_fn=<IndexBackward0>), 'labels': tensor([], dtype=torch.int64)}, {'boxes': tensor([], size=(0, 4), grad_fn=<StackBackward0>), 'scores': tensor([], grad_fn=<IndexBackward0>), 'labels': tensor([], dtype=torch.int64)}]
-------------------
Traceback (most recent call last):
File "/home/wangqian/torch_model_file_gen/run.py", line 43, in <module>
test_retinanet_resnet50_fpn_v2(weights=sys.argv[1])
File "/home/wangqian/torch_model_file_gen/run.py", line 41, in test_retinanet_resnet50_fpn_v2
convert_model(model, weights, [input_, input_1], model_file)
File "/home/wangqian/torch_model_file_gen/run.py", line 22, in convert_model
traced_model = torch.jit.trace(model, input_data)
File "/usr/local/lib/python3.10/dist-packages/torch/jit/_trace.py", line 806, in trace
return trace_module(
File "/usr/local/lib/python3.10/dist-packages/torch/jit/_trace.py", line 1074, in trace_module
module._c._create_method_from_trace(
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _slow_forward
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torchvision/models/detection/retinanet.py", line 606, in forward
images, targets = self.transform(images, targets)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _slow_forward
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torchvision/models/detection/transform.py", line 131, in forward
for k, v in t.items():
AttributeError: 'Tensor' object has no attribute 'items'. Did you mean: 'item'?
Versions
torch 2.2.1+cpu
torchaudio 2.2.1+cpu
torchvision 0.17.1+cpu
Metadata
Metadata
Assignees
Labels
oncall: jitAdd this issue/PR to JIT oncall triage queueAdd this issue/PR to JIT oncall triage queue