Skip to content

Commit f509aed

Browse files
Merge pull request #1082 from Aser-Abdelfatah:GSoC_Support_GatherElements_ONNX
Merge with opencv/opencv#24092 This pull request serves as an addition to the pull request "GSoC Add ONNX Support for GatherElements #24092", which is submitted to the original OpenCV repository. It contains three tests to the GatherElements operator. The three tests are sourced from: * https://github.com/onnx/onnx/tree/main/onnx/backend/test/data/node/test_gather_elements_0 * https://github.com/onnx/onnx/tree/main/onnx/backend/test/data/node/test_gather_elements_1 * https://github.com/onnx/onnx/tree/main/onnx/backend/test/data/node/test_gather_elements_negative_indices And the models were configured using the code provided by Yuantao Feng at https://github.com/fengyuentau/onnx_utils to confirm output shape in pre-run. --- Reference outputs for `optical_flow_estimation_raft_2023aug.onnx` is generated with the following script: ```python import cv2 as cv import numpy as np img1 = cv.imread("./opencv_extra/testdata/gpu/opticalflow/frame0.png") img2 = cv.imread("./opencv_extra/testdata/gpu/opticalflow/frame1.png") img1_blob = cv.cvtColor(img1, cv.COLOR_BGR2RGB) img1_blob = cv.resize(img1_blob, (480, 360)) # source: (1, 3, 388, 584) # target: 1, 3, 360, 480 img1_blob = cv.dnn.blobFromImage(img1_blob) # source: (1, 3, 388, 584) # target: 1, 3, 360, 480 img2_blob = cv.cvtColor(img2, cv.COLOR_BGR2RGB) img2_blob = cv.resize(img2_blob, (480, 360)) img2_blob = cv.dnn.blobFromImage(img2_blob) print(img1_blob.shape, img2_blob.shape) import onnxruntime as ort net = ort.InferenceSession("optical_flow_estimation_raft_2023aug.onnx", providers=["CPUExecutionProvider"]) output = net.run(["12007", "12006"], {"0": img1_blob, "1": img2_blob}) np.save("output_optical_flow_estimation_raft_2023aug_0.npy", output[0]) np.save("output_optical_flow_estimation_raft_2023aug_1.npy", output[1]) print(output[0].shape) print(output[1].shape) ```
1 parent e6b9fe5 commit f509aed

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

testdata/dnn/download_models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,11 @@ def handle_bad_download(self):
10491049
url='https://github.com/opencv/opencv_zoo/raw/aab69020085e9b6390723b61f9789ec56b96b07e/models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx',
10501050
sha='dc8c70a52c6880f11859bf074bcd294a45860821',
10511051
filename='text_recognition_CRNN_EN_2021sep.onnx'),
1052+
Model(
1053+
name='RAFT', # See https://github.com/opencv/opencv_zoo/tree/main/models/optical_flow_estimation_raft#raft for source
1054+
url='https://github.com/opencv/opencv_zoo/raw/281d232cd99cd920853106d853c440edd35eb442/models/optical_flow_estimation_raft/optical_flow_estimation_raft_2023aug.onnx',
1055+
sha='8165e43c7bd37cc651f66509532acdb3c292832b',
1056+
filename='onnx/models/optical_flow_estimation_raft_2023aug.onnx'),
10521057
]
10531058

10541059
# Note: models will be downloaded to current working directory
Binary file not shown.

0 commit comments

Comments
 (0)