diff --git a/PaddleCV/face_detection/README_cn.md b/PaddleCV/face_detection/README_cn.md index 75df49f1582559fc2d3cfdd1235b1d4c49d46cd0..3329a914af4fd12ae943fdc09ba7a6a15995db77 100644 --- a/PaddleCV/face_detection/README_cn.md +++ b/PaddleCV/face_detection/README_cn.md @@ -111,6 +111,7 @@ python -u train.py --batch_size=16 --pretrained_model=vgg_ilsvrc_16_fc_reduced **注意**: - 本次开源模型中CPM模块与论文中有些许不同,相比论文中CPM模块训练和测试速度更快。 - Pyramid Anchors模块的body部分可以针对不同情况,进行相应的长宽设置来调参。同时face、head、body部分的loss对应的系数也可以通过调参优化。 + - 针对GPU资源有限时,可采取显存优化策略,`train.py` 与 `derface_eval.py` 已经加入部分显存优化FLAGS,详情更多内容请参考[API文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/flags/memory_cn.html#flags-fraction-of-gpu-memory-to-use) ### 模型评估 diff --git a/PaddleCV/face_detection/widerface_eval.py b/PaddleCV/face_detection/widerface_eval.py index 8ce7c3f37dca5399087b2311a02cb455b99a0bdf..27a0d28562ff3172517d2ce5e679f1ad18d72927 100644 --- a/PaddleCV/face_detection/widerface_eval.py +++ b/PaddleCV/face_detection/widerface_eval.py @@ -22,6 +22,19 @@ import argparse import functools from PIL import Image +def set_paddle_flags(**kwargs): + for key, value in kwargs.items(): + if os.environ.get(key, None) is None: + os.environ[key] = str(value) + +# NOTE(paddle-dev): All of these flags should be +# set before `import paddle`. Otherwise, it would +# not take any effect. +set_paddle_flags( + FLAGS_eager_delete_tensor_gb=0, # enable GC to save memory +) + + import paddle.fluid as fluid import reader from pyramidbox import PyramidBox @@ -324,6 +337,7 @@ if __name__ == '__main__': is_infer=True) infer_program, nmsed_out = network.infer(main_program) fetches = [nmsed_out] + exe.run(startup_program) fluid.io.load_persistables( exe, args.model_dir, main_program=infer_program) # save model and program