Skip to content

Commit

Permalink
Merge pull request open-mmlab#38 from opencv/feature/ik/save_complexi…
Browse files Browse the repository at this point in the history
…ty_to_json

Feature/ik/save complexity to json
  • Loading branch information
Ilya-Krylov authored May 26, 2020
2 parents d1d8011 + 65d826f commit ce85416
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/get_flops.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import argparse
import json

from mmcv import Config

from mmdet.models import build_detector
from mmdet.utils import get_model_complexity_info


def parse_args():
parser = argparse.ArgumentParser(description='Train a detector')
parser.add_argument('config', help='train config file path')
Expand All @@ -15,6 +15,7 @@ def parse_args():
nargs='+',
default=[1280, 800],
help='input image size')
parser.add_argument('--out')
args = parser.parse_args()
return args

Expand Down Expand Up @@ -50,6 +51,14 @@ def main():
'You may need to check if all ops are supported and verify that the '
'flops computation is correct.')

if args.out:
out = list()
out.append({'key': 'size', 'displayName': 'Size', 'value': float(params.split(' ')[0]), 'unit': 'Mp'})
out.append({'key': 'complexity', 'displayName': 'Complexity', 'value': 2 * float(flops.split(' ')[0]),
'unit': 'GFLOPs'})
with open(args.out, 'w') as write_file:
json.dump(out, write_file, indent=4)


if __name__ == '__main__':
main()

0 comments on commit ce85416

Please sign in to comment.