Can't export sam onnx model without "orig_im_size" input
Hi mingj2021,
I had a problem when using the export_sam_model function in demo.py script: If the "orig_im_size" input in dummy_inputs is commented (as default), I cannot export the onnx model. Got the following error: TypeError: forward() missing 1 required positional argument: 'orig_im_size'
If I add the "orig_im_size" input, export can be success but cannot further transfer to .engine model.
Any hints to solve this issue?
I had tried both sam_vit_b_01ec64.pth and sam_vit_l_0b3195.pth With TensorRT-8.5.3.1
change "forward" function in the file which is "segment_anything/utils/onnx.py" , comment the params "orig_im_size"
Thanks, the export to onnx without 'orig_im_size' works.
But still got the following complain when transferring to .engine:
[06/08/2023-10:31:47] [TRT] [E] [graphShapeAnalyzer.cpp::analyzeShapes::1300] Error Code 4: Miscellaneous (IShuffleLayer /Reshape_9: reshape changes volume. Reshaping [4] to [1].) [06/08/2023-10:31:47] [TRT] [E] ModelImporter.cpp:748: While parsing node number 1237 [Reshape -> "/Reshape_9_output_0"]: [06/08/2023-10:31:47] [TRT] [E] ModelImporter.cpp:749: --- Begin node --- [06/08/2023-10:31:47] [TRT] [E] ModelImporter.cpp:750: input: "/Reshape_8_output_0" input: "/Concat_13_output_0" output: "/Reshape_9_output_0" name: "/Reshape_9" op_type: "Reshape"
[06/08/2023-10:31:47] [TRT] [E] ModelImporter.cpp:751: --- End node --- [06/08/2023-10:31:47] [TRT] [E] ModelImporter.cpp:754: ERROR: ModelImporter.cpp:179 In function parseGraph: [6] Invalid Node - /Reshape_9 [graphShapeAnalyzer.cpp::analyzeShapes::1300] Error Code 4: Miscellaneous (IShuffleLayer /Reshape_9: reshape changes volume. Reshaping [4] to [1].)
https://github.com/mingj2021/segment-anything-tensorrt/issues/7#issue-1747148108 transfer sam_vit_l_0b3195.pth to .engine model , test on windows,now