Comments (1)
@sulaimanvesal
The error message suggests that there is a mismatch in the expected dimensions for the BiasGelu
node during the inference run. Specifically, the input tensor for this node is expected to have only one dimension, but it is receiving a tensor with four dimensions. This mismatch often occurs due to differences in tensor shapes between the PyTorch model and the ONNX representation.
Please try with the following approach to fix your issue.
-
Check Tensor Shapes: Ensure that the input tensors provided to the ONNX model have the correct shapes. You can print the shapes of the tensors in your PyTorch model before exporting to ONNX and compare them with the shapes expected by the ONNX model.
-
Simplify the ONNX Model: Use the onnx-simplifier to simplify the ONNX model, which can sometimes resolve issues related to complex node operations. Install the simplifier with pip install onnx-simplifier and run it on your model:
python3 -m onnxsim your_model.onnx your_model_simplified.onnx
-
Update ONNXRuntime: Ensure that you are using the latest version of ONNXRuntime, as bugs and issues are often fixed in newer releases.
-
Check Node Specifications: Verify the specifications of the
BiasGelu
node in your ONNX model. You can inspect the model usingNetron
or by parsing the ONNX model programmatically:
import onnx
model = onnx.load("your_model.onnx")
onnx.checker.check_model(model)
print(onnx.helper.printable_graph(model.graph))
-
Custom Operators: If
BiasGelu
is a custom operator or not standard in ONNX, you might need to handle its conversion explicitly or use a workaround. -
Preprocessing: Ensure that any preprocessing steps applied during inference are consistent with those used during training and ONNX export.
I've attached the conceptional approach to check the tensor shapes before exporting to ONNX:
import torch
import onnx
# Your model definition
model = ... # Load or define your ConvNeXt-V2 model
model.eval()
# Dummy input tensor with the same shape as your actual input
dummy_input = torch.randn(1, 3, 224, 224)
# Print the shape of the output tensor before exporting to ONNX
with torch.no_grad():
output = model(dummy_input)
print(f"Output shape before ONNX export: {output.shape}")
# Export the model to ONNX
torch.onnx.export(
model,
dummy_input,
"model.onnx",
export_params=True,
opset_version=12,
do_constant_folding=True,
input_names=['input'],
output_names=['output'],
dynamic_axes={'input': {0: 'batch_size'}, 'output': {0: 'batch_size'}}
)
# Load and check the ONNX model
onnx_model = onnx.load("model.onnx")
onnx.checker.check_model(onnx_model)
Best luck !
from convnext-v2.
Related Issues (20)
- On masking input images HOT 1
- Make image and patch sizes dynamic HOT 1
- Adapting ConvNetV2 for Time Series: Inconsistencies between Pre-training Visuals and Fine-Tuning Performance HOT 1
- could you share the dense masked conv based sparse encoding ? HOT 2
- ImageNet-1K pre-trained weights ConvNeXt V2 supervised HOT 1
- GRN can be used on any convent with FCMAE οΌanyone tried this ?
- Cannot install MinkowskiEngine with provided instructions HOT 2
- Weights trained using pre-training script produce NaN values when running fine-tuning script HOT 3
- Pre-trained weights incompatible with backbone HOT 2
- deployment issue in trt fp16
- [Question] Cosine Similarity
- Finetuning with limited Labels ?
- ImageNet 22k(21k) Traning loss at the end of training
- Why not provide 22k-supervised finetuning model??? I am really shocked by that every available ConvNeXt-V2 pre-training weights has been finetuned on imagenet-1k. Please make 22k-supervised ConvNeXt-V2 open just like ConvNeXt-V1 !!!!!! πππ HOT 2
- can grn add to resnet
- downsample_layer model order
- Colab Implementation
- GRN in paper uses x_i / sum x_j whereas code uses x_i / mean x_j
- ConvNeXt or ConvNeXt-V2 for drone target view geo-localization problem ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from convnext-v2.