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

出现了个错误:An error occurred: '>' not supported between instances of 'NoneType' and 'int' #18

Open
Yiyang7869 opened this issue Oct 22, 2023 · 7 comments

Comments

@Yiyang7869
Copy link

我是初学者,运行代码时出现了个错误:An error occurred: '>' not supported between instances of 'NoneType' and 'int'
下面是运行的过程

[10/22 19:13:14 detectron2]: Command line arguments: Namespace(config_file='./configs/coco/instance-segmentation/Fast-COCO-InstanceSegmentation.yaml', dist_url='tcp://127.0.0.1:49152', eval_only=False, machine_rank=0, num_gpus=1, num_machines=1, opts=[], resume=False)
[10/22 19:13:14 detectron2]: Contents of args.config_file=./configs/coco/instance-segmentation/Fast-COCO-InstanceSegmentation.yaml:
[10/22 19:13:14 detectron2]: Full config saved to ./output/config.yaml
[10/22 19:13:20 d2.engine.defaults]: Model:
[10/22 19:13:20 fastinst.data.dataset_mappers.fastinst_instance_dataset_mapper]: [FastInstInstanceDatasetMapper] Augmentations used in training: [ResizeShortestEdge(short_edge_length=(416, 448, 480, 512, 544, 576, 608, 640), max_size=853, sample_style='choice'), RandomFlip()]
[10/22 19:13:39 d2.data.datasets.coco]: Loading datasets/coco/annotations/instances_train2017.json takes 18.91 seconds.
[10/22 19:13:40 d2.data.datasets.coco]: Loaded 118287 images in COCO format from datasets/coco/annotations/instances_train2017.json
[10/22 19:13:47 d2.data.build]: Removed 1021 images with no usable annotations. 117266 images left.
[10/22 19:13:51 d2.data.build]: Distribution of instances among all 80 categories:
[10/22 19:13:51 d2.data.build]: Using training sampler TrainingSampler
[10/22 19:13:51 d2.data.common]: Serializing the dataset using: <class 'detectron2.data.common._TorchSerializedList'>
[10/22 19:13:51 d2.data.common]: Serializing 117266 elements to byte tensors and concatenating them all ...
[10/22 19:13:54 d2.data.common]: Serialized dataset takes 451.21 MiB
/
之后报错了
An error occurred: '>' not supported between instances of 'NoneType' and 'int'

@junjiehe96
Copy link
Owner

可以提供更详细的错误信息吗

@Yiyang7869
Copy link
Author

Traceback (most recent call last):
File "train_net.py", line 350, in
launch(
File "/root/autodl-tmp/project/detectron2/engine/launch.py", line 86, in launch
main_func(*args)
File "train_net.py", line 342, in main
trainer = Trainer(cfg)
File "/root/autodl-tmp/project/detectron2/engine/defaults.py", line 380, in init
data_loader = self.build_train_loader(cfg)
File "train_net.py", line 155, in build_train_loader
return build_detection_train_loader(cfg, mapper=mapper)
File "/root/autodl-tmp/project/detectron2/config/config.py", line 209, in wrapped
return orig_func(**explicit_args)
File "/root/autodl-tmp/project/detectron2/data/build.py", line 549, in build_detection_train_loader
return build_batch_data_loader(
File "/root/autodl-tmp/project/detectron2/data/build.py", line 339, in build_batch_data_loader
data_loader = torchdata.DataLoader(
File "/root/miniconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 183, in init
assert prefetch_factor > 0
TypeError: '>' not supported between instances of 'NoneType' and 'int'

@junjiehe96
Copy link
Owner

Traceback (most recent call last): File "train_net.py", line 350, in launch( File "/root/autodl-tmp/project/detectron2/engine/launch.py", line 86, in launch main_func(*args) File "train_net.py", line 342, in main trainer = Trainer(cfg) File "/root/autodl-tmp/project/detectron2/engine/defaults.py", line 380, in init data_loader = self.build_train_loader(cfg) File "train_net.py", line 155, in build_train_loader return build_detection_train_loader(cfg, mapper=mapper) File "/root/autodl-tmp/project/detectron2/config/config.py", line 209, in wrapped return orig_func(**explicit_args) File "/root/autodl-tmp/project/detectron2/data/build.py", line 549, in build_detection_train_loader return build_batch_data_loader( File "/root/autodl-tmp/project/detectron2/data/build.py", line 339, in build_batch_data_loader data_loader = torchdata.DataLoader( File "/root/miniconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 183, in init assert prefetch_factor > 0 TypeError: '>' not supported between instances of 'NoneType' and 'int'

抱歉,我没有遇到过这种问题,似乎与detectron2版本有关facebookresearch/detectron2#5086 (comment)

@Yiyang7869
Copy link
Author

非常感谢您的回复,再次谢谢您

@wxm000000
Copy link

您好,我也遇到了这个问题,请问您解决了吗? @Yiyang7869

@Yiyang7869
Copy link
Author

Yiyang7869 commented Oct 28, 2023

已经解决了,应该是prefetch_factor=None 出现了问题(build.py),我的解决方法是将 prefetch_factor 改为一个整数 (默认是 2)(detection2.data.build.py文件中)@wxm000000

@wxm000000
Copy link

好的,谢谢!直接把prefetch_factor那三行注释掉也可以!

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

3 participants