924973292 / TOP-ReID

【AAAI2024】TOP-ReID: Multi-spectral Object Re-Identification with Token Permutation
MIT License
49 stars 2 forks source link

How to export model to onnx? #2

Closed chenscottus closed 8 months ago

chenscottus commented 8 months ago

Hello,

How to export model to onnx?

Thanks!

-Scott

924973292 commented 8 months ago

I am not familiar with exporting to ONNX, but you can try the following code, which I found in another project: ''' pip install onnx import torch model = ... input_sample = torch.randn(1, 3, 256, 128) # Assuming input shape is (1, 3, 256, 128) onnx_file_path = "model.onnx" torch.onnx.export(model, input_sample, onnx_file_path, export_params=True) ''' ''' import onnxruntime onnx_session = onnxruntime.InferenceSession(onnx_file_path) input_data = ... output = onnx_session.run(None, {"input": input_data}) '''