Skip to content

Latest commit

 

History

History

onnx

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

MODNet - ONNX Model

This ONNX version of MODNet is provided by @manthan3C273 from the community.
Please note that the PyTorch version required for this ONNX export function is higher than the official MODNet code (torch==1.7.1 is recommended).

You can try MODNet - Image Matting Demo (ONNX version) in this Colab.
You can also download the ONNX version of the official Image Matting Model from this link.

To export the ONNX version of MODNet (assuming you are currently in project root directory):

  1. Download the pre-trained Image Matting Model from this link and put the model into the folder MODNet/pretrained/.

  2. Install all dependencies by:

    pip install -r onnx/requirements.txt
    
  3. Export the ONNX version of MODNet by:

    python -m onnx.export_onnx \
        --ckpt-path=pretrained/modnet_photographic_portrait_matting.ckpt \
        --output-path=pretrained/modnet_photographic_portrait_matting.onnx
  4. Inference the ONNX model by:

    python -m onnx.inference_onnx \
        --image-path=$FILENAME_OF_INPUT_IMAGE$ \
        --output-path=$FILENAME_OF_OUTPUT_MATTE$ \
        --model-path=pretrained/modnet_photographic_portrait_matting.onnx