提交 8cd3a681 编写于 作者: S stephon

update binary model config

上级 d69a6e8f
Global: Global:
infer_imgs: "./recognition_demo_data_v1.1/test_product/daoxiangcunjinzhubing_6.jpg" infer_imgs: "./drink_dataset_v1.0/test_images/001.jpeg"
det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer" det_inference_model_dir: "./models/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer"
rec_inference_model_dir: "./models/product_MV3_x1_0_aliproduct_bin_v1.0_infer" rec_inference_model_dir: "./models/general_PPLCNet_x2_5_lite_binary_v1.0_infer"
rec_nms_thresold: 0.05 rec_nms_thresold: 0.05
batch_size: 1 batch_size: 1
...@@ -11,7 +11,6 @@ Global: ...@@ -11,7 +11,6 @@ Global:
labe_list: labe_list:
- foreground - foreground
# inference engine config
use_gpu: True use_gpu: True
enable_mkldnn: True enable_mkldnn: True
cpu_num_threads: 10 cpu_num_threads: 10
...@@ -49,19 +48,18 @@ RecPreProcess: ...@@ -49,19 +48,18 @@ RecPreProcess:
RecPostProcess: RecPostProcess:
main_indicator: Binarize main_indicator: Binarize
Binarize: Binarize:
method: "round" method: "sign"
# indexing engine config # indexing engine config
IndexProcess: IndexProcess:
index_method: "Flat" # supported: HNSW32, Flat index_method: "Flat" # supported: HNSW32, Flat
index_dir: "./recognition_demo_data_v1.1/gallery_product/index_binary" image_root: "./drink_dataset_v1.0/gallery/"
image_root: "./recognition_demo_data_v1.1/gallery_product/" index_dir: "./drink_dataset_v1.0/index_bin"
data_file: "./recognition_demo_data_v1.1/gallery_product/data_file.txt" data_file: "./drink_dataset_v1.0/gallery/drink_label.txt"
index_operation: "new" # suported: "append", "remove", "new" index_operation: "new" # suported: "append", "remove", "new"
delimiter: "\t" delimiter: "\t"
dist_type: "hamming" dist_type: "hamming"
embedding_size: 512 embedding_size: 512
batch_size: 32 batch_size: 32
binary_index: true
return_k: 5 return_k: 5
score_thres: 0 hamming_radius: 100
\ No newline at end of file \ No newline at end of file
...@@ -48,7 +48,7 @@ class SystemPredictor(object): ...@@ -48,7 +48,7 @@ class SystemPredictor(object):
assert os.path.exists(os.path.join( assert os.path.exists(os.path.join(
index_dir, "id_map.pkl")), "id_map.pkl not found ... " index_dir, "id_map.pkl")), "id_map.pkl not found ... "
if config['IndexProcess'].get("binary_index", False): if config['IndexProcess'].get("dist_type") == "hamming":
self.Searcher = faiss.read_index_binary( self.Searcher = faiss.read_index_binary(
os.path.join(index_dir, "vector.index")) os.path.join(index_dir, "vector.index"))
else: else:
...@@ -102,6 +102,7 @@ class SystemPredictor(object): ...@@ -102,6 +102,7 @@ class SystemPredictor(object):
# st2: add the whole image for recognition to improve recall # st2: add the whole image for recognition to improve recall
results = self.append_self(results, img.shape) results = self.append_self(results, img.shape)
#print(results)
# st3: recognition process, use score_thres to ensure accuracy # st3: recognition process, use score_thres to ensure accuracy
for result in results: for result in results:
...@@ -113,6 +114,13 @@ class SystemPredictor(object): ...@@ -113,6 +114,13 @@ class SystemPredictor(object):
scores, docs = self.Searcher.search(rec_results, self.return_k) scores, docs = self.Searcher.search(rec_results, self.return_k)
# just top-1 result will be returned for the final # just top-1 result will be returned for the final
if self.config["IndexProcess"]["dist_type"] == "hamming":
if scores[0][0] <= self.config["IndexProcess"][
"hamming_radius"]:
preds["rec_docs"] = self.id_map[docs[0][0]].split()[1]
preds["rec_scores"] = scores[0][0]
output.append(preds)
else:
if scores[0][0] >= self.config["IndexProcess"]["score_thres"]: if scores[0][0] >= self.config["IndexProcess"]["score_thres"]:
preds["rec_docs"] = self.id_map[docs[0][0]].split()[1] preds["rec_docs"] = self.id_map[docs[0][0]].split()[1]
preds["rec_scores"] = scores[0][0] preds["rec_scores"] = scores[0][0]
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
| ------------ | ------------- | -------- | ------- | | ------------ | ------------- | -------- | ------- |
| 轻量级通用主体检测模型 | 通用场景 |[tar 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar) [zip 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.zip) | - | | 轻量级通用主体检测模型 | 通用场景 |[tar 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.tar) [zip 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/picodet_PPLCNet_x2_5_mainbody_lite_v1.0_infer.zip) | - |
| 轻量级通用识别模型 | 通用场景 | [tar 格式下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar) [zip 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.zip) | [inference_general.yaml](../../../deploy/configs/inference_general.yaml) | | 轻量级通用识别模型 | 通用场景 | [tar 格式下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.tar) [zip 格式文件下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_v1.0_infer.zip) | [inference_general.yaml](../../../deploy/configs/inference_general.yaml) |
| 轻量级通用识别二值模型 | 存储受限场景 | [tar.gz 格式下载链接](https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/models/inference/general_PPLCNet_x2_5_lite_binary_v1.0_infer.tar.gz) | [inference_general_binary.yaml](../../../deploy/configs/inference_general_binary.yaml) |
注意:由于部分解压缩软件在解压上述 `tar` 格式文件时存在问题,建议非命令行用户下载 `zip` 格式文件并解压。`tar` 格式文件建议使用命令 `tar xf xxx.tar` 解压。 注意:由于部分解压缩软件在解压上述 `tar` 格式文件时存在问题,建议非命令行用户下载 `zip` 格式文件并解压。`tar` 格式文件建议使用命令 `tar xf xxx.tar` 解压。
...@@ -339,4 +340,3 @@ wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognit ...@@ -339,4 +340,3 @@ wget https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/rec/data/recognit
按照上述步骤下载模型和测试数据后,您可以进行相关方向识别模型的测试。 按照上述步骤下载模型和测试数据后,您可以进行相关方向识别模型的测试。
* 更多关于主体检测的介绍可以参考:[主体检测教程文档](../image_recognition_pipeline/mainbody_detection.md);关于特征提取的介绍可以参考:[特征提取教程文档](../image_recognition_pipeline/feature_extraction.md);关于向量检索的介绍可以参考:[向量检索教程文档](../image_recognition_pipeline/vector_search.md) * 更多关于主体检测的介绍可以参考:[主体检测教程文档](../image_recognition_pipeline/mainbody_detection.md);关于特征提取的介绍可以参考:[特征提取教程文档](../image_recognition_pipeline/feature_extraction.md);关于向量检索的介绍可以参考:[向量检索教程文档](../image_recognition_pipeline/vector_search.md)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册