You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by Matrixmang0 March 14, 2023
Hello world!
My name is Santhosh, and I am an undergrad junior Electrical and Electronics Engineering from India.
I would really rooting to work on OpenVINO projet, this summer. So, I am currently working on my GSOC pre-requisite task on Optimizing YOWOv2 model using OpenVINO. I am actually stuck at Converting the model to ONNX format, dealing with an error. Below is the code snippet, where I am facing the follwing error.
import os
# Define the path to the weights
weights_path = Path('model/yowo_v2_tiny_ava.pth')
# Define the path where the ONNX model will be saved
onnx_path = weights_path.with_suffix('.onnx')
# Define the width and height of the input image and the number of frames in the input video
IMAGE_WIDTH = 208
IMAGE_HEIGHT = 208
NUM_FRAMES = 16
# If an ONNX model with the same name already exists, remove it
if os.path.exists(onnx_path):
os.remove(onnx_path)
# Create a dummy input tensor for the PyTorch model, with random values
dummy_input = torch.randn(1, 3, NUM_FRAMES, IMAGE_HEIGHT, IMAGE_WIDTH)
# Export the PyTorch model to ONNX format using the `torch.onnx.export()` function
torch.onnx.export(
YOWO_model, # The PyTorch model to export
dummy_input, # The dummy input tensor to use for tracing
onnx_path, # The path to save the ONNX model
verbose=False,
opset_version=12,
input_names=['input'],
output_names=['output'],
dynamic_axes={
'input': {0: 'batch_size', 2: 'seq_length'},
'output': {0: 'batch_size', 2: 'seq_length'}
}
)
# Load the exported ONNX model
onnx_model = onnx.load(onnx_path)
# Save the ONNX model
onnx.save(onnx_model, onnx_path)
print(f"ONNX model exported to {onnx_path}.")
Error for the code!
File ~/Openvino-projects/openvino_notebooks/notebooks/YOWOv2-optimization/YOWOv2/models/backbone/backbone_2d/cnn_2d/yolo_free/yolo_free_fpn.py:204, in PaFPNELAN.forward(self, features)
202 c6 = self.cv1(c5)
203 c7 = F.interpolate(c6, scale_factor=2.0)
--> 204 c8 = torch.cat([c7, self.cv2(c4)], dim=1)
205 c9 = self.head_elan_1(c8)
206 ## P4 -> P3
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 12 but got size 13 for tensor number 1 in the list.
This is just the final trace of the error, as the entire error log is real huge
Any help on this would really be appreciated!
The text was updated successfully, but these errors were encountered:
@Matrixmang0 hello, just to make sure, does inference in PyTorch format work for you? I don't see any code on your repo regarding yowov2 and from above I'm not sure if that works. I'd say that if you didn't try that, it'd be great to verify the inference of the original model first, and then possibly check the dimensions with debugger, because it might be something with that.
Discussed in openvinotoolkit/openvino#16294
Originally posted by Matrixmang0 March 14, 2023
Hello world!
My name is Santhosh, and I am an undergrad junior Electrical and Electronics Engineering from India.
I would really rooting to work on OpenVINO projet, this summer. So, I am currently working on my GSOC pre-requisite task on
Optimizing YOWOv2 model using OpenVINO
. I am actually stuck at Converting the model to ONNX format, dealing with an error. Below is the code snippet, where I am facing the follwing error.Error for the code!
This is just the final trace of the error, as the entire error log is real huge
Any help on this would really be appreciated!
The text was updated successfully, but these errors were encountered: