其实就是把mmdet里的FPS Benchmark改成mmocr里的,mmdet里的FPS Benchmark链接为:https://mmdetection.readthedocs.io/en/latest/useful_tools.html?highlight=fps#fps-benchmark,运行时执行python -m torch.distributed.launch --nproc_per_node=1 --master_port=29500 tools/ana_fps.py configs/textdet/drrg/drrg_r50_adam.py res/drrg_adam_pre/epoch_200.pth --launcher pytorch
我把这个文件放在了tools/ana_fps.py 里,仅供参考。
具体代码如下:
# Copyright (c) OpenMMLab. All rights reserved.
import argparse
import copy
import os
import time
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDistributedDataParallel
from mmcv.runner import init_dist, load_checkpoint, wrap_fp16_model
from mmdet.datasets import replace_ImageToTensor
from mmocr.datasets import build_dataloader, build_dataset
from mmocr.models import build_detector
def parse_args():
parser = argparse.ArgumentParser(description='MMDet benchmark a model')
parser.add_argument('config', help='test config file path')
parser.add_argument('checkpoint', help='checkpoint file')
parser.add_argument(
'--repeat-num',
type=int,
default=1,
help='number of repeat times of measurement for averaging the results')
parser.add_argument(
'--max-iter', type=int, default=2000, help='num of max iter')
parser.add_argument(
'--log-interval', type=int, default=50, help='interval of logging')
parser.add_argument(
'--fuse-conv-bn',
action='store_true',
help='Whether to fuse conv and bn, this will slightly increase'
'the inference speed')
parser.add_argument(
'--cfg-options',
nargs='