From 9ee41577d010fdd98637b4239e31a51b017c3459 Mon Sep 17 00:00:00 2001 From: RunningLeon Date: Wed, 23 Feb 2022 22:24:44 +0800 Subject: [PATCH] [Enhance] Add deprecation message for deploy tools. (#697) * add derepcation message for deploy tools * add space * Update tools/deployment/onnx2tensorrt.py Co-authored-by: Ma Zerun * remove colorama package * use plaintext to avoid import mmcv Co-authored-by: Ma Zerun --- tools/deployment/onnx2tensorrt.py | 13 +++++++++++++ tools/deployment/pytorch2onnx.py | 13 +++++++++++++ tools/deployment/test.py | 12 ++++++++++++ 3 files changed, 38 insertions(+) diff --git a/tools/deployment/onnx2tensorrt.py b/tools/deployment/onnx2tensorrt.py index 0bb163cf..8f71b615 100644 --- a/tools/deployment/onnx2tensorrt.py +++ b/tools/deployment/onnx2tensorrt.py @@ -2,6 +2,7 @@ import argparse import os import os.path as osp +import warnings import numpy as np @@ -140,3 +141,15 @@ if __name__ == '__main__': fp16_mode=args.fp16, verify=args.verify, workspace_size=args.workspace_size) + + # Following strings of text style are from colorama package + bright_style, reset_style = '\x1b[1m', '\x1b[0m' + red_text, blue_text = '\x1b[31m', '\x1b[34m' + white_background = '\x1b[107m' + + msg = white_background + bright_style + red_text + msg += 'DeprecationWarning: This tool will be deprecated in future. ' + msg += blue_text + 'Welcome to use the unified model deployment toolbox ' + msg += 'MMDeploy: https://github.com/open-mmlab/mmdeploy' + msg += reset_style + warnings.warn(msg) diff --git a/tools/deployment/pytorch2onnx.py b/tools/deployment/pytorch2onnx.py index 87fafa3d..1da95946 100644 --- a/tools/deployment/pytorch2onnx.py +++ b/tools/deployment/pytorch2onnx.py @@ -1,5 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse +import warnings from functools import partial import mmcv @@ -231,3 +232,15 @@ if __name__ == '__main__': output_file=args.output_file, do_simplify=args.simplify, verify=args.verify) + + # Following strings of text style are from colorama package + bright_style, reset_style = '\x1b[1m', '\x1b[0m' + red_text, blue_text = '\x1b[31m', '\x1b[34m' + white_background = '\x1b[107m' + + msg = white_background + bright_style + red_text + msg += 'DeprecationWarning: This tool will be deprecated in future. ' + msg += blue_text + 'Welcome to use the unified model deployment toolbox ' + msg += 'MMDeploy: https://github.com/open-mmlab/mmdeploy' + msg += reset_style + warnings.warn(msg) diff --git a/tools/deployment/test.py b/tools/deployment/test.py index c13ef9a1..aeaa7bb9 100644 --- a/tools/deployment/test.py +++ b/tools/deployment/test.py @@ -114,3 +114,15 @@ def main(): if __name__ == '__main__': main() + + # Following strings of text style are from colorama package + bright_style, reset_style = '\x1b[1m', '\x1b[0m' + red_text, blue_text = '\x1b[31m', '\x1b[34m' + white_background = '\x1b[107m' + + msg = white_background + bright_style + red_text + msg += 'DeprecationWarning: This tool will be deprecated in future. ' + msg += blue_text + 'Welcome to use the unified model deployment toolbox ' + msg += 'MMDeploy: https://github.com/open-mmlab/mmdeploy' + msg += reset_style + warnings.warn(msg)