microsoft / onnxruntime-extensions

onnxruntime-extensions: A specialized pre- and post- processing library for ONNX Runtime
MIT License
295 stars 80 forks source link

Update Yolov8 tutorial with arguments #658

Closed natke closed 4 months ago

natke commented 4 months ago

Script usage:

python yolov8_pose_e2e.py --help
usage: Add pre and post processing to the YOLOv8 POSE model. The model can be updated to take either
        jpg/png bytes as input (--input image), or RGB data (--input rgb).
        By default the post processing will scale the bounding boxes and key points to the original image.

       [-h] [--onnx_model_path ONNX_MODEL_PATH] [--updated_onnx_model_path UPDATED_ONNX_MODEL_PATH]
       [--input {image,rgb}] [--input_shape INPUT_SHAPE] [--output_image {jpg,png}] [--run_model]
       [--test_image TEST_IMAGE]

options:
  -h, --help            show this help message and exit
  --onnx_model_path ONNX_MODEL_PATH
                        The ONNX YOLOv8 POSE model.
  --updated_onnx_model_path UPDATED_ONNX_MODEL_PATH
                        Filename to save the updated ONNX model to. If not provided default to the filename from
                        --onnx_model_path with '.with_pre_post_processing' before the '.onnx' e.g. yolov8n-pose.onnx
                        -> yolov8n-pose.with_pre_post_processing.onnx
  --input {image,rgb}   Desired model input format. Image bytes from jpg/png or RGB data.
  --input_shape INPUT_SHAPE
                        Shape of RGB input if input is 'rgb'. Provide a comma separated list of 3 dimensions. Symbolic
                        dimensions are allowed. Either the first or last dimension must be 3 to infer if layout is HWC
                        or CHW. examples: channels first with symbolic dims for height and width: --input_shape 3,H,W
                        or channels last with fixed input shape: --input_shape 384,512,3
  --output_image {jpg,png}
                        OPTIONAL. If the input is an image, instead of outputting the scaled bounding boxes and key
                        points the model will draw the bounding boxes on the original image, convert to the specified
                        format, and output the updated image bytes. The scaled key points for each selected bounding
                        box will also be a model output.NOTE: it will NOT draw the key points as there's no custom
                        operator to handle that.
  --run_model           Run inference on the model to validate output.
  --test_image TEST_IMAGE
                        JPG or PNG image to run model with.