raspberry pi
The following post shows how to train and test TensorFlow and TensorFlow Lite models based on SSD-architecture (to get familiar with SSD follow the links in the «References» down below) on Raspberry Pi.
以下帖子显示了如何在Raspberry Pi上基于SSD架构训练和测试TensorFlow和TensorFlow Lite模型(要熟悉SSD,请遵循下面“参考”中的链接)。
Note: The described steps were tested on Linux Mint 19.3 but shall work on Ubuntu and Debian.
注意:所描述的步骤已经在Linux Mint 19.3上进行了测试,但是可以在Ubuntu和Debian上运行。
资料准备 (Data preparation)
Like in the post dedicated to YOLO one have to prepare data first. Follow the first 7 steps and then do this:
就像在专门针对YOLO的帖子中一样,必须首先准备数据。 请遵循前7个步骤,然后执行以下操作:
1. In order to get listed data and generate TFRecords clone repository «How To Train an Object Detection Classifier for Multiple Objects Using TensorFlow(GPU) on Windows 10»:
1.为了获取列出的数据并生成TFRecords克隆存储库《如何在Windows 10上使用TensorFlow(GPU)训练多个对象的对象检测分类器》:
git clone https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10.gitcd TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-
Windows-10
2. Put all labeled images into folders «images/test» and «images/train»:
2.将所有带标签的图像放入“图像/测试”和“图像/训练”文件夹中:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/5e1a1f2d57604897df5f2eed37fff3f7.png)
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/72d46453c893d8eea25ce53594d13171.png)
3. Get data records:
3.获取数据记录:
python3 xml_to_csv.py
This command creates «train_labels.csv» and «test_labels.csv» in «im-ages» folder:
该命令在«im-ages»文件夹中创建«train_labels.csv»和«test_labels.csv»:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/6aeada47e7a91218e26c5c1fff9b1aa7.png)
4. Open «generate_tfrecord.py»:
4.打开«generate_tfrecord.py»:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/df2c989c5aee0d952684cb45096f4fd6.png)
And replace the label map starting at line 31 with your own label map, where each object is assigned an ID number, for ex.:
并用您自己的标签图替换从第31行开始的标签图,其中为每个对象分配一个ID号,例如:
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/4349fdd2df7a479769863d7c35977ed6.png)
5. Generate TFRecords for data:
5.为数据生成TFRecords:
python3 generate_tfrecord.py — csv_input=images/train_labels.csv
— image_dir=images/train — output_path=train.recordpython3 generate_tfrecord.py — csv_input=images/test_labels.csv
— image_dir=images/test — output_path=test.record
These commands generate «train.record» and «test.record» file which will be used to train the new object detection classifier.
这些命令生成“ train.record”和“ test.record”文件,这些文件将用于训练新的对象检测分类器。
![Image for post](https://i-blog.csdnimg.cn/blog_migrate/c0cb718cadc8d7ec77792010708ab489.png)
6. Create a label map. The label map defines a mapping of class names to classID numbers, for ex.:
6.创建标签图。 标签映射定义了类名到classID号的映射,例如:
item {
id: 1
name: 'nutria'
}
Save it as «labelmap.pbtxt».
将其另存为«labelmap.pbtxt»。
7. Configure the object detection training pipeline. It defines which model and what parameters will be used for training.Download «ssd_mobilenet_v2_quantized_300x300_coco.config» from https://github.com/tensorflow/models/tree/master/research/object_detection/samples/configs:
7.配置对象检测训练管道。 它定义了用于训练的模型和参数。从https://github.com/tensorflow/models/tree/master/research/object_detection/samples/configs下载 «ssd_mobilenet_v2_quantized_300x300_coco.config»:
wget https://github.com/tensorflow/models/blob/master/research/object_detection/samples/config/ssd_mobilenet_v2_quantized_300x300_
coco.config
8. Change configuration file:
8.更改配置文件:
Set number of classes:
设置班数:
- num_classes: SET_YOUR_VALUE
-num_classes:SET_YOUR_VALUE
Set checkpoint:
设置检查点:
- fine_tune_checkpoint: “/path/to/ssd_mobilenet_v2_quantized/model.ckpt”
-fine_tune_checkpoint:“ / path / to / s