Skip to content

Commit

Permalink
Add deprecation message for deploy tools (open-mmlab#1207)
Browse files Browse the repository at this point in the history
* add derepcation message for deploy tools

* change import warnings positions

* do yapf

* do isort
  • Loading branch information
QwQ2000 authored and ly015 committed Mar 7, 2022
1 parent 3919c89 commit f210cc9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tools/deployment/mmpose2torchserve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import warnings
from argparse import ArgumentParser, Namespace
from tempfile import TemporaryDirectory

Expand Down Expand Up @@ -114,6 +115,18 @@ def parse_args():
if __name__ == '__main__':
args = parse_args()

# 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)

if package_model is None:
raise ImportError('`torch-model-archiver` is required.'
'Try: pip install torch-model-archiver')
Expand Down
13 changes: 13 additions & 0 deletions tools/deployment/pytorch2onnx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import argparse
import warnings

import numpy as np
import torch
Expand Down Expand Up @@ -132,6 +133,18 @@ def parse_args():

assert args.opset_version == 11, 'MMPose only supports opset 11 now'

# 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)

model = init_pose_model(args.config, args.checkpoint, device='cpu')
model = _convert_batchnorm(model)

Expand Down
13 changes: 13 additions & 0 deletions tools/deployment/test_torchserver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
import warnings
from argparse import ArgumentParser

import requests
Expand Down Expand Up @@ -64,3 +65,15 @@ def main(args):
if __name__ == '__main__':
args = parse_args()
main(args)

# 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)

0 comments on commit f210cc9

Please sign in to comment.