aim-uofa / AdelaiDet

AdelaiDet is an open source toolbox for multiple instance-level detection and recognition tasks.
https://git.io/AdelaiDet
Other
3.37k stars 646 forks source link

RuntimeError: non-empty 3D or 4D (batch mode) tensor expected for input, but got: [ torch.cuda.FloatTensor{0,1,200,200} ] #284

Closed zeeshanalipanhwar closed 3 years ago

zeeshanalipanhwar commented 3 years ago

Hi,

I am using CondInst for Multi-class Instance Segmentation for a custom dataset.

Here is what the log for inference looks like from the bottom.

[01/04 11:01:25 d2.data.dataset_mapper]: [DatasetMapper] Augmentations used in inference: [ResizeShortestEdge(short_edge_length=(800, 800), max_size=1333, sample_style='choice')]
[01/04 11:01:25 d2.data.common]: Serializing 1024 elements to byte tensors and concatenating them all ...
[01/04 11:01:26 d2.data.common]: Serialized dataset takes 189.13 MiB
WARNING [01/04 11:01:26 d2.evaluation.coco_evaluation]: COCO Evaluator instantiated using config, this is deprecated behavior. Please pass tasks in directly
[01/04 11:01:29 d2.evaluation.evaluator]: Start inference on 1024 images
/content/AdelaiDet/adet/modeling/fcos/fcos_outputs.py:460: UserWarning: This overload of nonzero is deprecated:
    nonzero()
Consider using one of the following signatures instead:
    nonzero(*, bool as_tuple) (Triggered internally at  /pytorch/torch/csrc/utils/python_arg_parser.cpp:882.)
  per_candidate_nonzeros = per_candidate_inds.nonzero()
Traceback (most recent call last):
  File "tools/train_net.py", line 218, in <module>
    args=(args,),
  File "/usr/local/lib/python3.6/dist-packages/detectron2/engine/launch.py", line 62, in launch
    main_func(*args)
  File "tools/train_net.py", line 189, in main
    res = Trainer.test(cfg, model) # d2 defaults.py
  File "/usr/local/lib/python3.6/dist-packages/detectron2/engine/defaults.py", line 534, in test
    results_i = inference_on_dataset(model, data_loader, evaluator)
  File "/usr/local/lib/python3.6/dist-packages/detectron2/evaluation/evaluator.py", line 141, in inference_on_dataset
    outputs = model(inputs)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/content/AdelaiDet/adet/modeling/condinst/condinst.py", line 96, in forward
    padded_im_h, padded_im_w
  File "/content/AdelaiDet/adet/modeling/condinst/condinst.py", line 208, in postprocess
    results.pred_global_masks, factor
  File "/content/AdelaiDet/adet/utils/comm.py", line 26, in aligned_bilinear
    tensor = F.pad(tensor, pad=(0, 1, 0, 1), mode="replicate")
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 3572, in _pad
    return torch._C._nn.replication_pad2d(input, pad)
RuntimeError: non-empty 3D or 4D (batch mode) tensor expected for input, but got: [ torch.cuda.FloatTensor{0,1,200,200} ]
Syzygianinfern0 commented 3 years ago

What is the solution to this bug?

tianzhi0549 commented 3 years ago

@Syzygianinfern0 @zeeshanalipanhwar it seems that this image has no predicted masks. You can skip these images.