raspberry pi_在Raspberry Pi上使用TensorFlow进行对象检测

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
Image for post

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

4. Open «generate_tfrecord.py»:

4.打开«generate_tfrecord.py»:

Image for post

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

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

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值