Python 用于检测新对象的训练模型-YoloV3
我训练我的模型去探测全息透镜 现在,我创建了一个新的Pascal吉他Voc数据集 我想让我的实际模型,检测全息镜头,以检测全息镜头和吉他 在步骤3中,我更改以下行:Python 用于检测新对象的训练模型-YoloV3,python,python-3.x,tensorflow,object-detection,yolo,Python,Python 3.x,Tensorflow,Object Detection,Yolo,我训练我的模型去探测全息透镜 现在,我创建了一个新的Pascal吉他Voc数据集 我想让我的实际模型,检测全息镜头,以检测全息镜头和吉他 在步骤3中,我更改以下行: trainer.setDataDirectory(data_directory="hololens") trainer.setTrainConfig(object_names_array=["hololens"], batch_size=4, num_experiments=100, train_from_pretrained_mo
trainer.setDataDirectory(data_directory="hololens")
trainer.setTrainConfig(object_names_array=["hololens"], batch_size=4, num_experiments=100, train_from_pretrained_model="pretrained-yolov3.h5")
致:
violao文件夹结构是:
-violao
--train
---anottations
----<xml_files>
---images
----<images_files>
我得到这个错误:
Generating anchor boxes for training images and annotation...
[Errno 21] Is a directory: 'violao/train/annotations/.ipynb_checkpoints'
Ignore this bad annotation: violao/train/annotations/.ipynb_checkpoints
Average IOU for 9 anchors: 0.96
Anchor Boxes generated.
Detection configuration saved in violao/json/detection_config.json
Some labels have no annotations! Please revise the list of labels in your configuration.
Training on: None
Training with Batch Size: 4
Number of Experiments: 100
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-11-2e7a3bd0b6ee> in <module>()
5 trainer.setDataDirectory(data_directory="violao")
6 trainer.setTrainConfig(object_names_array=["hololens", "violao"], batch_size=4, num_experiments=100, train_from_pretrained_model="drive/My Drive/PhoHast/PhoHastV1.h5")
----> 7 trainer.trainModel()
1 frames
/usr/local/lib/python3.6/dist-packages/imageai/Detection/Custom/__init__.py in trainModel(self)
231 shuffle=True,
232 jitter=0.3,
--> 233 norm=normalize
234 )
235
/usr/local/lib/python3.6/dist-packages/imageai/Detection/Custom/generator.py in __init__(self, instances, anchors, labels, downsample, max_box_per_image, batch_size, min_net_size, max_net_size, shuffle, jitter, norm)
34 self.net_w = 416
35
---> 36 if shuffle: np.random.shuffle(self.instances)
37
38 def __len__(self):
mtrand.pyx in numpy.random.mtrand.RandomState.shuffle()
TypeError: object of type 'NoneType' has no len()
我做错了什么???我认为关键的错误是
Some labels have no annotations! Please revise the list of labels in
your configuration.
我通过在训练数据集注释中不存在的object_names_数组列表中添加新标签,成功地重现了类似的问题,我得到了这些错误
Some labels have no annotations! Please revise the list of labels in your configuration.
...
Training on: None
...
TypeError: object of type 'NoneType' has no len()
解决方案
确保所有对象名称和阵列标签都在hololens和violao的数据集中。我假设您仅使用带有violao标签的图像的数据集,因此ImageAI抱怨无法找到全息透镜训练数据,即使您也指定在全息透镜上训练,假设您正在训练新模型,并且在训练前它不知道任何标签,例如您是否只离开[violao]它不会检测全息透镜,因为它对全息透镜一无所知。
从数据目录路径中删除未经过训练和验证的文件夹。当您添加标签等时,从其他会话生成的培训文件(很可能是缓存文件夹)可能会干扰培训。
如果它仍然不起作用,试着从给定的经过预训练的yolov3模型中训练你的模型我想你把一个附加值拼错了一个双t
我的问题是我在这里输入了文件夹的名称,而不是对象的名称
object_names_array=["object name in the Label"]
试试这个:
trainer.setTrainConfig(object_names_array=[], batch_size=4, num_experiments=200, train_from_pretrained_model="---.h5")
默认情况下,object_names_array=[]将从xml中选择注释
object_names_array=["object name in the Label"]
trainer.setTrainConfig(object_names_array=[], batch_size=4, num_experiments=200, train_from_pretrained_model="---.h5")