-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vision model's input size spedified with cmd line is overrided by pretrained model config #2035
Comments
If not, how could I export onnx model with 224x224 or other size which is different from the pretrained 960x960? |
This comment was marked as off-topic.
This comment was marked as off-topic.
if I understand correctly, you want the model to not use dynamic axes and statically exported to 224x224 ? |
I guess I see what's happening here, so I think this is not a bug, since the intention was to fix specific edge cases, but yes it would make sense to support the feature you're requesting here. All generators will have to be updated with something from: def __init__(
self,
task: str,
normalized_config: NormalizedVisionConfig,
batch_size: int = DEFAULT_DUMMY_SHAPES["batch_size"],
num_channels: int = DEFAULT_DUMMY_SHAPES["num_channels"],
width: int = DEFAULT_DUMMY_SHAPES["width"],
height: int = DEFAULT_DUMMY_SHAPES["height"],
**kwargs,
):
self.task = task
# Some vision models can take any input sizes, in this case we use the values provided as parameters.
if normalized_config.has_attribute("num_channels"):
self.num_channels = normalized_config.num_channels
else:
self.num_channels = num_channels to def __init__(
self,
task: str,
normalized_config: NormalizedVisionConfig,
**input_shapes,
):
self.task = task
if kwargs.get("num_channels", None) is not None:
self.num_channels = kwargs.pop("num_channels")
elif normalized_config.has_attribute("num_channels"):
self.num_channels = normalized_config.num_channels
else:
self.num_channels = DEFAULT_DUMMY_SHAPES.get("num_channels") where user input shapes take precedence over normalized config. @echarlaix wdyt, since static export is probably something OpenVINO models offer |
@IlyasMoutawwakil Yes, I want to deploy the model on an edge/terminal device like a phone or IoT device. |
I have dived deep into this issue and found that position_embedding need to be interpolated for any other input sizes except the pretrained, and I test the precision is acceptable for deployment. |
@waterdropw I would love to review a PR 🤗 |
the exported onnx model input size is still 960x960, and I found the dummy input generator will use the pretrained model config in
normalized_config
960 instead, but not the cmd line specified 224:optimum/optimum/utils/input_generators.py
Line 762 in f7c3a7f
is it a bug?
The text was updated successfully, but these errors were encountered: