Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onnx conversion #32

Open
fisakhan opened this issue Oct 22, 2021 · 2 comments
Open

onnx conversion #32

fisakhan opened this issue Oct 22, 2021 · 2 comments

Comments

@fisakhan
Copy link

I converted the the torch model (magface_epoch_00025.pth) to onnx (magface_epoch_00025.onnx) and used in opencv but the extracted embedding does not match with that of torch version. What am I doing woring?

I converted the pre-trained model to onnx model using the following code:

onnx_model_path = 'magface_epoch_00025.onnx'
# Create some sample input in the shape this model expects 
# This is needed because the conversion forward pass the network once 
dummy_input = torch.randn(1, 3, 112, 112, device='cuda')
torch.onnx.export(model.module, dummy_input, onnx_model_path, verbose=True)

I then try to use it in opencv dnn with the following code:

net =  cv2.dnn.readNetFromONNX(onnx_model_path) 
image = cv2.imread(image_path)
blob = cv2.dnn.blobFromImage(image, 1.0, (112,112),(0, 0, 0), swapRB=True, crop=False)
net.setInput(blob)
featcv = net.forward()
@IrvingMeng
Copy link
Owner

Hi,

I am not familiar with the onnx conversion so unable to solve the issue. Sorry for not helping :(

Best,
Qiang

@tonhathuy
Copy link

I converted this model to onnx and tensorRT , checkout my repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants