Skip to content

Linaom1214/TensorRT-FastSAM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TensorRT-FastSAM

Requirements

pip install -r requirements.txt

Export ONNX model

python export.py --weights < path to FastSAM-x.pt > --output <onnx_model_path>
##--------- example ---------- 
# python export.py --weights ../models/FastSAM-x.pt --output ../models/FastSAM-x2.onnx

Export trt engine

/usr/src/tensorrt/bin/trtexec \ 
--onnx=<onnx_model_path> \
--saveEngine=<engine_path> \
--explicitBatch \ 
--minShapes=images:1x3x1024x1024 \
--optShapes=images:1x3x1024x1024 \
--maxShapes=images:4x3x1024x1024 \ 
--verbose \ 
--device=0
##--------- example ---------- 
# /usr/src/tensorrt/bin/trtexec \
# --onnx="../models/FastSAM-x2.onnx" \
# --saveEngine="../trt_engines/FastSAM-x.engine" \
# --explicitBatch \
# --minShapes=images:1x3x1024x1024 \
# --optShapes=images:1x3x1024x1024 \
# --maxShapes=images:4x3x1024x1024 \
# --verbose \
# --device=0

Do inference

python trt_infer.py <engine_path> <image_path> --output=<output_path>
##--------- example ---------- 
# python trt_infer.py "../trt_engines/FastSAM-x.engine" --output="../unnamed.jpg"

References