From 27fd71382a4f32db4c558ccb86a7b41c7916555d Mon Sep 17 00:00:00 2001 From: wangguanzhong Date: Wed, 17 Jun 2020 12:28:15 +0800 Subject: [PATCH] add python version check for visualdl (#951) --- docs/tutorials/GETTING_STARTED.md | 4 ++-- docs/tutorials/GETTING_STARTED_cn.md | 4 ++-- tools/infer.py | 2 ++ tools/train.py | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/GETTING_STARTED.md b/docs/tutorials/GETTING_STARTED.md index 69bd1a7bb..21c9da45f 100644 --- a/docs/tutorials/GETTING_STARTED.md +++ b/docs/tutorials/GETTING_STARTED.md @@ -41,8 +41,8 @@ list below can be viewed by `--help` | --draw_threshold | infer | Threshold to reserve the result for visualization | 0.5 | `--draw_threshold 0.7` | | --infer_dir | infer | Directory for images to perform inference on | None | | | --infer_img | infer | Image path | None | higher priority over --infer_dir | -| --use_vdl | train/infer | Whether to record the data with [VisualDL](https://github.com/paddlepaddle/visualdl), so as to display in VisualDL | False | | -| --vdl\_log_dir | train/infer | VisualDL logging directory for image | train:`vdl_log_dir/scalar` infer: `vdl_log_dir/image` | | +| --use_vdl | train/infer | Whether to record the data with [VisualDL](https://github.com/paddlepaddle/visualdl), so as to display in VisualDL | False | VisualDL requires Python>=3.5 | +| --vdl\_log_dir | train/infer | VisualDL logging directory for image | train:`vdl_log_dir/scalar` infer: `vdl_log_dir/image` | VisualDL requires Python>=3.5 | ## Examples diff --git a/docs/tutorials/GETTING_STARTED_cn.md b/docs/tutorials/GETTING_STARTED_cn.md index 0bc7a445a..462d5a86e 100644 --- a/docs/tutorials/GETTING_STARTED_cn.md +++ b/docs/tutorials/GETTING_STARTED_cn.md @@ -38,8 +38,8 @@ python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_img=demo/0000005 | --draw_threshold | infer | 可视化时分数阈值 | 0.5 | `--draw_threshold 0.7` | | --infer_dir | infer | 用于预测的图片文件夹路径 | None | | | --infer_img | infer | 用于预测的图片路径 | None | 相较于`--infer_dir`具有更高优先级 | -| --use_vdl | train/infer | 是否使用[VisualDL](https://github.com/paddlepaddle/visualdl)记录数据,进而在VisualDL面板中显示 | False | | -| --vdl\_log_dir | train/infer | 指定 VisualDL 记录数据的存储路径 | train:`vdl_log_dir/scalar` infer: `vdl_log_dir/image` | | +| --use_vdl | train/infer | 是否使用[VisualDL](https://github.com/paddlepaddle/visualdl)记录数据,进而在VisualDL面板中显示 | False | VisualDL需Python>=3.5 | +| --vdl\_log_dir | train/infer | 指定 VisualDL 记录数据的存储路径 | train:`vdl_log_dir/scalar` infer: `vdl_log_dir/image` | VisualDL需Python>=3.5 | ## 使用示例 diff --git a/tools/infer.py b/tools/infer.py index 2ffb0e8fd..e4ee0a7cc 100644 --- a/tools/infer.py +++ b/tools/infer.py @@ -24,6 +24,7 @@ if parent_path not in sys.path: import glob import numpy as np +import six from PIL import Image from paddle import fluid @@ -160,6 +161,7 @@ def main(): # use VisualDL to log image if FLAGS.use_vdl: + assert six.PY3, "VisualDL requires Python >= 3.5" from visualdl import LogWriter vdl_writer = LogWriter(FLAGS.vdl_log_dir) vdl_image_step = 0 diff --git a/tools/train.py b/tools/train.py index 017fed672..828f54818 100644 --- a/tools/train.py +++ b/tools/train.py @@ -26,6 +26,7 @@ import time import numpy as np import random import datetime +import six from collections import deque from paddle.fluid import profiler @@ -224,6 +225,7 @@ def main(): # use VisualDL to log data if FLAGS.use_vdl: + assert six.PY3, "VisualDL requires Python >= 3.5" from visualdl import LogWriter vdl_writer = LogWriter(FLAGS.vdl_log_dir) vdl_loss_step = 0 -- GitLab