-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate supported-backends markdown table (#1986)
* Generate supported-backends markdown table * Generate supported-backends markdown table * update branch * update codebase dir * update backends nargs * update args to capitals * center alignment starting from the 3rd coloumn * center alignment starting from the 3rd coloumn * fix bad urls * fix bad urls * Update codebases.txt fix circleci * Update codebases.txt --------- Co-authored-by: RunningLeon <[email protected]>
- Loading branch information
1 parent
6c26e88
commit 671d626
Showing
15 changed files
with
178 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ mmedit>=1.0.0rc2 | |
mmocr>=1.0.0rc4 | ||
mmpose>=1.0.0rc0 | ||
mmrotate>=1.0.0rc0 | ||
mmsegmentation @ git+https://github.com/open-mmlab/[email protected] | ||
mmsegmentation>=1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import argparse | ||
import os | ||
import os.path as osp | ||
|
||
import yaml | ||
from mmengine import Config | ||
|
||
from mmdeploy.utils import get_backend, get_task_type, load_config | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser( | ||
description='from yaml export markdown table') | ||
parser.add_argument('yml_file', help='input yml config path') | ||
parser.add_argument('output', help='output markdown file path') | ||
parser.add_argument( | ||
'--backends', | ||
nargs='+', | ||
help='backends you want to generate', | ||
default=[ | ||
'onnxruntime', 'tensorrt', 'torchscript', 'pplnn', 'openvino', | ||
'ncnn' | ||
]) | ||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
assert osp.exists(args.yml_file), f'File not exists: {args.yml_file}' | ||
output_dir, _ = osp.split(args.output) | ||
if output_dir: | ||
os.makedirs(output_dir, exist_ok=True) | ||
header = ['model', 'task'] + args.backends | ||
aligner = [':--'] * 2 + [':--:'] * len(args.backends) | ||
|
||
def write_row_f(writer, row): | ||
writer.write('|' + '|'.join(row) + '|\n') | ||
|
||
print(f'Processing{args.yml_file}') | ||
with open(args.yml_file, 'r') as reader, open(args.output, 'w') as writer: | ||
config = yaml.load(reader, Loader=yaml.FullLoader) | ||
config = Config(config) | ||
write_row_f(writer, header) | ||
write_row_f(writer, aligner) | ||
repo_url = config.globals.repo_url | ||
for i in range(len(config.models)): | ||
name = config.models[i].name | ||
model_configs = config.models[i].model_configs | ||
pipelines = config.models[i].pipelines | ||
config_url = osp.join(repo_url, model_configs[0]) | ||
config_url, _ = osp.split(config_url) | ||
support_backends = {b: 'N' for b in args.backends} | ||
deploy_config = [ | ||
pipelines[i].deploy_config for i in range(len(pipelines)) | ||
] | ||
cfg = [ | ||
load_config(deploy_config[i]) | ||
for i in range(len(deploy_config)) | ||
] | ||
task = [ | ||
get_task_type(cfg[i][0]).value | ||
for i in range(len(deploy_config)) | ||
] | ||
backend_type = [ | ||
get_backend(cfg[i][0]).value | ||
for i in range(len(deploy_config)) | ||
] | ||
for i in range(len(deploy_config)): | ||
support_backends[backend_type[i]] = 'Y' | ||
support_backends = [support_backends[i] for i in args.backends] | ||
model_name = f'[{name}]({config_url})' | ||
row = [model_name, task[i]] + support_backends | ||
|
||
write_row_f(writer, row) | ||
print(f'Save to {args.output}') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |