(model, input_shape)
| 33 | |
| 34 | |
| 35 | def 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 | |
| 50 | def profile(model, inputs, verbose=True): |
nothing calls this directly
no test coverage detected