@@ -45,8 +45,85 @@ python tools/analysis_tools/offline_eval.py configs/textdet/psenet/psenet_r50_fp
45
45
46
46
In addition, based on this tool, users can also convert predictions obtained from other libraries into MMOCR-supported formats, then use MMOCR's built-in metrics to evaluate them.
47
47
48
- | ARGS | Type | Description |
49
- | ------------- | ----- | --------------------------------- |
50
- | config | str | (required) Path to the config. |
51
- | pkl_results | str | (required) The saved predictions. |
52
- | --cfg-options | float | Override configs. [ Example] ( < > ) |
48
+ | ARGS | Type | Description |
49
+ | ------------- | ----- | ------------------------------------------------------------------ |
50
+ | config | str | (required) Path to the config. |
51
+ | pkl_results | str | (required) The saved predictions. |
52
+ | --cfg-options | float | Override configs. [ Example] ( ./config.md#command-line-modification ) |
53
+
54
+ ### Calculate FLOPs and the Number of Parameters
55
+
56
+ We provide a method to calculate the FLOPs and the number of parameters, first we install the dependencies using the following command.
57
+
58
+ ``` shell
59
+ pip install fvcore
60
+ ```
61
+
62
+ The usage of the script to calculate FLOPs and the number of parameters is as follows.
63
+
64
+ ``` shell
65
+ python tools/analysis_tools/get_flops.py ${config} --shape ${IMAGE_SHAPE}
66
+ ```
67
+
68
+ | ARGS | Type | Description |
69
+ | ------- | ---- | ----------------------------------------------------------------------------------------- |
70
+ | config | str | (required) Path to the config. |
71
+ | --shape | int | Image size to use when calculating FLOPs, such as ` --shape 320 320 ` . Default is ` 640 640 ` |
72
+
73
+ For example, you can run the following command to get FLOPs and the number of parameters of ` dbnet_resnet18_fpnc_100k_synthtext.py ` :
74
+
75
+ ``` shell
76
+ python tools/analysis_tools/get_flops.py configs/textdet/dbnet/dbnet_resnet18_fpnc_100k_synthtext.py --shape 1024 1024
77
+ ```
78
+
79
+ The output is as follows:
80
+
81
+ ``` shell
82
+ input shape is (1, 3, 1024, 1024)
83
+ | module | # parameters or shape | #flops |
84
+ | :------------------------ | :------------------- | :------ |
85
+ | model | 12.341M | 63.955G |
86
+ | backbone | 11.177M | 38.159G |
87
+ | backbone.conv1 | 9.408K | 2.466G |
88
+ | backbone.conv1.weight | (64, 3, 7, 7) | |
89
+ | backbone.bn1 | 0.128K | 83.886M |
90
+ | backbone.bn1.weight | (64,) | |
91
+ | backbone.bn1.bias | (64,) | |
92
+ | backbone.layer1 | 0.148M | 9.748G |
93
+ | backbone.layer1.0 | 73.984K | 4.874G |
94
+ | backbone.layer1.1 | 73.984K | 4.874G |
95
+ | backbone.layer2 | 0.526M | 8.642G |
96
+ | backbone.layer2.0 | 0.23M | 3.79G |
97
+ | backbone.layer2.1 | 0.295M | 4.853G |
98
+ | backbone.layer3 | 2.1M | 8.616G |
99
+ | backbone.layer3.0 | 0.919M | 3.774G |
100
+ | backbone.layer3.1 | 1.181M | 4.842G |
101
+ | backbone.layer4 | 8.394M | 8.603G |
102
+ | backbone.layer4.0 | 3.673M | 3.766G |
103
+ | backbone.layer4.1 | 4.721M | 4.837G |
104
+ | neck | 0.836M | 14.887G |
105
+ | neck.lateral_convs | 0.246M | 2.013G |
106
+ | neck.lateral_convs.0.conv | 16.384K | 1.074G |
107
+ | neck.lateral_convs.1.conv | 32.768K | 0.537G |
108
+ | neck.lateral_convs.2.conv | 65.536K | 0.268G |
109
+ | neck.lateral_convs.3.conv | 0.131M | 0.134G |
110
+ | neck.smooth_convs | 0.59M | 12.835G |
111
+ | neck.smooth_convs.0.conv | 0.147M | 9.664G |
112
+ | neck.smooth_convs.1.conv | 0.147M | 2.416G |
113
+ | neck.smooth_convs.2.conv | 0.147M | 0.604G |
114
+ | neck.smooth_convs.3.conv | 0.147M | 0.151G |
115
+ | det_head | 0.329M | 10.909G |
116
+ | det_head.binarize | 0.164M | 10.909G |
117
+ | det_head.binarize.0 | 0.147M | 9.664G |
118
+ | det_head.binarize.1 | 0.128K | 20.972M |
119
+ | det_head.binarize.3 | 16.448K | 1.074G |
120
+ | det_head.binarize.4 | 0.128K | 83.886M |
121
+ | det_head.binarize.6 | 0.257K | 67.109M |
122
+ | det_head.threshold | 0.164M | |
123
+ | det_head.threshold.0 | 0.147M | |
124
+ | det_head.threshold.1 | 0.128K | |
125
+ | det_head.threshold.3 | 16.448K | |
126
+ | det_head.threshold.4 | 0.128K | |
127
+ | det_head.threshold.6 | 0.257K | |
128
+ !!! Please be cautious if you use the results in papers. You may need to check if all ops are supported and verify that the flops computation is correct.
129
+ ` ` `
0 commit comments