Official PyTorch Resnet50 in Keras

There is a package in Keras which I need to use so I need to shift to Keras half-way through a project.
Right now, I load the trained model like this

import torchvision.models as models

model = models.__dict__[arch](num_classes=365)
model_file = 'resnet50_places365.pth.tar'
checkpoint = torch.load(model_file, map_location=lambda storage, loc: storage)
state_dict = {str.replace(k,'module.',''): v for k,v in checkpoint['state_dict'].items()}
model.load_state_dict(state_dict)
model.eval()

For full code, refer here.
I now need the same model with the same weight in keras. I have no idea how to convert the model! Any help would be great!

I would recommend to post this question on StackOverflow, as you should find more Keras users there. :wink:

I ended up implementing the package in PyTorch :rofl:

1 Like