diff --git a/contrib/Individual/.keep b/contrib/Individual/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/contrib/Individual/README.md b/contrib/Individual/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c326b6b2f9f327224c395bc98488e02a37d9eb74 --- /dev/null +++ b/contrib/Individual/README.md @@ -0,0 +1,27 @@ +# Individual attribute recognition + +## 介绍 + +行业SDK流程编排,该项目主要实现了从Sample.pipeline中读取pipeline创建推理stream,然后读取一张图片送到stream进行推理,获取推理结构后把结果打印出来,最后销毁stream。 +为了评测,可以从Sample_proto.pipline中读取pipeline创建推理stream,然后读入评测文档,根据评测文档中的数据集路径读入图片,最后将推理结果输出到一个txt文档中,通过对比脚本 +可以得到评测的结果。 + +## 配置 + +确保pipeline所需要的yolov4和resnet50模型文件在'../models'中存在,run.sh脚本中LD_LIBRARY_PATH设置了ACL动态库链接路径为/usr/local/Ascend/ascend-toolkit/latest/acllib/lib64, +如果实际环境中路径不一致,需要替换为实际的目录。 +本项目涵盖人脸识别,人脸关键点提取,人脸对齐,人脸属性识别模型整体的代码。 +main.py以及Sample.pipeline是本项目的核心内容,完成人脸识别,人脸关键点提取,人脸对齐以及人脸属性识别整体的流程。在main.py中修改输入图像的路径即可得到相应的推理结果。 +项目目录下提供了三组可供测试使用的test1,test2,test3。如有需要,可以修改Sample.pipeline完成更丰富的功能。 +项目评测部分主要由在数据集CelebA上完成。该部分由attr_main.py、cal_accuracy.py、Sample_proto.pipeline和groudtruth组成。将数据集文件按照text_full中的路径存放到相应位置,运行脚本文件,可以得到 +一个txt输出,再通过运行cal_accuracy.py完成模型输出与标准值的对比,可以查看到评测结果。 + + +## 运行 + +```python3.7/bash +运行项目:bash ./run.sh 或者 python3.7 main.py +运行评测:python3.7 attr_main.py +python3.7 cal_accuracy.py --gt-file=./test_full.txt --pred-file=./img_result.txt +``` +如果使用过程中遇到问题,请联系华为技术支持。 \ No newline at end of file diff --git a/contrib/Individual/attr_main.py b/contrib/Individual/attr_main.py new file mode 100644 index 0000000000000000000000000000000000000000..59b7782ae975927af4416e24bb5c459fc5f837b9 --- /dev/null +++ b/contrib/Individual/attr_main.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# coding=utf-8 + +# Copyright(C) 2021. Huawei Technologies Co.,Ltd. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# import StreamManagerApi.py +from StreamManagerApi import * +import os +if __name__ == '__main__': + # init stream manager + streamManagerApi = StreamManagerApi() + ret = streamManagerApi.InitManager() + if ret != 0: + print("Failed to init Stream manager, ret=%s" % str(ret)) + # exit() + + # create streams by pipeline config file + with open("./pipeline/Sample.pipeline", 'rb') as f: + pipelineStr = f.read() + ret = streamManagerApi.CreateMultipleStreams(pipelineStr) + if ret != 0: + print("Failed to create Stream, ret=%s" % str(ret)) + + file_handle = open('img_result.txt', 'w') + file_handle2 = open('test_full.txt', 'r') + while 1: + # Construct the input of the stream + dataInput = MxDataInput() + line = file_handle2.readline() + # the length of the path is 34 + img_path = line[0:34] + with open(img_path, 'rb') as f: + dataInput.data = f.read() + + # Inputs data to a specified stream based on streamName. + streamName = b'classification+detection' + inPluginId = 0 + uniqueId = streamManagerApi.SendDataWithUniqueId(streamName, inPluginId, dataInput) + if uniqueId < 0: + print("Failed to send data to stream.") + + # Obtain the inference result by specifying streamName and uniqueId. + inferResult = streamManagerApi.GetResultWithUniqueId(streamName, uniqueId, 3000) + if inferResult.errorCode != 0: + print("GetResultWithUniqueId error. errorCode=%d, errorMsg=%s" % ( + inferResult.errorCode, inferResult.data.decode())) + # save the confidence + img_list = [] + # print the infer result + print(inferResult.data.decode()) + dict_all = inferResult.data.decode() + # start of the string + begin = 0 + end = len(dict_all) + index = 0 + # the num of the attribute + attr_num = 40 + # the distence of the 'confidence' and the num is 12 + next_confidence = 12 + for i in range(attr_num): + # find confidence in dict + loc = dict_all.find('confidence', begin + index, end) + # next confidence + index = loc + next_confidence + img_list.append(int(dict_all[loc + next_confidence])) + file_handle.write(img_path + ' ') + file_handle.write(str(img_list).replace("[", "").replace("]", "").replace(",", " ")) + file_handle.write('\n') + # destroy streams + file_handle.close() + streamManagerApi.DestroyAllStreams() diff --git a/contrib/Individual/cal_accuracy.py b/contrib/Individual/cal_accuracy.py new file mode 100644 index 0000000000000000000000000000000000000000..e1138a9ae9e401caca99c977606d39774b5e7d25 --- /dev/null +++ b/contrib/Individual/cal_accuracy.py @@ -0,0 +1,67 @@ +# Copyright(C) 2021. Huawei Technologies Co.,Ltd. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import numpy as np +import argparse + + +def get_arguments(): + parser = argparse.ArgumentParser(description="Attribute Network") + parser.add_argument("--gt-file", type=str, + help="ground truth file path.") + parser.add_argument("--pred-file", type=str, + help="prediction file path.") + parser.add_argument("--path-shift", type=int, default=0, + help="prediction file path.") + return parser.parse_args() + + +def cal_attr(): + args = get_arguments() + path_shift = args.path_shift + print(args) + gt_attr_file = args.gt_file + pred_file = args.pred_file + attr_num = 40 + gt_f = open(gt_attr_file, 'r') + gt_line = gt_f.readline().strip().split() + pred_f = open(pred_file, 'r') + #pred_f = open(pred_file, 'r') + pred_line = pred_f.readline().strip().split() + + same_count = np.zeros(attr_num, dtype=np.int32) + valid_sum = 0 + while pred_line: + valid_sum += 1 + for i in range(attr_num): + pred_attr = int(pred_line[1 + i]) + gt_attr = int(gt_line[path_shift + 1 + i]) + if pred_attr == gt_attr: + same_count[i] += 1 + gt_line = gt_f.readline().strip().split() + pred_line = pred_f.readline().strip().split() + print(valid_sum) + result = np.zeros(attr_num) + cur_index = 0 + for v in same_count: + # percentage calculation + print(v * 1.0 / valid_sum * 100) + result[cur_index] = v * 1.0 / valid_sum * 100 + cur_index += 1 + print('mean result', np.mean(result)) + return result + + +if __name__ == '__main__': + cal_attr() diff --git a/contrib/Individual/main.py b/contrib/Individual/main.py new file mode 100644 index 0000000000000000000000000000000000000000..f8eb7df06953c65fb90a71dbed85ddb2b74cc738 --- /dev/null +++ b/contrib/Individual/main.py @@ -0,0 +1,60 @@ + +#!/usr/bin/env python +# coding=utf-8 + +# Copyright(C) 2021. Huawei Technologies Co.,Ltd. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# import StreamManagerApi.py +from StreamManagerApi import * + +if __name__ == '__main__': + # init stream manager + streamManagerApi = StreamManagerApi() + ret = streamManagerApi.InitManager() + if ret != 0: + print("Failed to init Stream manager, ret=%s" % str(ret)) + + # create streams by pipeline config file + with open("./pipeline/Sample_proto.pipeline", 'rb') as f: + pipelineStr = f.read() + ret = streamManagerApi.CreateMultipleStreams(pipelineStr) + if ret != 0: + print("Failed to create Stream, ret=%s" % str(ret)) + + # Construct the input of the stream + dataInput = MxDataInput() + + # example + with open("./test7.jpg", 'rb') as f: + dataInput.data = f.read() + + # Inputs data to a specified stream based on streamName. + streamName = b'classification+detection' + inPluginId = 0 + uniqueId = streamManagerApi.SendDataWithUniqueId(streamName, inPluginId, dataInput) + if uniqueId < 0: + print("Failed to send data to stream.") + + # Obtain the inference result by specifying streamName and uniqueId. + inferResult = streamManagerApi.GetResultWithUniqueId(streamName, uniqueId, 3000) + if inferResult.errorCode != 0: + print("GetResultWithUniqueId error. errorCode=%d, errorMsg=%s" % ( + inferResult.errorCode, inferResult.data.decode())) + + # print the infer result + print(inferResult.data.decode()) + + # destroy streams + streamManagerApi.DestroyAllStreams() diff --git a/contrib/Individual/models/.keep b/contrib/Individual/models/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/contrib/Individual/models/attr.names b/contrib/Individual/models/attr.names new file mode 100644 index 0000000000000000000000000000000000000000..9a650240e84d102fbbb015d6f17cdcdb5d8d3e4f --- /dev/null +++ b/contrib/Individual/models/attr.names @@ -0,0 +1,82 @@ +#this is file +5_o_Clock_Shadow +Arched_Eyebrows +Attractive +Bags_Under_Eyes +Bald +Bangs +Big_Lips +Big_Nose +Black_Hair +Blond_Hair +Blurry +Brown_Hair +Bushy_Eyebrows +Chubby +Double_Chin +Eyeglasses +Goatee +Gray_Hair +Heavy_Makeup +High_Cheekbones +Male +Mouth_Slightly_Open +Mustache +Narrow_Eyes +No_Beard +Oval_Face +Pale_Skin +Pointy_Nose +Receding_Hairline +Rosy_Cheeks +Sideburns +Smiling +Straight_Hair +Wavy_Hair +Wearing_Earrings +Wearing_Hat +Wearing_Lipstick +Wearing_Necklace +Wearing_Necktie +Young +5_o_Clock_Shadow|no +Arched_Eyebrows|no +Attractive|no +Bags_Under_Eyes|no +Bald|no +Bangs|no +Big_Lips|no +Big_Nose|no +Black_Hair|no +Blond_Hair|no +Blurry|no +Brown_Hair|no +Bushy_Eyebrows|no +Chubby|no +Double_Chin|no +Eyeglasses|no +Goatee|no +Gray_Hair|no +Heavy_Makeup|no +High_Cheekbones|no +Male|no +Mouth_Slightly_Open|no +Mustache|no +Narrow_Eyes|no +No_Beard|no +Oval_Face|no +Pale_Skin|no +Pointy_Nose|no +Receding_Hairline|no +Rosy_Cheeks|no +Sideburns|no +Smiling|no +Straight_Hair|no +Wavy_Hair|no +Wearing_Earrings|no +Wearing_Hat|no +Wearing_Lipstick|no +Wearing_Necklace|no +Wearing_Necktie|no +Young|no + \ No newline at end of file diff --git a/contrib/Individual/models/coco.names b/contrib/Individual/models/coco.names new file mode 100644 index 0000000000000000000000000000000000000000..784594cd592c96e549d6363b1e5a5b9aa0e187cc --- /dev/null +++ b/contrib/Individual/models/coco.names @@ -0,0 +1,5 @@ +# This file is originally from https://github.com/pjreddie/darknet/blob/master/data/coco.names +person +non motor-vehicle +motor-vehicle +face diff --git a/contrib/Individual/models/face_quality_0605_b1.om b/contrib/Individual/models/face_quality_0605_b1.om new file mode 100644 index 0000000000000000000000000000000000000000..65f03b1b8d2542b0b822b38d7d7af4f68e65a401 Binary files /dev/null and b/contrib/Individual/models/face_quality_0605_b1.om differ diff --git a/contrib/Individual/models/libfacelandmarkpostprocessor.so b/contrib/Individual/models/libfacelandmarkpostprocessor.so new file mode 100644 index 0000000000000000000000000000000000000000..58628a337435fd75483b1514bb664132470d1bdd Binary files /dev/null and b/contrib/Individual/models/libfacelandmarkpostprocessor.so differ diff --git a/contrib/Individual/models/libsamplepostprocess.so b/contrib/Individual/models/libsamplepostprocess.so new file mode 100644 index 0000000000000000000000000000000000000000..76db642fe1be041951d57a6034eb04a0bf630551 Binary files /dev/null and b/contrib/Individual/models/libsamplepostprocess.so differ diff --git a/contrib/Individual/models/libyolov3postprocess.so b/contrib/Individual/models/libyolov3postprocess.so new file mode 100644 index 0000000000000000000000000000000000000000..d1b897f46e752b8cc01aa39f4463f2166465a220 Binary files /dev/null and b/contrib/Individual/models/libyolov3postprocess.so differ diff --git a/contrib/Individual/models/resnet50_aipp_tf.cfg b/contrib/Individual/models/resnet50_aipp_tf.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5d004f9cbd6c9c2378b866de905162d34ad1a168 --- /dev/null +++ b/contrib/Individual/models/resnet50_aipp_tf.cfg @@ -0,0 +1,2 @@ +CLASS_NUM=40 +SOFTMAX=false \ No newline at end of file diff --git a/contrib/Individual/models/resnet50_aipp_tf1.cfg b/contrib/Individual/models/resnet50_aipp_tf1.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fea8d3e2765b2df571753ab7a28a2df593aeffe6 --- /dev/null +++ b/contrib/Individual/models/resnet50_aipp_tf1.cfg @@ -0,0 +1,3 @@ +ATTRIBUTE_NUM=40 +ATTRIBUTE_INDEX=0%1%2%3%4%5%6%7%8%9%10%11%12%13%14%15%16%17%18%19%20%21%22%23%24%25%26%27%28%29%30%31%32%33%34%35%36%37%38%39% +ACTIVATION_FUNCTION=sigmoid \ No newline at end of file diff --git a/contrib/Individual/models/yolov4.cfg b/contrib/Individual/models/yolov4.cfg new file mode 100644 index 0000000000000000000000000000000000000000..231e4566b70e3484203db45960e11a31d68c21a9 --- /dev/null +++ b/contrib/Individual/models/yolov4.cfg @@ -0,0 +1,10 @@ +CLASS_NUM=4 +BIASES_NUM=12 +BIASES=23,27,37,58,81,82,81,82,135,169,344,319 +SCORE_THRESH=0.4 +OBJECTNESS_THRESH=0.8 +IOU_THRESH=0.5 +YOLO_TYPE=2 +ANCHOR_DIM=3 +MODEL_TYPE=0 +RESIZE_FLAG=0 diff --git a/contrib/Individual/pipeline/.keep b/contrib/Individual/pipeline/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/contrib/Individual/pipeline/Sample.pipeline b/contrib/Individual/pipeline/Sample.pipeline new file mode 100644 index 0000000000000000000000000000000000000000..2f7b7361c5f91ddbd0f1bbc0640a779a9abd25c0 --- /dev/null +++ b/contrib/Individual/pipeline/Sample.pipeline @@ -0,0 +1,58 @@ +{ + "classification+detection": { + "stream_config": { + "deviceId": "0" + }, + "mxpi_imagedecoder0": { + "factory": "mxpi_imagedecoder", + "next": "mxpi_imageresize0" + }, + "mxpi_imageresize0": { + "factory": "mxpi_imageresize", + "next": "face_attribute", + "props": { + "dataSource": "mxpi_imagedecoder0", + "resizeHeight": "224", + "resizeWidth": "224" + } + }, + "face_attribute": { + "props":{ + "dataSource":"mxpi_imageresize0", + "modelPath":"./models/simple.om" + }, + "factory": "mxpi_tensorinfer", + "next": "mxpi_classpostprocessor1" + }, + "mxpi_classpostprocessor1": { + "props": { + "dataSource": "face_attribute", + "postProcessConfigPath": "./models/resnet50_aipp_tf.cfg", + "labelPath": "./models/attr.names", + "postProcessLibPath": "./models/libsamplepostprocess.so" + }, + "factory": "mxpi_classpostprocessor", + "next": "mxpi_dataserialize0" + }, + "mxpi_dataserialize0": { + "props": { + "outputDataKeys": "mxpi_classpostprocessor1" + }, + "factory": "mxpi_dataserialize", + "next": "appsink0" + }, + "appsrc0": { + "props": { + "blocksize": "409600" + }, + "factory": "appsrc", + "next": "mxpi_imagedecoder0" + }, + "appsink0": { + "props": { + "blocksize": "4096000" + }, + "factory": "appsink" + } + } +} diff --git a/contrib/Individual/pipeline/Sample_proto.pipeline b/contrib/Individual/pipeline/Sample_proto.pipeline new file mode 100644 index 0000000000000000000000000000000000000000..b6bb215927c1031b6e29eb147bcb14f11f37288d --- /dev/null +++ b/contrib/Individual/pipeline/Sample_proto.pipeline @@ -0,0 +1,149 @@ +{ + "classification+detection": { + "stream_config": { + "deviceId": "0" + }, + "mxpi_imagedecoder0": { + "factory": "mxpi_imagedecoder", + "next": "mxpi_imageresize0" + }, + "mxpi_imageresize0": { + "factory": "mxpi_imageresize", + "next": "mxpi_tensorinfer0" + }, + "mxpi_tensorinfer0": { + "props": { + "dataSource": "mxpi_imageresize0", + "modelPath": "./models/yolov4_detection.om" + }, + "factory": "mxpi_tensorinfer", + "next": "mxpi_objectpostprocessor0" + }, + "mxpi_objectpostprocessor0": { + "props": { + "dataSource": "mxpi_tensorinfer0", + "postProcessConfigPath": "./models/yolov4.cfg", + "labelPath": "./models/coco.names", + "postProcessLibPath": "./models/libyolov3postprocess.so" + }, + "factory": "mxpi_objectpostprocessor", + "next": "mxpi_objectdistributor0" + }, + "mxpi_objectdistributor0":{ + "props":{ + "classIds":"3,2|1|0", + "dataSource":"mxpi_objectpostprocessor0" + }, + "factory":"mxpi_distributor", + "next":["mxpi_imagecrop0","fakesink0"] + }, + "fakesink0": { + "factory": "fakesink" + }, + "mxpi_imagecrop0": { + "props": { + "dataSource": "mxpi_objectdistributor0_0", + "leftExpandRatio":"0.2", + "rightExpandRatio":"0.2", + "upExpandRatio":"0.2", + "downExpandRatio":"0.2", + "resizeHeight":"224", + "resizeWidth":"224" + }, + "factory": "mxpi_imagecrop", + "next": "tee0" + }, + + "tee0":{ + "props":{}, + "factory":"tee", + "next":[ + "queue0", + "queue1" + ] + }, + "queue0":{ + "props":{ + "max-size-buffers":"50" + }, + "factory":"queue", + "next":"mxpi_imageresize1" + }, + "queue1":{ + "props":{ + "max-size-buffers":"50" + }, + "factory":"queue", + "next":"mxpi_facealignment0:0" + }, + "mxpi_imageresize1": { + "props": { + "resizeHeight":"96", + "resizeWidth":"96", + "dataSource": "mxpi_imagecrop0" + }, + "factory": "mxpi_imageresize", + "next": "face_landmark" + }, + "face_landmark": { + "props":{ + "dataSource":"mxpi_imageresize1", + "modelPath":"./models/face_quality_0605_b1.om", + "postProcessLibPath":"./models/libfacelandmarkpostprocessor.so" + }, + "factory": "mxpi_modelinfer", + "next": "mxpi_facealignment0:1" + }, + "mxpi_facealignment0":{ + "props":{ + "status":"1", + "dataSourceImage":"mxpi_imagecrop0", + "dataSourceKeyPoint":"face_landmark", + "afterFaceAlignmentHeight":"224", + "afterFaceAlignmentWidth":"224" + }, + "factory":"mxpi_facealignment", + "next": "face_attribute" + }, + + "face_attribute": { + "props":{ + "dataSource":"mxpi_facealignment0", + "modelPath":"./models/bgrbgrsimple.om" + }, + "factory": "mxpi_tensorinfer", + "next": "mxpi_classpostprocessor1" + }, + "mxpi_classpostprocessor1": { + "props": { + "dataSource": "face_attribute", + "postProcessConfigPath": "./models/resnet50_aipp_tf.cfg", + "labelPath": "./models/attr.names", + "postProcessLibPath": "./models/libsamplepostprocess.so" + }, + "factory": "mxpi_classpostprocessor", + "next": "mxpi_dataserialize0" + }, + + "mxpi_dataserialize0": { + "props": { + "outputDataKeys": "mxpi_classpostprocessor1" + }, + "factory": "mxpi_dataserialize", + "next": "appsink0" + }, + "appsrc0": { + "props": { + "blocksize": "409600" + }, + "factory": "appsrc", + "next": "mxpi_imagedecoder0" + }, + "appsink0": { + "props": { + "blocksize": "4096000" + }, + "factory": "appsink" + } + } +} diff --git a/contrib/Individual/pipeline/Sample_proto1.pipeline b/contrib/Individual/pipeline/Sample_proto1.pipeline new file mode 100644 index 0000000000000000000000000000000000000000..5d6a804691ebf1fea26cf1a3fd6423aa53ced293 --- /dev/null +++ b/contrib/Individual/pipeline/Sample_proto1.pipeline @@ -0,0 +1,139 @@ +{ + "classification+detection": { + "stream_config": { + "deviceId": "0" + }, + "mxpi_imagedecoder0": { + "factory": "mxpi_imagedecoder", + "next": "mxpi_imageresize0" + }, + "mxpi_imageresize0": { + "factory": "mxpi_imageresize", + "next": "mxpi_tensorinfer0" + }, + "mxpi_tensorinfer0": { + "props": { + "dataSource": "mxpi_imageresize0", + "modelPath": "./models/yolov4_detection.om" + }, + "factory": "mxpi_tensorinfer", + "next": "mxpi_objectpostprocessor0" + }, + "mxpi_objectpostprocessor0": { + "props": { + "dataSource": "mxpi_tensorinfer0", + "postProcessConfigPath": "./models/yolov4.cfg", + "labelPath": "./models/coco.names", + "postProcessLibPath": "/home/nku_wang6/mxVision/lib/modelpostprocessors/libyolov3postprocess.so" + }, + "factory": "mxpi_objectpostprocessor", + "next": "mxpi_imagecrop0" + }, + + "mxpi_imagecrop0": { + "props": { + "dataSource": "mxpi_objectpostprocessor0", + "leftExpandRatio":"0.2", + "rightExpandRatio":"0.2", + "upExpandRatio":"0.2", + "downExpandRatio":"0.2", + "resizeHeight":"224", + "resizeWidth":"224" + }, + "factory": "mxpi_imagecrop", + "next": "tee0" + }, + + "tee0":{ + "props":{}, + "factory":"tee", + "next":[ + "queue0", + "queue1" + ] + }, + "queue0":{ + "props":{ + "max-size-buffers":"50" + }, + "factory":"queue", + "next":"mxpi_imageresize1" + }, + "queue1":{ + "props":{ + "max-size-buffers":"50" + }, + "factory":"queue", + "next":"mxpi_facealignment0:0" + }, + "mxpi_imageresize1": { + "props": { + "resizeHeight":"96", + "resizeWidth":"96", + "dataSource": "mxpi_imagecrop0" + }, + "factory": "mxpi_imageresize", + "next": "face_landmark" + }, + "face_landmark": { + "props":{ + "dataSource":"mxpi_imageresize1", + "modelPath":"./models/face_quality_0605_b1.om", + "postProcessLibPath":"/home/nku_wang6/mxVision/lib/libfacelandmarkpostprocessor.so" + }, + "factory": "mxpi_modelinfer", + "next": "mxpi_facealignment0:1" + }, + "mxpi_facealignment0":{ + "props":{ + "status":"1", + "dataSourceImage":"mxpi_imagecrop0", + "dataSourceKeyPoint":"face_landmark", + "afterFaceAlignmentHeight":"224", + "afterFaceAlignmentWidth":"224" + }, + "factory":"mxpi_facealignment", + "next": "face_attribute" + }, + + "face_attribute": { + "props":{ + "dataSource":"mxpi_facealignment0", + "modelPath":"./models/bgrbgrsimple.om" + }, + "factory": "mxpi_tensorinfer", + "next": "mxpi_classpostprocessor1" + }, + "mxpi_classpostprocessor1": { + "props": { + "dataSource": "face_attribute", + "postProcessConfigPath": "./models/resnet50_aipp_tf.cfg", + "labelPath": "./models/attr.names", + "postProcessLibPath": "/home/nku_wang6/mxVision/lib/modelpostprocessors/libsamplepostprocess.so" + }, + "factory": "mxpi_classpostprocessor", + "next": "mxpi_dataserialize0" + }, + + "mxpi_dataserialize0": { + "props": { + "outputDataKeys": "mxpi_classpostprocessor1" + }, + "factory": "mxpi_dataserialize", + "next": "appsink0" + }, + "appsrc0": { + "props": { + "blocksize": "409600" + }, + "factory": "appsrc", + "next": "mxpi_imagedecoder0" + }, + "appsink0": { + "props": { + "blocksize": "4096000" + }, + "factory": "appsink" + } + } +} diff --git a/contrib/Individual/run.sh b/contrib/Individual/run.sh new file mode 100644 index 0000000000000000000000000000000000000000..1d348d753e1de4c04f810c8ca3a70411477efd59 --- /dev/null +++ b/contrib/Individual/run.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright(C) 2021. Huawei Technologies Co.,Ltd. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -e + +CUR_PATH=$(cd "$(dirname "$0")" || { warn "Failed to check path/to/run.sh" ; exit ; } ; pwd) + +# Simple log helper functions +info() { echo -e "\033[1;34m[INFO ][MxStream] $1\033[1;37m" ; } +warn() { echo >&2 -e "\033[1;31m[WARN ][MxStream] $1\033[1;37m" ; } + +export MX_SDK_HOME=${CUR_PATH}/../../.. +export LD_LIBRARY_PATH=${MX_SDK_HOME}/lib:${MX_SDK_HOME}/opensource/lib:${MX_SDK_HOME}/opensource/lib64:/usr/local/Ascend/ascend-toolkit/latest/acllib/lib64:${LD_LIBRARY_PATH} +export GST_PLUGIN_SCANNER=${MX_SDK_HOME}/opensource/libexec/gstreamer-1.0/gst-plugin-scanner +export GST_PLUGIN_PATH=${MX_SDK_HOME}/opensource/lib/gstreamer-1.0:${MX_SDK_HOME}/lib/plugins:/home/nku_wang6/mxVision-2.0.2/samples/mindx_sdk_plugin + +#to set PYTHONPATH, import the StreamManagerApi.py +export PYTHONPATH=$PYTHONPATH:${MX_SDK_HOME}/python + +python3.7 main.py +exit 0 \ No newline at end of file