无法训练更快的rcnn

时间:2019-10-08 10:39:04

标签: python windows tensorflow deep-learning faster-rcnn

我想构建自己的Faster Rcnn模型,我从https://github.com/dBeker/Faster-RCNN-TensorFlow-Python3下载了一个示例

运行代码时出现错误,我不知道为什么

Traceback (most recent call last):
  File "C:/Users/l/Desktop/Faster-RCNN/train.py", line 216, in <module>
    train.train()
  File "C:/Users/l/Desktop/Faster-RCNN/train.py", line 148, in train
    blobs = self.data_layer.forward()
  File "C:\Users\l\Desktop\Faster-RCNN\lib\layer_utils\roi_data_layer.py", line 75, in forward
    blobs = self._get_next_minibatch()
  File "C:\Users\l\Desktop\Faster-RCNN\lib\layer_utils\roi_data_layer.py", line 71, in _get_next_minibatch
    return get_minibatch(minibatch_db, self._num_classes)
  File "C:\Users\l\Desktop\Faster-RCNN\lib\utils\minibatch.py", line 30, in get_minibatch
    im_blob, im_scales = _get_image_blob(roidb, random_scale_inds)
  File "C`enter code here`:\Users\l\Desktop\Faster-RCNN\lib\utils\minibatch.py", line 67, in _get_image_blob
    im, im_scale = prep_im_for_blob(im, cfg.FLAGS2["pixel_means"], target_size, cfg.FLAGS.max_size)
  File "C:\Users\l\Desktop\Faster-RCNN\lib\utils\blob.py", line 35, in prep_im_for_blob
    im = im.astype(np.float32, copy=False)
AttributeError: 'NoneType' object has no attribute 'astype'

1 个答案:

答案 0 :(得分:0)

要构建自己的Faster RCNN Models,可以按照Official Tensorflow Github Repository中提到的说明进行操作。

遵循这些说明的优点是,如果您遇到任何问题,可以在this Repo中提出问题,并且Google工程师会为您提供帮助。

为社区的利益指定Github Repo中提到的步骤(以防链接断开)。

定义新的Faster R-CNN或SSD功能提取器:

在大多数情况下,您可能不会从头开始实现DetectionModel ---您可能会创建一个新的功能提取器,以供SSD或Faster R-CNN元体系结构之一使用。 (我们认为元体系结构是使用DetectionModel抽象定义整个模型族的类。

注意:为了使下面的讨论有意义,我们建议您首先熟悉Faster R-CNN文件。

现在让我们想象一下,您已经发明了一种全新的网络体系结构(例如,“ InceptionV100”)进行分类,并希望了解InceptionV100作为检测特征提取器的行为(例如,使用Faster R-CNN)。 SSD型号也可以采用类似的步骤,但我们将讨论Faster R-CNN。

要使用InceptionV100,我们将必须定义一个新的FasterRCNNFeatureExtractor并将其作为输入传递给我们的FasterRCNNMetaArch构造函数。分别参见object_detection/meta_architectures/faster_rcnn_meta_arch.pyFasterRCNNFeatureExtractor的定义。 FasterRCNNMetaArch必须定义一些功能:

  • FasterRCNNFeatureExtractor:在输入图像上运行检测器之前,对输入值进行任何必要的预处理。
  • preprocess:提取第一阶段的区域提案网络(RPN)功能。
  • _extract_proposal_features:提取第二级Box分类器功能。
  • _extract_box_classifier_features:将检查点加载到Tensorflow图中。

请参见restore_from_classification_checkpoint_fn定义作为一个示例。一些说明:

  • 我们通常使用Slim Resnet-101 classification checkpoint中的权重来初始化该特征提取器的权重,并且我们知道,在训练此检查点时,会通过从每个输入图像中减去通道平均值来对图像进行预处理。因此,我们实现了预处理功能以复制相同的通道均值减法行为。
  • 在slim中定义的“完整” resnet分类网络分为两部分---除最后一个“ resnet块”之外的所有内容都放入object_detection/models/faster_rcnn_resnet_v1_feature_extractor.py函数中,最后一个块在{{ 1}}函数。通常,可能需要进行一些实验才能确定一个最佳图层,在该图层上将特征提取器“切割”为Faster R-CNN的这两部分。

有关更多信息,请参阅this link和此Tensorflow Models的Github存储库。

希望这会有所帮助。学习愉快!

相关问题