KaihuaTang / Scene-Graph-Benchmark.pytorch

A new codebase for popular Scene Graph Generation methods (2020). Visualization & Scene Graph Extraction on custom images/datasets are provided. It's also a PyTorch implementation of paper “Unbiased Scene Graph Generation from Biased Training CVPR 2020”
MIT License
1.03k stars 228 forks source link

使用coco数据集预训练faster-rcnn #68

Open Dong-G12 opened 3 years ago

Dong-G12 commented 3 years ago

你好,当我使用coco数据集预训练模型时出现以下错误,我改了类别数,改成了coco数据集的81类,其他没有改,想请问一下还需要改什么参数吗? Traceback (most recent call last): File "tools/detector_pretrain_net.py", line 313, in main() File "tools/detector_pretrain_net.py", line 306, in main model = train(cfg, args.local_rank, args.distributed, logger) File "tools/detector_pretrainnet.py", line 97, in train for iteration, (images, targets, ) in enumerate(train_data_loader, start_iter): File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in next data = self._next_data() File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data return self._process_data(data) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data data.reraise() File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/_utils.py", line 394, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 0. Original Traceback (most recent call last): File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/data/datasets/coco.py", line 94, in getitem target = target.clip_to_image(remove_empty=True) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/structures/bounding_box.py", line 246, in clip_to_image return self[keep] File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/structures/bounding_box.py", line 231, in getitem bbox.add_field(k, v[item]) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/structures/segmentation_mask.py", line 553, in getitem selected_instances = self.instances.getitem(item) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/structures/segmentation_mask.py", line 462, in getitem selected_polygons.append(self.polygons[i]) IndexError: list index out of range

/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/optim/lr_scheduler.py:110: UserWarning: Seems like optimizer.step() has been overridden after learning rate scheduler initialization. Please, make sure to call optimizer.step() before lr_scheduler.step(). See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate warnings.warn("Seems like optimizer.step() has been overridden after learning rate scheduler " Traceback (most recent call last): File "tools/detector_pretrain_net.py", line 313, in main() File "tools/detector_pretrain_net.py", line 306, in main model = train(cfg, args.local_rank, args.distributed, logger) File "tools/detector_pretrain_net.py", line 111, in train loss_dict = model(images, targets) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, kwargs) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 447, in forward output = self.module(*inputs[0], *kwargs[0]) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, kwargs) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py", line 52, in forward x, result, detector_losses = self.roi_heads(features, proposals, targets, logger) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, *kwargs) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py", line 27, in forward x, detections, loss_box = self.box(features, proposals, targets) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, **kwargs) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/box_head.py", line 85, in forward proposals = self.samp_processor.subsample(proposals, targets) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/sampling.py", line 95, in subsample labels, attributes, regression_targets, matched_idxs = self.prepare_targets(proposals, targets) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/sampling.py", line 53, in prepare_targets matched_targets = self.match_targets_to_proposals( File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/modeling/roi_heads/box_head/sampling.py", line 38, in match_targets_to_proposals target = target.copy_with_fields(["labels", "attributes"]) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/Scene-Graph-Benchmark.pytorch/maskrcnn_benchmark/structures/bounding_box.py", line 275, in copy_with_fields raise KeyError("Field '{}' not found in {}".format(field, self)) KeyError: "Field 'attributes' not found in BoxList(num_boxes=2, image_width=600, image_height=899, mode=xyxy)" Traceback (most recent call last): File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/distributed/launch.py", line 263, in main() File "/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/lib/python3.8/site-packages/torch/distributed/launch.py", line 258, in main raise subprocess.CalledProcessError(returncode=process.returncode, subprocess.CalledProcessError: Command '['/media/user2/yjd1/anaconda3/envs/scene_graph_benchmark/bin/python', '-u', 'tools/detector_pretrain_net.py', '--local_rank=1', '--config-file', 'configs/e2e_relation_detector_X_101_32_8_FPN_1x.yaml', 'SOLVER.IMS_PER_BATCH', '4', 'TEST.IMS_PER_BATCH', '2', 'DTYPE', 'float16', 'SOLVER.MAX_ITER', '50000', 'SOLVER.STEPS', '(30000, 45000)', 'SOLVER.VAL_PERIOD', '2000', 'SOLVER.CHECKPOINT_PERIOD', '2000', 'MODEL.RELATION_ON', 'False', 'OUTPUT_DIR', '/media/user2/yjd1/anaconda3/envs/checkpoints/pretrained_coco', 'SOLVER.PRE_VAL', 'False']' returned non-zero exit status 1.

KaihuaTang commented 3 years ago

一些数据集的annotation应该也要改,参考https://github.com/KaihuaTang/Scene-Graph-Benchmark.pytorch/blob/master/DATASET.md 中涉及到的几个文件

Dong-G12 commented 3 years ago

好的,非常感谢!

liu-hx commented 3 years ago

@Dong-G12 想问下您解决这个问题了嘛,我也在尝试用coco预训练,但不是很清楚数据集要怎么处理