提交 34b79406 编写于 作者: Z Zeyu

add ssd demo

上级 d4fb75b1
......@@ -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
```
import os
import paddlehub as hub
def infer_with_input_path():
# get ssd module
if __name__ == "__main__":
ssd = hub.Module(name="ssd_mobilenet_v1_pascal")
test_img_path = os.path.join("test", "test_img_bird.jpg")
......@@ -19,26 +17,3 @@ def infer_with_input_path():
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()
......@@ -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 \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册