Open AlexanderHustinx opened 2 years ago
Hi,
I encounter the same problem here. A way to do transfer learning from pretrained ONNX models would be to convert them into Torch format. However I could not find a good way to do it. Did someone find any solution to do the ONNX -> Torch model weights conversion for the iresnet50-based models? If this is not possible, it would be nice to consider releasing trained models in .pt format in addition to the .onnx format.
Thanks for your help.
The repo is a bit messy, but the authors have actually uploaded Pytorch models here: https://onedrive.live.com/?authkey=%21AFZjr283nwZHqbA&id=4A83B6B633B029CC%215577&cid=4A83B6B633B029CC
The repo is a bit messy, but the authors have actually uploaded Pytorch models here: https://onedrive.live.com/?authkey=%21AFZjr283nwZHqbA&id=4A83B6B633B029CC%215577&cid=4A83B6B633B029CC
Thanks a lot. I am new to pytorch and haven't figure out how to use the models here. Does the directory contain the full model or just the models weights? By the way, may I ask where do you find this link? Is there any illustrations? @gerald-ftk
@43ig2, I ended up using onnx2torch
from https://github.com/ENOT-AutoDL/onnx2torch
Basically this snippet should do it:
from onnx2torch import convert
base_model = "saved_models/glint360k_r50.onnx" # use your own model and path
self.base = convert(base_model).to(device)
and then just add your own layers on top as required and as you normally would, e.g.:
self.classifier = self.classifier = nn.Sequential(nn.ReLU(True), nn.Dropout(), nn.Linear(512, num_classes))
and in the forward
-function just, as normally:
def forward(self, x):
x = self.base(x)
y = self.classifier(x)
return y
Small caveat, it doesn't seem to work for all models. You might also need to make sure the ArcFace-class is available somewhere.. I'm not 100% whether that was necessary anymore, it's been a while.
@gerald-ftk, I was aware of these models (thanks though). But there are many more models they provide a *.ONNX-file here: https://github.com/deepinsight/insightface/tree/master/model_zoo The snippet I provided above can be used with some success there.
First off, thank you very much for this repo. It has been very insightful and performs nicely.
Now, I have a problem where I'd like to use face recognition as a base for transfer learning a different task. As such I'd like to use the ArcFace weights and finetune them on my own task, updating the representations in the process.
However, I am not sure how to do this using the ONNX model weights you have provided. Could anyone please shed some light on that for me?
Thanks in advance!