简体   繁体   English

改进预训练的 tensorflow object 检测 model

[英]Improving a pre-trained tensorflow object detection model

I want to use tensorflow for detecting cars in an embedded system, so I tried ssd_mobilenet_v2 and it actually did pretty well for me, except for some specific car types which are not very common and I think that is why the model does not recognize them.我想使用 tensorflow 在嵌入式系统中检测汽车,所以我尝试了 ssd_mobilenet_v2 ,它实际上对我来说做得很好,除了一些不太常见的特定汽车类型,我认为这就是 model 无法识别它们的原因。 I have a dataset of these cases and I want to improve the model by fine-tuning it.我有这些案例的数据集,我想通过微调来改进 model。 I should also note that I need a .tflite file because I'm using tflite_runtime in python.我还应该注意,我需要一个.tflite文件,因为我在 python 中使用tflite_runtime I followed these instructions https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10 and I could train the model and reached a reasonable loss value.我按照这些说明https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10我可以训练 model 并达到合理的损失值。 I then used export_tflite_ssd_graph.py in the object detection API to build inference_graph from the trained model.然后我在 object 检测 API 中使用export_tflite_ssd_graph.py从经过训练的 model 构建 inference_graph。 Afterwards I used toco tool to build a.tflite file out of it.之后我使用toco工具从中构建了一个 .tflite 文件。

But here is the problem, after I've done all that;但是,在我完成所有这些之后,问题就来了; not only the model did not improve, but now it does not detect any cars.不仅 model 没有改善,而且现在它没有检测到任何汽车。 I got confused and do not know what is the problem, I searched a lot and did not find any tutorial about doing what I need to do.我很困惑,不知道是什么问题,我搜索了很多,没有找到任何关于做我需要做的事情的教程。 They just added a new object to a model and then exported it, which I tried and I was successful doing that.他们只是在 model 中添加了一个新的 object,然后将其导出,我尝试过并且成功了。 I also tried to build a.tflite file without training the model and directly from the Tensorflow detection model zoo and it worked fine.我还尝试在不训练 model 和直接从Tensorflow 检测 model 动物园的情况下构建 a.tflite 文件,并且效果很好。 So I think the problem has something to do with the training process.所以我认为这个问题与训练过程有关。 Maybe I am missing something there.也许我在那里遗漏了一些东西。

Another thing that I did not find in documents is that whether is it possible to "add" a class to the current classes of an object detection model.我在文档中没有找到的另一件事是,是否可以将 class “添加”到 object 检测 model 的当前类中。 For example, let's assume the mobilenet ssd v2 detects 90 different object classes, I would like to add another class so that the model detects 91 different classes instead of 90 classes.例如,假设 mobilenet ssd v2 检测到 90 个不同的 object 类,我想添加另一个 class 以便 model 检测到 91 个不同的类。 As far as I understand and tested after doing transfer learning using object detection API, I could only detect the objects that I had in my dataset and the old classes will be gone.据我了解并在使用 object 检测 API 进行迁移学习后进行测试,我只能检测到我的数据集中的对象,旧类将消失。 So how do I do what I explained?那么我该怎么做我解释的呢?

I found out that there is no way to 'add' a class to the previously trained classes but with providing a little amount of data of that class you can have your model detect it.我发现没有办法将 class “添加”到先前训练的课程中,但是通过提供少量的 class 数据,您可以让 model 检测到它。 The reason is that the last layer of the model changes when transfer learning is applied.原因是 model 的最后一层在应用迁移学习时发生了变化。 In my case I labeled around 3k frames containing about 12k objects because my frames would be complicated.在我的例子中,我标记了大约 3k 帧,其中包含大约 12k 个对象,因为我的帧会很复杂。 But for simpler tasks as I saw in tutorials 200-300 annotated images would be enough.但是对于我在教程中看到的更简单的任务,200-300 个带注释的图像就足够了。

And for the part that the model did not detect anything it has something to do with the convert command that I used.对于 model 没有检测到任何与我使用的转换命令有关的部分。 I should have used tflite_convert instead of toco .我应该使用tflite_convert而不是toco I explained more here .在这里解释了更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载预训练的 model 检查点与 TensorFlow Object 检测 ZDB974238714CA8DE634A7ACE1 - Unable to load pre-trained model checkpoint with TensorFlow Object Detection API 如何评估预训练的 model Tensorflow Object 检测 ZDB974238714CA38DE634A7CE1ZF0 - How can I evaluate pre-trained model Tensorflow Object Detection API 预训练 Object 检测 API model 用于灰度图像(1通道) - Pre-trained Object Detection API model for greyscale images (1 channel) Tensorflow Python未加载预训练的模型 - Tensorflow python not loading the pre-trained model 预训练张量流模型的烧瓶 - flask with pre-trained tensorflow model 如何在 tensorflow 中使用预训练的 model 进行预测? - how to predict with pre-trained model in tensorflow? 如何在TensorFlow中使用预训练模型 - How to use pre-trained model in TensorFlow 如何向预训练的对象检测模型添加额外的类并训练它检测所有类(预训练 + 新的)? - How to add additional classes to a pre-trained object detection model and train it to detect all of the classes (pre-trained + new)? 如何找到用于物体检测的预训练模型精度和混淆矩阵 - How to find pre-trained model accuracy and confusion matrix for object detection Tensorflow如何修改保存为检查点的预训练模型 - Tensorflow how to modify a pre-trained Model saved as checkpoints
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM