vietanhdev / anylabeling

Effortless AI-assisted data labeling with AI support from YOLO, Segment Anything (SAM+SAM2), MobileSAM!!
https://anylabeling.nrl.ai
GNU General Public License v3.0
2.2k stars 236 forks source link

SAM encoder ONNXRuntimeError #71

Closed jonbakerfish closed 1 year ago

jonbakerfish commented 1 year ago

Running the latest version of anylabeling with SAM model will crash:

2023-05-04 14:37:55.442148422 [W:onnxruntime:Default, tensorrt_execution_provider.h:63 log] [2023-05-04 06:37:55 WARNING] nx_tensorrt-src/onnx2trt_utils.cpp:375: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
2023-05-04 14:37:55.442272866 [W:onnxruntime:Default, tensorrt_execution_provider.h:63 log] [2023-05-04 06:37:55 WARNING] nx_tensorrt-src/onnx2trt_utils.cpp:403: One or more weights outside the range of INT32 was clamped
2023-05-04 14:37:55.459027396 [W:onnxruntime:Default, tensorrt_execution_provider.h:63 log] [2023-05-04 06:37:55 WARNING] nx_tensorrt-src/onnx2trt_utils.cpp:403: One or more weights outside the range of INT32 was clamped
2023-05-04 14:37:55.477279852 [E:onnxruntime:Default, tensorrt_execution_provider.h:61 log] [2023-05-04 06:37:55   ERROR] [shuffleNode.cpp::symbolicExecute::392] Error Code 4: Internal Error (/blocks.0/Reshape: IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2])
2023-05-04 14:37:55.478303947 [W:onnxruntime:Default, tensorrt_execution_provider.h:63 log] [2023-05-04 06:37:55 WARNING] nx_tensorrt-src/onnx2trt_utils.cpp:403: One or more weights outside the range of INT32 was clamped
2023-05-04 14:37:55.553881868 [E:onnxruntime:, inference_session.cc:1532 operator()] Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc:897 SubGraphCollection_t onnxruntime::TensorrtExecutionProvider::GetSupportedList(SubGraphCollection_t, int, int, const onnxruntime::GraphViewer&, bool*) const [ONNXRuntimeError] : 1 : FAIL : TensorRT input: /blocks.0/Pad_output_0 has no shape specified. Please run shape inference on the onnx model first. Details can be found in https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#shape-inference-for-tensorrt-subgraphs

Traceback (most recent call last):
  File "./code/SAM/anylabeling/anylabeling/utils.py", line 15, in run
    self.func(*self.args, **self.kwargs)
  File "./code/SAM/anylabeling/anylabeling/services/auto_labeling/model_manager.py", line 151, in _load_model
    model_info["model"] = SegmentAnything(
  File "./code/SAM/anylabeling/anylabeling/services/auto_labeling/segment_anything.py", line 74, in __init__
    self.encoder_session = onnxruntime.InferenceSession(
  File "./miniconda3/envs/anylabeling/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 360, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "./miniconda3/envs/anylabeling/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 408, in _create_inference_session
    sess.initialize_session(providers, provider_options, disabled_optimizers)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc:897 SubGraphCollection_t onnxruntime::TensorrtExecutionProvider::GetSupportedList(SubGraphCollection_t, int, int, const onnxruntime::GraphViewer&, bool*) const [ONNXRuntimeError] : 1 : FAIL : TensorRT input: /blocks.0/Pad_output_0 has no shape specified. Please run shape inference on the onnx model first. Details can be found in https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#shape-inference-for-tensorrt-subgraphs
[1]    335899 IOT instruction (core dumped)  anylabeling
vietanhdev commented 1 year ago

@jonbakerfish Please try the latest version:

vietanhdev commented 1 year ago

Documentation for GPU support: https://anylabeling.com/docs/gpu.