diff --git a/docs/en/tutorials/quick_start_recognition_en.md b/docs/en/tutorials/quick_start_recognition_en.md index cd14d2bb79e383dc72a558fc8b4a3f5408f6fa5e..4d82cd2afba91fc57e632948e1697a039ecba107 100644 --- a/docs/en/tutorials/quick_start_recognition_en.md +++ b/docs/en/tutorials/quick_start_recognition_en.md @@ -90,13 +90,13 @@ wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/infere cd .. # Download the demo data and unzip it -wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_en_v1.0.tar && tar -xf recognition_demo_data_en_v1.0.tar +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_en_v1.1.tar && tar -xf recognition_demo_data_en_v1.1.tar ``` -Once unpacked, the `recognition_demo_data_v1.0` folder should have the following file structure. +Once unpacked, the `recognition_demo_data_v1.1` folder should have the following file structure. ``` -├── recognition_demo_data_v1.0 +├── recognition_demo_data_v1.1 │ ├── gallery_cartoon │ ├── gallery_logo │ ├── gallery_product @@ -126,13 +126,21 @@ The `models` folder should have the following file structure. ### 2.2 Product Recognition and Retrieval -Take the product recognition demo as an example to show the recognition and retrieval process (if you wish to try other scenarios of recognition and retrieval, replace the corresponding configuration file after downloading and unzipping the corresponding demo data and model to complete the prediction)。 +Take the product recognition demo as an example to show the recognition and retrieval process (if you wish to try other scenarios of recognition and retrieval, replace the corresponding configuration file after downloading and unzipping the corresponding demo data and model to complete the prediction). +**Note:** `faiss` is used as search library. The installation method is as follows: + +``` +pip install faiss-cpu==1.7.1post2 +``` + +If error happens when using `import faiss`, please uninstall `faiss` and reinstall it, especially on `Windows`. + #### 2.2.1 Single Image Recognition -Run the following command to identify and retrieve the image `./recognition_demo_data_v1.0/test_product/daoxiangcunjinzhubing_6.jpg` for recognition and retrieval +Run the following command to identify and retrieve the image `./recognition_demo_data_v1.1/test_product/daoxiangcunjinzhubing_6.jpg` for recognition and retrieval ```shell # use the following command to predict using GPU. @@ -141,8 +149,6 @@ python3.7 python/predict_system.py -c configs/inference_product.yaml python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.use_gpu=False ``` -**Note:** Program lib used to build index is compliled on our machine, if error occured because of the environment, you can refer to [vector search tutorial](../../../deploy/vector_search/README.md) to rebuild the lib. - The image to be retrieved is shown below. @@ -175,7 +181,7 @@ If you want to predict the images in the folder, you can directly modify the `Gl ```shell # using the following command to predict using GPU, you can append `-o Global.use_gpu=False` to predict using CPU. -python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.0/test_product/" +python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.1/test_product/" ``` @@ -195,16 +201,16 @@ The results on the screen are shown as following. All the visualization results are also saved in folder `output`. -Furthermore, the recognition inference model path can be changed by modifying the `Global.rec_inference_model_dir` field, and the path of the index to the index databass can be changed by modifying the `IndexProcess.index_path` field. +Furthermore, the recognition inference model path can be changed by modifying the `Global.rec_inference_model_dir` field, and the path of the index to the index databass can be changed by modifying the `IndexProcess.index_dir` field. ## 3. Recognize Images of Unknown Category -To recognize the image `./recognition_demo_data_v1.0/test_product/anmuxi.jpg`, run the command as follows: +To recognize the image `./recognition_demo_data_v1.1/test_product/anmuxi.jpg`, run the command as follows: ```shell -python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.0/test_product/anmuxi.jpg" +python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.1/test_product/anmuxi.jpg" ``` The image to be retrieved is shown below. @@ -225,14 +231,14 @@ When the index database cannot cover the scenes we actually recognise, i.e. when First, you need to copy the images which are similar with the image to retrieval to the original images for the index database. The command is as follows. ```shell -cp -r ../docs/images/recognition/product_demo/gallery/anmuxi ./recognition_demo_data_v1.0/gallery_product/gallery/ +cp -r ../docs/images/recognition/product_demo/gallery/anmuxi ./recognition_demo_data_/gallery_product/gallery/ ``` Then you need to create a new label file which records the image path and label information. Use the following command to create a new file based on the original one. ```shell # copy the file -cp recognition_demo_data_v1.0/gallery_product/data_file.txt recognition_demo_data_v1.0/gallery_product/data_file_update.txt +cp recognition_demo_data_v1.1/gallery_product/data_file.txt recognition_demo_data_v1.1/gallery_product/data_file_update.txt ``` Then add some new lines into the new label file, which is shown as follows. @@ -255,20 +261,20 @@ Each line can be splited into two fields. The first field denotes the relative i Use the following command to build the index to accelerate the retrieval process after recognition. ```shell -python3.7 python/build_gallery.py -c configs/build_product.yaml -o IndexProcess.data_file="./recognition_demo_data_v1.0/gallery_product/data_file_update.txt" -o IndexProcess.index_path="./recognition_demo_data_v1.0/gallery_product/index_update" +python3.7 python/build_gallery.py -c configs/build_product.yaml -o IndexProcess.data_file="./recognition_demo_data_v1.1/gallery_product/data_file_update.txt" -o IndexProcess.index_dir="./recognition_demo_data_v1.1/gallery_product/index_update" ``` -Finally, the new index information is stored in the folder`./recognition_demo_data_v1.0/gallery_product/index_update`. Use the new index database for the above index. +Finally, the new index information is stored in the folder`./recognition_demo_data_v1.1/gallery_product/index_update`. Use the new index database for the above index. ### 3.2 Recognize the Unknown Category Images -To recognize the image `./recognition_demo_data_v1.0/test_product/anmuxi.jpg`, run the command as follows. +To recognize the image `./recognition_demo_data_v1.1/test_product/anmuxi.jpg`, run the command as follows. ```shell # using the following command to predict using GPU, you can append `-o Global.use_gpu=False` to predict using CPU. -python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.0/test_product/anmuxi.jpg" -o IndexProcess.index_path="./recognition_demo_data_v1.0/gallery_product/index_update" +python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.infer_imgs="./recognition_demo_data_v1.1/test_product/anmuxi.jpg" -o IndexProcess.index_dir="./recognition_demo_data_v1.1/gallery_product/index_update" ``` The output is as follows: diff --git a/docs/zh_CN/tutorials/quick_start_recognition.md b/docs/zh_CN/tutorials/quick_start_recognition.md index 2e2fab8316a307aac105f669675270b2425f4c79..19b8fed91925935a21f279ef7833867a70b8ebf2 100644 --- a/docs/zh_CN/tutorials/quick_start_recognition.md +++ b/docs/zh_CN/tutorials/quick_start_recognition.md @@ -46,8 +46,8 @@ 本章节demo数据下载地址如下: [数据下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_v1.1.tar)。 - **注意** + 1. windows 环境下如果没有安装wget,可以按照下面的步骤安装wget与tar命令,也可以在,下载模型时将链接复制到浏览器中下载,并解压放置在相应目录下;linux或者macOS用户可以右键点击,然后复制下载链接,即可通过`wget`命令下载。 2. 如果macOS环境下没有安装`wget`命令,可以运行下面的命令进行安装。 @@ -74,8 +74,8 @@ cd .. wget {数据下载链接地址} && tar -xf {压缩包的名称} ``` - + ### 2.1 下载、解压inference 模型与demo数据 以商品识别为例,下载demo数据集以及通用检测、识别模型,命令如下。 @@ -90,13 +90,13 @@ wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/infere cd ../ # 下载demo数据并解压 -wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_v1.0.tar && tar -xf recognition_demo_data_v1.0.tar +wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognition_demo_data_v1.1.tar && tar -xf recognition_demo_data_v1.1.tar ``` -解压完毕后,`recognition_demo_data_v1.0`文件夹下应有如下文件结构: +解压完毕后,`recognition_demo_data_v1.1`文件夹下应有如下文件结构: ``` -├── recognition_demo_data_v1.0 +├── recognition_demo_data_v1.1 │ ├── gallery_cartoon │ ├── gallery_logo │ ├── gallery_product @@ -129,11 +129,19 @@ wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognit 以商品识别demo为例,展示识别与检索过程(如果希望尝试其他方向的识别与检索效果,在下载解压好对应的demo数据与模型之后,替换对应的配置文件即可完成预测)。 +注意,此部分使用了`faiss`作为检索库,安装方法如下: + +```python +pip install faiss-cpu==1.7.1post2 +``` + +若使用时,不能正常引用,则`uninstall` 之后,重新`install`,尤其是windows下。 + #### 2.2.1 识别单张图像 -运行下面的命令,对图像`./recognition_demo_data_v1.0/test_product/daoxiangcunjinzhubing_6.jpg`进行识别与检索 +运行下面的命令,对图像`./recognition_demo_data_v1.1/test_product/daoxiangcunjinzhubing_6.jpg`进行识别与检索 ```shell # 使用下面的命令使用GPU进行预测 @@ -142,8 +150,6 @@ python3.7 python/predict_system.py -c configs/inference_product.yaml python3.7 python/predict_system.py -c configs/inference_product.yaml -o Global.use_gpu=False ``` -注意:这里使用了默认编译生成的库文件进行特征索引,如果与您的环境不兼容,导致程序报错,可以参考[向量检索教程](../../../deploy/vector_search/README.md)重新编译库文件。 - 待检索图像如下所示。