I try to use inference_and_visualization.ipynb for visualization. However, when run the code as follow:
output = model.cuda()(image[None].cuda())output = postprocessors['bbox'](output, torch.Tensor([[1.0, 1.0]]).cuda())[0]
File /usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py:1051, in Module._call_impl(self, *input, *kwargs)
1047 # If we don't have any hooks, we want to skip the rest of the logic in
1048 # this function, and just call forward.
1049 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1050 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1051 return forward_call(input, **kwargs)
1052 # Do not call functions when jit is used
1053 full_backward_hooks, non_full_backward_hooks = [], []
File /hy-tmp/DINO/models/dino/dino.py:267, in DINO.forward(self, samples, targets)
262 poss.append(pos_l)
265 if self.dn_number > 0 or targets is not None:
266 input_query_label, input_query_bbox, attn_mask, dn_meta =\
--> 267 prepare_for_cdn(dn_args=(targets, self.dn_number, self.dn_label_noise_ratio, self.dn_box_noise_scale),
268 training=self.training,num_queries=self.num_queries,num_classes=self.num_classes,
269 hidden_dim=self.hidden_dim,label_enc=self.label_enc)
270 else:
271 assert targets is None
File /hy-tmp/DINO/models/dino/dn_components.py:36, in prepare_for_cdn(dn_args, training, num_queries, num_classes, hidden_dim, label_enc)
34 # positive and negative dn queries
35 dn_number = dn_number * 2
---> 36 known = [(torch.ones_like(t['labels'])).cuda() for t in targets]
37 batch_size = len(known)
38 known_num = [sum(k) for k in known]
I try to use inference_and_visualization.ipynb for visualization. However, when run the code as follow:
output = model.cuda()(image[None].cuda())
output = postprocessors['bbox'](output, torch.Tensor([[1.0, 1.0]]).cuda())[0]
it get error as follow:
`--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Input In [69], in <cell line: 1>() ----> 1 output = model.cuda()(image[None].cuda()) 2 output = postprocessors['bbox'](output, torch.Tensor([[1.0, 1.0]]).cuda())[0]
File /usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py:1051, in Module._call_impl(self, *input, *kwargs) 1047 # If we don't have any hooks, we want to skip the rest of the logic in 1048 # this function, and just call forward. 1049 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks 1050 or _global_forward_hooks or _global_forward_pre_hooks): -> 1051 return forward_call(input, **kwargs) 1052 # Do not call functions when jit is used 1053 full_backward_hooks, non_full_backward_hooks = [], []
File /hy-tmp/DINO/models/dino/dino.py:267, in DINO.forward(self, samples, targets) 262 poss.append(pos_l) 265 if self.dn_number > 0 or targets is not None: 266 input_query_label, input_query_bbox, attn_mask, dn_meta =\ --> 267 prepare_for_cdn(dn_args=(targets, self.dn_number, self.dn_label_noise_ratio, self.dn_box_noise_scale), 268 training=self.training,num_queries=self.num_queries,num_classes=self.num_classes, 269 hidden_dim=self.hidden_dim,label_enc=self.label_enc) 270 else: 271 assert targets is None
File /hy-tmp/DINO/models/dino/dn_components.py:36, in prepare_for_cdn(dn_args, training, num_queries, num_classes, hidden_dim, label_enc) 34 # positive and negative dn queries 35 dn_number = dn_number * 2 ---> 36 known = [(torch.ones_like(t['labels'])).cuda() for t in targets] 37 batch_size = len(known) 38 known_num = [sum(k) for k in known]
TypeError: 'NoneType' object is not iterable`