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

Conversion to tflite #10

Open
Aayush2007 opened this issue Jan 21, 2022 · 0 comments
Open

Conversion to tflite #10

Aayush2007 opened this issue Jan 21, 2022 · 0 comments

Comments

@Aayush2007
Copy link

I'm trying to convert the pytorch model to tflite model. But I'm facing issue in providing the dummy model input to torch.onnx.export() method. Do you know what can be the dummy model input ?

Here is how my code look like:

`import torch.nn as nn
import torch.onnx
import torchvision
import torch
from onmt.model_builder import build_base_model
from onmt.utils.parse import ArgumentParser

checkpoint = torch.load('model_step_1600.pt')

model_opt = ArgumentParser.ckpt_model_opts(checkpoint['opt'])
ArgumentParser.update_model_opts(model_opt)
ArgumentParser.validate_model_opts(model_opt)
vocab = checkpoint['vocab']
fields = vocab

model = build_base_model(model_opt, fields, None, checkpoint)
model.eval()

dummy_input = torch.randn(1, 3, 224, 224, requires_grad=True) # dummy_input = torch.from_numpy(X_test[0].reshape(1, -1)).float().to(device)

torch.onnx.export(model, dummy_input, 'model_simple.onnx')
`

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

1 participant