Skip to content

Commit 9524f37

Browse files
authored
add print model graph args for tools/print_config.py (#451)
* add print model graph for print_config tool * add print model graph for print_config tool * fix double quoted * fix iosort
1 parent 4345ee3 commit 9524f37

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/print_config.py

+10
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
from mmcv import Config, DictAction
44

5+
from mmseg.apis import init_segmentor
6+
57

68
def parse_args():
79
parser = argparse.ArgumentParser(description='Print the whole config')
810
parser.add_argument('config', help='config file path')
11+
parser.add_argument(
12+
'--graph', action='store_true', help='print the models graph')
913
parser.add_argument(
1014
'--options', nargs='+', action=DictAction, help='arguments in dict')
1115
args = parser.parse_args()
@@ -22,6 +26,12 @@ def main():
2226
print(f'Config:\n{cfg.pretty_text}')
2327
# dump config
2428
cfg.dump('example.py')
29+
# dump models graph
30+
if args.graph:
31+
model = init_segmentor(args.config, device='cpu')
32+
print(f'Model graph:\n{str(model)}')
33+
with open('example-graph.txt', 'w') as f:
34+
f.writelines(str(model))
2535

2636

2737
if __name__ == '__main__':

0 commit comments

Comments
 (0)