update ppshitu_application_scenarios.md

pull/2248/head
zengshao0622 2022-09-01 11:16:19 +00:00
parent a7c2b987a4
commit fd85021e85
1 changed files with 0 additions and 112 deletions

View File

@ -199,115 +199,3 @@ python3.7 python/predict_system.py -c configs/inference_general.yaml -o Global.i
...
```
所有图像的识别结果可视化图像也保存在`output`文件夹内。
<a name="3 新增场景库图像识别体验"></a>
### 3 新增场景库图像识别体验
该部分内容介绍根据新数据集创建场景库并进行指标验证和识别检索的方法。
<a name="3.1 根据相似度划分Gallery和Query"></a>
#### 3.1 根据相似度划分Gallery和Query
首先制作需要创建场景库数据集的`image_list.txt`,该文件格式如下:
```
# 每一行采用“空格”分割图像路径与标签
image_path_1 label_1
image_path_2 label_1
image_path_3 label_1
image_path_4 label_2
...
```
在配置文件`configs/index_selector.yaml`中的`Datasets`字段中添加新建场景库对应数据集的信息,格式如下:
```shell
Datasets:
DatasetName:
infer_path: "path/to/image"
infer_imgs: "path/to/image_list.txt"
output_path: "path/to/save/Gallery&Query"
gallery_num: 20
sim_thred: 0.88
```
其中,`DatasetName`表示新建场景库的名字,`infer_path`为保存新建场景库对应数据集图像的文件夹路径,`infer_imgs`为`image_list.txt`的路径,`output_path`为划分好gallery和query的保存路径`gallery_num`为每类gallery图像的最大数量`sim_thred`为选择query图像时与gallery图像的相似度阈值。
运行如下命令根据相似度划分gallery和query
```shell
python shitu_index_selector/index_selector.py -c configs/index_selector.yaml
```
输出结果如下:
```
Mean of gallery num: 20
Mean of query num: 26
```
其中`Mean of gallery num`表示划分的gallery库每类图像数均值`Mean of query num`表示划分的query库每类图像数均值。
划分好的文件结构如下:
```
├── Gallery
│ ├── class1
│ │ ├──image1.jpg
│ │ ├──image2.jpg
│ │ ├──...
│ ├── class2
│ └── ...
├── Query
│ ├── class1
│ ├── class2
│ └── ...
├── gallery_list.txt
└── query_list.txt
```
其中`Gallery`和`Query`分别为gallery和query库图像`gallery_list.txt`和`query_list.txt`分别为对应的标签文件。
<a name="3.2 根据Gallery构建index索引"></a>
#### 3.2 根据划分好的Gallery构建index索引
首先在配置文件`configs/sample_indexes.yaml`中的`Datasets`字段中添加新建场景库的信息,格式如下:
```shell
Datasets:
DatasetName:
infer_path: "path/to/Gallery/images"
infer_imgs: "path/to/gallery_list.txt"
output_dir: "path/to/save/index"
```
其中,`DatasetName`表示新建场景库的名字,`infer_path`为保存新建场景库划分好的gallery图像路径`infer_imgs`为`gallery_list.txt`的路径,`output_path`为保存构建`index`索引的路径。
然后在配置文件`configs/sample_indexes.yaml`中的`Method`字段中添加构建`index`索引的方法,格式如下:
```shell
Methods:
SampleAll:
method_name: SampleAll
RandomSample_10:
method_name: RandomSample
gallery_num: 10
```
其中PaddleClas提供了两种方法`SampleAll`为根据提供的所有Gallery图像构建`index`索引,`RandomSample`为根据提供的Gallery图像每类随机选取`gallery_num`张图像构建`index`索引,可根据需要选择对应的方法。同时,也可以参考`shitu_index_selector/index_random_sample.py`和`shitu_index_selector/index_sample_all.py`实现其他图像选择方式构建`index`索引。
构建的`index`索引库文件结构如下:
```
├── RandomSample_10
│ ├── gallery
│ │ ├──class1
│ │ │ ├──image1.jpg
│ │ │ ├──...
│ │ ├──class2
│ │ └──...
│ └── index
│ ├──id_map.pkl
│ └──vector.index
└──SampleAll
└── index
├──id_map.pkl
└──vector.index
```
其中,`RadomSample`方法构建index索引后会保存随机采样的Gallery图像到`gallery`文件夹。
使用新的`index`索引库进行图像识别,需要修改配置文件中的`IndexProcess.index_dir`字段来更改索引库的路径。
注意划分Gallery、构建`index`索引库以及进行图像识别时,应当使用同一个识别模型(即三个步骤配置文件中的`Global.rec_inference_model_dir`字段保持一致)。