diff --git a/demo/ssd/README.md b/demo/ssd/README.md index 0a6aafb2534b60c0910755e374f098fb03a0fbd4..2b3f5cbca98577fe3486d02bfbac68b7f7306bd5 100644 --- a/demo/ssd/README.md +++ b/demo/ssd/README.md @@ -27,18 +27,18 @@ $ pip install --upgrade paddlepaddle ## 命令行方式预测 -`infer.sh`给出了使用命令行调用Module预测的示例脚本 +`cli_demo.sh`给出了使用命令行调用Module预测的示例脚本 通过以下命令试验下效果 ```shell -$ sh infer.sh +$ sh cli_demo.sh ``` ## 通过python API预测 -`infer_by_code.py`给出了使用python API调用Module预测的示例代码 +`ssd_demo.py`给出了使用python API调用Module预测的示例代码 通过以下命令试验下效果 ```shell -python infer_by_code.py +python ssd_demo.py ``` diff --git a/demo/ssd/infer.sh b/demo/ssd/cli_demo.sh similarity index 100% rename from demo/ssd/infer.sh rename to demo/ssd/cli_demo.sh diff --git a/demo/ssd/infer_by_code.py b/demo/ssd/infer_by_code.py deleted file mode 100644 index 10e65bb22df899be67e65581ab0cefef0ddeb6e4..0000000000000000000000000000000000000000 --- a/demo/ssd/infer_by_code.py +++ /dev/null @@ -1,44 +0,0 @@ -import os -import paddlehub as hub - - -def infer_with_input_path(): - # get ssd module - ssd = hub.Module(name="ssd_mobilenet_v1_pascal") - - test_img_path = os.path.join("test", "test_img_bird.jpg") - - # get the input keys for signature 'object_detection' - data_format = ssd.processor.data_format(sign_name='object_detection') - key = list(data_format.keys())[0] - - # set input dict - input_dict = {key: [test_img_path]} - - # execute predict and print the result - results = ssd.object_detection(data=input_dict) - for result in results: - hub.logger.info(result) - - -def infer_with_input_file(): - # get ssd module - ssd = hub.Module(name="ssd_mobilenet_v1_pascal") - - # get the input keys for signature 'object_detection' - data_format = ssd.processor.data_format(sign_name='object_detection') - key = list(data_format.keys())[0] - - # parse input file - test_file = os.path.join("test", "test.txt") - test_images = hub.io.parser.txt_parser.parse(test_file) - - # set input dict - input_dict = {key: test_images} - results = ssd.object_detection(data=input_dict) - for result in results: - hub.logger.info(result) - - -if __name__ == "__main__": - infer_with_input_file() diff --git a/demo/ssd/ssd_demo.py b/demo/ssd/ssd_demo.py new file mode 100644 index 0000000000000000000000000000000000000000..4a24751f9829d285c8242f4e4606144183eedfb2 --- /dev/null +++ b/demo/ssd/ssd_demo.py @@ -0,0 +1,19 @@ +import os +import paddlehub as hub + +if __name__ == "__main__": + ssd = hub.Module(name="ssd_mobilenet_v1_pascal") + + test_img_path = os.path.join("test", "test_img_bird.jpg") + + # get the input keys for signature 'object_detection' + data_format = ssd.processor.data_format(sign_name='object_detection') + key = list(data_format.keys())[0] + + # set input dict + input_dict = {key: [test_img_path]} + + # execute predict and print the result + results = ssd.object_detection(data=input_dict) + for result in results: + hub.logger.info(result) diff --git a/demo/text-classification/run_classifier.sh b/demo/text-classification/run_classifier.sh index 0b53a268c31929fd810138bf0fa36ab41469fc60..cb80a788c9d47caed011bca576512ecc9c4e8b2f 100644 --- a/demo/text-classification/run_classifier.sh +++ b/demo/text-classification/run_classifier.sh @@ -10,7 +10,7 @@ CKPT_DIR="./ckpt_${DATASET}" python -u text_classifier.py \ --batch_size=24 \ - --use_gpu=True \ + --use_gpu=False \ --dataset=${DATASET} \ --checkpoint_dir=${CKPT_DIR} \ --learning_rate=5e-5 \