I want to convert SegFormer(include imageprocessor) to ONNX format.
import requests
from PIL import Image
from optimum.onnxruntime import ORTModelForSemanticSegmentation
from optimum.exporters.onnx import onnx_export_from_model
from transformers import AutoFeatureExtractor, AutoModelForSemanticSegmentation, AutoImageProcessor
checkpoint = "nvidia/mit-b0"
image_processor = AutoImageProcessor.from_pretrained(checkpoint)
model = AutoModelForSemanticSegmentation.from_pretrained("checkpoint")
onnx_export_from_model(model=model, output="/content/NEW_ONNX", preprocessors=[image_processor])
What I want is to add preprocessors to the ONNX file. However, when exporting the ONNX model using onnx_export_from_model
, it seems that I got the same config and ONNX file as if I didn’t include the preprocessors parameter.
Am I using the preprocessors parameter correctly in the way I intended?