Alibaba-MIIL / ASL

Official Pytorch Implementation of: "Asymmetric Loss For Multi-Label Classification"(ICCV, 2021) paper
MIT License
732 stars 102 forks source link

Hello #86

Closed molla1998 closed 2 years ago

molla1998 commented 2 years ago

Hi

TResNet can be easily converted to onnx. i have converted them in the past. follow the steps listed below, don't reinvent the wheel, or do other stuff

1) update to latest ASL repo 2) edit the class "SpaceToDepthModule" to be:

class SpaceToDepthModule(nn.Module):
    def __init__(self, remove_model_jit=True): # True instead of false. JIT function cannot be converted.
        super().__init__()
        if not remove_model_jit:
            self.op = SpaceToDepthJit()
        else:
            self.op = SpaceToDepth()

    def forward(self, x):
        return self.op(x)

(you can pass the 'remove_model_jit' as an argument for something more modular) 3) After you create the model and load the proper weights, do:

model=InplacABN_to_ABN(model)

This will transfrom inplace bn to equivilent standart bn

If after these steps you encounter problems, let me know

Tal

Originally posted by @mrT23 in https://github.com/Alibaba-MIIL/ASL/issues/73#issuecomment-975339046