PINTO0309 / PINTO_model_zoo

A repository for storing models that have been inter-converted between various frameworks. Supported frameworks are TensorFlow, PyTorch, ONNX, OpenVINO, TFJS, TFTRT, TensorFlowLite (Float32/16/INT8), EdgeTPU, CoreML.
https://qiita.com/PINTO
MIT License
3.49k stars 566 forks source link

RAFT inference time and model size #315

Closed ashank-art closed 1 year ago

ashank-art commented 1 year ago

Issue Type

Performance, Support

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

PyTorch, ONNX

Model name and Weights/Checkpoints URL

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/252_RAFT

Description

Hi @PINTO0309 regarding the RAFT onnx model conversion, i have done the conversion with Pytorch version 1.12.0 and offset version 16, but the model size i am getting is 21.1mb but model uploaded here is 97mb for same resolution 640*480 and iterations. Any suggestion what might be missing, Below attached the code snipped used and environment.

Relevant Log Output


### URL or source code for simple inference testing code
DEVICE = 'cuda'

def demo(args):
    model = torch.nn.DataParallel(RAFT(args))
    model.load_state_dict(torch.load(args.model))

    model = model.module
    model.to(DEVICE)
    model.eval()

    H=480
    W=640
    onnx_file = f"raft_kitti_iter20_{H}x{W}.onnx"
    x1 = torch.randn(1, 3, H, W).to(DEVICE)
    x2 = torch.randn(1, 3, H, W).to(DEVICE)
    torch.onnx.export(
        model,
        args=(x1,x2),
        f=onnx_file,
        opset_version=16,
    )

and the environment used.
numpy==1.21.6
nvidia-cublas-cu11==11.10.3.66
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99
nvidia-cudnn-cu11==8.5.0.96
opencv-python==4.6.0.66
Pillow==9.3.0
scipy==1.7.3
torch==1.12.0
typing_extensions==4.4.0
PINTO0309 commented 1 year ago

Have you read the source code of the paper?

ashank-art commented 1 year ago

Thank you for your support