(model)
| 64 | |
| 65 | |
| 66 | def fuse_model(model): |
| 67 | from yolox.models.network_blocks import BaseConv |
| 68 | |
| 69 | for m in model.modules(): |
| 70 | if type(m) is BaseConv and hasattr(m, "bn"): |
| 71 | m.conv = fuse_conv_and_bn(m.conv, m.bn) # update conv |
| 72 | delattr(m, "bn") # remove batchnorm |
| 73 | m.forward = m.fuseforward # update forward |
| 74 | return model |
| 75 | |
| 76 | |
| 77 | def replace_module(module, replaced_module_type, new_module_type, replace_func=None): |