soeaver/RP-R-CNN

ValueError: num_samples should be a positive integer value, but got num_samples=0

hugoycj opened this issue · 1 comments

Hello!

I am trying to train RP-R-CNN, but I encounter a problem when runing the training command following the Readme.md. When running

CUDA_VISIBLE_DEVICES=0 python tools/train_net.py --cfg cfgs/CIHP/e2e_rp_rcnn_R-50-FPN_3x_ms.yaml

I am getting the following message:

Traceback (most recent call last):
  File "tools/train_net.py", line 147, in <module>
    main()
  File "tools/train_net.py", line 127, in main
    train_loader = make_train_data_loader(datasets, is_distributed=args.distributed, start_iter=scheduler.iteration)
  File "/data/home/v_julhugoye/human_parsing/RP-R-CNN/rcnn/datasets/dataset.py", line 121, in make_train_data_loader
    sampler = make_data_sampler(datasets, shuffle, is_distributed)
  File "/data/home/v_julhugoye/human_parsing/RP-R-CNN/rcnn/datasets/dataset.py", line 66, in make_data_sampler
    sampler = torch.utils.data.sampler.RandomSampler(dataset)
  File "/data/home/v_julhugoye/.conda/envs/ParsingRCNN/lib/python3.6/site-packages/torch/utils/data/sampler.py", line 94, in __init__
    "value, but got num_samples={}".format(self.num_samples))
ValueError: num_samples should be a positive integer value, but got num_samples=0
Segmentation fault

So thanks for your help

我发现这段代码会一直返回False,导致过滤后的数据集是0

def has_valid_annotation(anno, ann_types, filter_crowd=True):
# if it's empty, there is no annotation
if len(anno) == 0:
    return False
if filter_crowd:
    # if image only has crowd annotation, it should be filtered
    if 'iscrowd' in anno[0]:
        anno = [obj for obj in anno if obj["iscrowd"] == 0]
if len(anno) == 0:
    return False
# if all boxes have close to zero area, there is no annotation
if _has_only_empty_bbox(anno):
    return False

return False