diff --git a/.gitignore b/.gitignore index adfae9cc..83dc99d5 100644 --- a/.gitignore +++ b/.gitignore @@ -112,4 +112,4 @@ dpl/output/ .viminfo # inner egs -inner +delta_inner diff --git a/docs/development/contributing.md b/docs/development/contributing.md index ffe45a6d..57d6e098 100644 --- a/docs/development/contributing.md +++ b/docs/development/contributing.md @@ -35,9 +35,9 @@ Before commit golang code, plase using `go fmt` and `go vec` to format and lint ## Logging guideline -For `python` using [abseil-py](https://github.com/abseil/abseil-py). +For `python` using [abseil-py](https://github.com/abseil/abseil-py), [more info](https://abseil.io/docs/python/). -For C++ using [abseil-cpp](https://github.com/abseil/abseil-cpp). +For C++ using [abseil-cpp](https://github.com/abseil/abseil-cpp), [more info](https://abseil.io/docs/cpp/). For Golang using [glog](https://github.com/golang/glog). diff --git a/utils/pb_pbtxt.py b/utils/pb_pbtxt.py index e5147753..1d2be4de 100755 --- a/utils/pb_pbtxt.py +++ b/utils/pb_pbtxt.py @@ -65,8 +65,10 @@ def main(_): logging.info(f"dump graph to {dump_dir}") if __name__ == '__main__': + # flags usage: https://abseil.io/docs/python/guides/flags logging.set_verbosity(logging.INFO) - flags.DEFINE_string('graph', default=None, help='graph.pb file name') - flags.DEFINE_bool('binary_in', default=True, help='input graph is binary or not') + flags.DEFINE_string('graph', default=None, help='graph.pb file name', short_name='g') + flags.DEFINE_bool('binary_in', default=True, help='input graph is binary or not', short_name='b') + flags.mark_flag_as_required('graph') app.run(main) diff --git a/utils/run_saved_model.py b/utils/run_saved_model.py index d4be979e..3dab707b 100755 --- a/utils/run_saved_model.py +++ b/utils/run_saved_model.py @@ -17,6 +17,7 @@ ''' Saved & Frozen & Checkpoint model Evaluater''' import os from absl import logging +from absl import flags from absl import app from delta import utils @@ -59,10 +60,12 @@ def main(_): def define_flags(): ''' define flags for evaluator''' # The GPU devices which are visible for current process - app.flags.DEFINE_string('gpu', '', 'same to CUDA_VISIBLE_DEVICES') - app.flags.DEFINE_string('config', 'conf/xxx.yml', help='path to yaml config file') - app.flags.DEFINE_string('mode', 'eval', 'one of eval, infer, eval_and_infer') - app.flags.DEFINE_boolean('debug', False, 'debug mode') + flags.DEFINE_string('gpu', '', 'same to CUDA_VISIBLE_DEVICES') + flags.DEFINE_string('config', None, help='path to yaml config file') + flags.DEFINE_enum('mode', 'eval',['eval', 'infer', 'eval_and_infer'], 'eval or infer') + flags.DEFINE_bool('debug', False, 'debug mode') + # https://github.com/abseil/abseil-py/blob/master/absl/flags/_validators.py#L330 + flags.mark_flags_as_required(['config', 'mode']) if __name__ == '__main__': logging.set_verbosity(logging.INFO)