FCOS代码复现错误集合

在我复现无锚框检测神网络-FCOS时,官方代码—FCOS-master令我头疼不已,现将问题总结如下,仅供参考:
1.from fcos_core import _C
遇到这个问题抓耳挠腮了好久,尝试过各种方法,最后不得已,在文件所在目录下重新执行:

python setup.py build develop --no-deps

再次运行的时候,没有出现这个报错。
2.cv2.error: OpenCV(4.5.1) /tmp/pip-install-2f1_c8js/Opencv-python/opencv/modules/highgui/src/window.cpp:651: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvShowImage’

尝试了好几种解决方式,目前无解

  1. File “/home/damon/anaconda3/lib/python3.7/site-packages/yacs/config.py”, line 211, in merge_from_file
    with open(cfg_filename, “r”) as f:
    FileNotFoundError: [Errno 2] No such file or directory: ‘’

错误出现在train——net代码121行,没有放置相应的文件。

4。File “/home/damon/桌面/FCOS1/FCOS-master/fcos_core/config/paths_catalog.py”, line 117, in get
attrs = DatasetCatalog.DATASETS[name]
KeyError: ‘/home/damon/Datasets/coco2020/train2020’
2021-05-21 10:32:22,566 fcos_core.data.build WARNING: When using more than one image per GPU you may encounter an out-of-memory (OOM) error if your GPU does not have sufficient memory. If this happens, you can reduce SOLVER.IMS_PER_BATCH (for training) or TEST.IMS_PER_BATCH (for inference). For training, you must also adjust the learning rate and schedule length according to the linear scaling rule. See for example: https://github.com/facebookresearch/Detectron/blob/master/configs/getting_started/tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml#L14

Process finished with exit code 1

错误显示是内存不足,调整batch试一下。

这个错误一般是网速的问题,多试几次就好了。

  1. File “/home/damon/桌面/FCOS1/FCOS-master/fcos_core/config/paths_catalog.py”, line 117, in get
    attrs = DatasetCatalog.DATASETS[name]
    KeyError: ‘/home/damon/Datasets/coco2020/train2020’

Process finished with exit code 1

文件夹地址有问题。

5File “/home/damon/anaconda3/lib/python3.7/site-packages/yacs/config.py”, line 537, in _check_and_coerce_cfg_value_type
original_type, replacement_type, original, replacement, full_key
ValueError: Type mismatch ( vs. ) with values (() vs. (“coco_2017_train”, “coco_2017_val”)) for config key: DATASETS.TRAIN

  1. File “/home/damon/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 845, in load_state_dict
    self.class.name, “\n\t”.join(error_msgs)))
    RuntimeError: Error(s) in loading state_dict for GeneralizedRCNN:
    size mismatch for backbone.fpn.fpn_inner2.weight: copying a param with shape torch.Size([256, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 32, 1, 1]).
    size mismatch for backbone.fpn.fpn_inner3.weight: copying a param with shape torch.Size([256, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 96, 1, 1]).
    size mismatch for backbone.fpn.fpn_inner4.weight: copying a param with shape torch.Size([256, 2048, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 320, 1, 1]).

7.File “/home/damon/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py”, line 845, in load_state_dict
self.class.name, “\n\t”.join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for GeneralizedRCNN:
size mismatch for backbone.fpn.fpn_inner2.weight: copying a param with shape torch.Size([256, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 32, 1, 1]).
size mismatch for backbone.fpn.fpn_inner3.weight: copying a param with shape torch.Size([256, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 96, 1, 1]).
size mismatch for backbone.fpn.fpn_inner4.weight: copying a param with shape torch.Size([256, 2048, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 320, 1, 1]).
size mismatch for rpn.head.cls_logits.weight: copying a param with shape torch.Size([80, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([2, 256, 3, 3]).
size mismatch for rpn.head.cls_logits.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([2]).

上面三种都是需要改fore_core/config/deafults 文件中的类别数量,类别数量改为类别数+背景
tools文件夹下的以前训练模型要重新设置一个文件夹或者删掉,否则会以此为模型进行继续训练。

6.一定要保证数据集格式是对的,分类损失函数为零的话,大概率是类别没有设置好,需要将类别重新设置。

7.训练的过程中特别容易因为初始化的问题,导致训练的结果并不好,所以可以关注下这方面的内容。

其他后续,发现再补。

你可能感兴趣的:(目标检测,python,深度学习)