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

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

Open
hugoycj opened this issue Jan 20, 2021 · 1 comment

Comments

@hugoycj
Copy link

hugoycj commented Jan 20, 2021

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

@duACGN
Copy link

duACGN commented Oct 8, 2022

我发现这段代码会一直返回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

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

2 participants