MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / flops_cal

Function flops_cal

PATH/helper/flops_helper.py:35–47  ·  view source on GitHub ↗
(model, input_shape)

Source from the content-addressed store, hash-verified

33
34
35def flops_cal(model, input_shape):
36 inputs = {
37 'image': torch.randn(1, input_shape[0], input_shape[1], input_shape[2]),
38 'image_info': [[input_shape[1], input_shape[2], 1, input_shape[1], input_shape[2], False]],
39 'filename': ['Test.jpg'],
40 'label': torch.LongTensor([[0]]),
41 }
42 # flops, params = profile(model, inputs=(to_device(inputs),))
43 flops, params = profile(model, inputs=(inputs,))
44 flops_str, params_str = clever_format([flops, params], "%.3f")
45 flops = flops / 1e6
46 params = flops / 1e6
47 return flops, params, flops_str, params_str
48
49
50def profile(model, inputs, verbose=True):

Callers

nothing calls this directly

Calls 2

profileFunction · 0.85
clever_formatFunction · 0.85

Tested by

no test coverage detected