diff --git a/testdata/cv/cameracalibration/circles/circles_24964.png b/testdata/cv/cameracalibration/circles/circles_24964.png new file mode 100644 index 000000000..18b9868a1 Binary files /dev/null and b/testdata/cv/cameracalibration/circles/circles_24964.png differ diff --git a/testdata/cv/cameracalibration/fisheye/stereo_pair_014.png b/testdata/cv/cameracalibration/fisheye/stereo_pair_014.png new file mode 100644 index 000000000..c1e2b5b60 Binary files /dev/null and b/testdata/cv/cameracalibration/fisheye/stereo_pair_014.png differ diff --git a/testdata/cv/mcc/mcc_ccm_test.jpg b/testdata/cv/mcc/mcc_ccm_test.jpg new file mode 100644 index 000000000..2faeb3180 Binary files /dev/null and b/testdata/cv/mcc/mcc_ccm_test.jpg differ diff --git a/testdata/cv/mcc/mcc_ccm_test.yml b/testdata/cv/mcc/mcc_ccm_test.yml new file mode 100644 index 000000000..c87abaf92 --- /dev/null +++ b/testdata/cv/mcc/mcc_ccm_test.yml @@ -0,0 +1,91 @@ +%YAML:1.0 +--- +Macbeth_corners: [ 2.51388901e+02, 9.04293518e+01, 6.18812256e+02, + 9.31525421e+01, 6.40433594e+02, 3.47054962e+02, 2.34627167e+02, + 3.43148376e+02 ] +chartsRGB: !!opencv-matrix + rows: 72 + cols: 5 + dt: d + data: [ 770., 9.7018181818181816e+01, 9.4645301922076519e-01, 95., + 105., 770., 8.0824675324675326e+01, 1.1595628200085211e+00, 77., + 87., 770., 5.3563636363636363e+01, 3.9092600386245806e+00, 42., + 73., 798., 1.6569423558897242e+02, 9.7035861631224973e-01, 163., + 169., 798., 1.3274310776942355e+02, 1.0188309020321478e+00, 130., + 136., 798., 1.1540100250626566e+02, 2.0155035683620337e+00, 110., + 126., 784., 8.2394132653061220e+01, 1.1851617743507668e+00, 78., + 87., 784., 9.5862244897959172e+01, 1.1883374860876685e+00, 92., + 99., 784., 1.2781377551020407e+02, 1.6244352332909029e+00, 122., + 133., 770., 8.0270129870129864e+01, 1.4241940017300359e+00, 75., + 85., 770., 1.0111298701298702e+02, 1.3537682520831342e+00, 96., + 105., 770., 6.5819480519480521e+01, 3.9673845276050486e+00, 52., + 94., 784., 1.1550765306122447e+02, 1.0773373271034734e+00, 113., + 118., 784., 1.0674362244897958e+02, 1.0273480523763854e+00, 104., + 110., 784., 1.4758545918367346e+02, 1.4233270858221301e+00, 143., + 153., 783., 8.9015325670498086e+01, 1.8088105968192547e+00, 84., + 96., 783., 1.5520561941251597e+02, 1.1798084539336262e+00, 152., + 159., 783., 1.6633205619412516e+02, 1.3521967319711203e+00, 162., + 170., 826., 1.7623728813559322e+02, 1.0562230700190447e+00, 171., + 179., 826., 1.3204358353510898e+02, 1.8067773247212249e+00, 118., + 138., 826., 3.6970944309927361e+01, 8.1682743222591547e+00, 9., + 122., 842., 5.3210213776722092e+01, 1.6060278974867714e+00, 47., + 60., 842., 5.7219714964370546e+01, 1.3923581440906183e+00, 54., + 63., 842., 1.2389192399049882e+02, 1.8954768899411336e+00, 119., + 131., 841., 1.6775148632580260e+02, 9.5875752068363906e-01, 164., + 170., 841., 9.6422116527942919e+01, 9.3367991507067238e-01, 92., + 100., 841., 7.7549346016646837e+01, 2.9950816084097802e+00, 67., + 96., 841., 7.2869203329369796e+01, 1.3971315808677551e+00, 69., + 83., 841., 5.8565992865636140e+01, 1.2426178667841234e+00, 55., + 63., 841., 8.1378121284185482e+01, 2.3599304267415597e+00, 75., + 91., 839., 1.3092252681764003e+02, 1.4074398956166911e+00, 125., + 136., 839., 1.7468295589988080e+02, 1.2398172946695771e+00, 169., + 178., 839., 8.6032181168057207e+01, 3.9496429597484721e+00, 72., + 114., 841., 2.0054696789536266e+02, 1.0404396126431092e+00, 196., + 203., 841., 1.7241379310344826e+02, 1.1332190844963712e+00, 167., + 177., 841., 6.2807372175980973e+01, 4.6513131247204011e+00, 43., + 95., 885., 2.9964971751412431e+01, 1.7963912740189363e+00, 24., + 40., 885., 3.4445197740112995e+01, 1.5450274129158603e+00, 29., + 43., 885., 9.7777401129943513e+01, 1.8567780923662216e+00, 92., + 111., 886., 4.8639954853273132e+01, 2.0862187808505608e+00, 41., + 56., 886., 1.1998081264108352e+02, 1.2144139102806220e+00, 115., + 124., 886., 7.5695259593679452e+01, 3.7958216439826575e+00, 61., + 93., 915., 1.4989726775956285e+02, 1.2291287817720791e+00, 146., + 155., 915., 7.6278688524590166e+01, 1.4249664654205476e+00, 69., + 82., 915., 5.0009836065573772e+01, 5.0767778899235987e+00, 33., + 84., 870., 1.9989655172413794e+02, 1.1114294695204852e+00, 196., + 204., 870., 1.9029655172413794e+02, 1.5600949187039233e+00, 180., + 194., 870., 7.5060919540229889e+01, 4.8815593966427304e+00, 56., + 122., 915., 1.5694754098360656e+02, 1.1247255729473995e+00, 154., + 160., 915., 9.1795628415300541e+01, 1.1253572662403217e+00, 88., + 95., 915., 1.2020765027322405e+02, 1.5627307079811592e+00, 115., + 128., 899., 2.7309232480533925e+01, 3.0567552009661569e+00, 18., + 37., 899., 9.4481646273637381e+01, 1.6059009521768621e+00, 89., + 102., 899., 1.4615127919911012e+02, 1.5754745842609790e+00, 141., + 151., 946., 1.8069238900634249e+02, 1.1250958149684871e+00, 178., + 184., 946., 1.8332875264270615e+02, 1.0619091706908901e+00, 181., + 187., 946., 1.8893340380549682e+02, 1.3369067670391985e+00, 185., + 193., 962., 1.5142203742203742e+02, 9.5569896195477178e-01, 148., + 154., 962., 1.5618087318087319e+02, 9.8350642724810333e-01, 153., + 159., 962., 1.6121621621621622e+02, 1.2811714311504592e+00, 157., + 166., 976., 1.2489241803278689e+02, 1.0796667164870304e+00, 121., + 131., 976., 1.3006967213114754e+02, 1.0631988035078002e+00, 125., + 134., 976., 1.3304815573770492e+02, 1.4899721777609278e+00, 126., + 140., 946., 9.7050739957716701e+01, 1.2180654271464280e+00, 93., + 101., 946., 1.0161733615221988e+02, 1.0421739390034210e+00, 98., + 106., 946., 1.0038372093023256e+02, 2.4446752125049676e+00, 91., + 111., 977., 7.0025588536335718e+01, 1.1929339413930722e+00, 66., + 74., 977., 7.4783009211873079e+01, 1.2924463457807394e+00, 69., + 80., 977., 7.0187308085977477e+01, 3.3076200939718361e+00, 57., + 91., 978., 4.6092024539877308e+01, 1.9601651028627682e+00, 39., + 59., 978., 4.9716768916155424e+01, 1.7120244148104067e+00, 45., + 57., 978., 3.6976482617586917e+01, 4.2491980598153010e+00, 22., + 54. ] +ccm: !!opencv-matrix + rows: 3 + cols: 3 + dt: d + data: [ 1.5716570001850085e+00, -2.8092439445926803e-01, + 8.4539221097703107e-02, -2.1945308390378220e-02, + 1.3776087064810523e+00, -1.8039879125793784e-01, + -2.8439953579767585e-02, 3.0335314988002327e-01, + 1.4714738669924146e+00 ] diff --git a/testdata/cv/mcc/mcc_ccm_test_res.png b/testdata/cv/mcc/mcc_ccm_test_res.png new file mode 100644 index 000000000..36e027cff Binary files /dev/null and b/testdata/cv/mcc/mcc_ccm_test_res.png differ diff --git a/testdata/dnn/download_models.py b/testdata/dnn/download_models.py index f6dfecac4..c7013795d 100755 --- a/testdata/dnn/download_models.py +++ b/testdata/dnn/download_models.py @@ -984,9 +984,20 @@ def is_archive(self): filename='onnx/models/yolov6n.onnx'), Model( name='yolov8n', - url='https://dl.opencv.org/models/yolov8/yolov8n.onnx', + url=[ + 'https://huggingface.co/cabelo/yolov8/resolve/main/yolov8n.onnx?download=true', + 'https://dl.opencv.org/models/yolov8/yolov8n.onnx' + ], sha='136807b88d0b02bc226bdeb9741141d857752e10', filename='onnx/models/yolov8n.onnx'), + Model( + name='yolov8x', + url=[ + 'https://huggingface.co/cabelo/yolov8/resolve/main/yolov8x.onnx?download=true', + 'https://dl.opencv.org/models/yolov8/yolov8x.onnx' + ], + sha='462f15d668c046d38e27d3df01fe8142dd004cb4', + filename='onnx/models/yolov8x.onnx'), Model( name='yolo_nas_s', diff --git a/testdata/dnn/onnx/data/input_biased_matmul.npy b/testdata/dnn/onnx/data/input_biased_matmul.npy new file mode 100644 index 000000000..f75f4cbad Binary files /dev/null and b/testdata/dnn/onnx/data/input_biased_matmul.npy differ diff --git a/testdata/dnn/onnx/data/output_biased_matmul.npy b/testdata/dnn/onnx/data/output_biased_matmul.npy new file mode 100644 index 000000000..4f1342eb8 Binary files /dev/null and b/testdata/dnn/onnx/data/output_biased_matmul.npy differ diff --git a/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py b/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py index c908b7cf0..0b125ff95 100644 --- a/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py +++ b/testdata/dnn/onnx/generate_onnx_models_with_onnxscript.py @@ -6,6 +6,13 @@ from onnxscript import opset11 from onnxscript import opset13 +############### +### CAUTION!!! +### Be sure to put constant numpy arrays out of @ost.script() decorated fucntion. +### Otherwise random values change each time eager mode is enter. +### See discussions in https://github.com/microsoft/onnxscript/issues/1313 +############### + np.random.seed(0) def make_model_and_data(model, *args, **kwargs): @@ -339,3 +346,22 @@ def layer_norm_no_fusion(x: ost.FLOAT[n, c, h, w]) -> ost.FLOAT[n, c, h, w]: return add make_model_and_data(layer_norm_no_fusion, np.random.rand(n, c, h, w).astype(np.float32)) + + +''' Subgraph: [Input] -> MatMul -> Add -> [Output] +''' + +b = 2 +m = 32 +n = 64 +k = 16 +weight_data = np.random.rand(k, n).astype(np.float32) +bias_data = np.random.rand(n).astype(np.float32) + +@ost.script() +def biased_matmul(x: ost.FLOAT[b, m, k]) -> ost.FLOAT[b, m, n]: + weight = op.Constant(value=onnx.helper.make_tensor("", onnx.TensorProto.FLOAT, [k, n], weight_data)) + matmul = op.MatMul(x, weight) + bias = op.Constant(value=onnx.helper.make_tensor("", onnx.TensorProto.FLOAT, [n], bias_data)) + return op.Add(bias, matmul) +make_model_and_data(biased_matmul, np.random.rand(b, m, k).astype(np.float32), use_ort=True, ort_input_keys=["x"]) diff --git a/testdata/dnn/onnx/models/biased_matmul.onnx b/testdata/dnn/onnx/models/biased_matmul.onnx new file mode 100644 index 000000000..373127487 Binary files /dev/null and b/testdata/dnn/onnx/models/biased_matmul.onnx differ diff --git a/testdata/dnn/tflite/fully_connected.tflite b/testdata/dnn/tflite/fully_connected.tflite new file mode 100644 index 000000000..d3b4a0144 Binary files /dev/null and b/testdata/dnn/tflite/fully_connected.tflite differ diff --git a/testdata/dnn/tflite/fully_connected_inp.npy b/testdata/dnn/tflite/fully_connected_inp.npy new file mode 100644 index 000000000..23b216047 Binary files /dev/null and b/testdata/dnn/tflite/fully_connected_inp.npy differ diff --git a/testdata/dnn/tflite/fully_connected_out_Identity.npy b/testdata/dnn/tflite/fully_connected_out_Identity.npy new file mode 100644 index 000000000..f5098b3da Binary files /dev/null and b/testdata/dnn/tflite/fully_connected_out_Identity.npy differ diff --git a/testdata/dnn/tflite/generate.py b/testdata/dnn/tflite/generate.py index 9e7f5992f..54d6acddf 100644 --- a/testdata/dnn/tflite/generate.py +++ b/testdata/dnn/tflite/generate.py @@ -52,15 +52,18 @@ def save_tflite_model(model, inp, name): converter = tf.lite.TFLiteConverter.from_concrete_functions([func]) tflite_model = converter.convert() - interpreter = tf.lite.Interpreter(model_content=tflite_model) - with open(f'{name}.tflite', 'wb') as f: f.write(tflite_model) out = model(inp) + out = np.array(out) + + if len(inp.shape) == 4: + inp = inp.transpose(0, 3, 1, 2) + out = out.transpose(0, 3, 1, 2) - np.save(f'{name}_inp.npy', inp.transpose(0, 3, 1, 2)) - np.save(f'{name}_out_Identity.npy', np.array(out).transpose(0, 3, 1, 2)) + np.save(f'{name}_inp.npy', inp) + np.save(f'{name}_out_Identity.npy', out) @tf.function(input_signature=[tf.TensorSpec(shape=[1, 3, 3, 1], dtype=tf.float32)]) @@ -75,3 +78,27 @@ def replicate_by_pack(x): inp = np.random.standard_normal((1, 3, 3, 1)).astype(np.float32) save_tflite_model(replicate_by_pack, inp, 'replicate_by_pack') +@tf.function(input_signature=[tf.TensorSpec(shape=[1, 3], dtype=tf.float32)]) +def split(x): + splitted = tf.split( + x, 3, axis=-1, num=None, name='split' + ) + return tf.concat((splitted[2], splitted[1], splitted[0]), axis=-1) + +inp = np.random.standard_normal((1, 3)).astype(np.float32) +save_tflite_model(split, inp, 'split') + + +fully_connected = tf.keras.models.Sequential([ + tf.keras.layers.Dense(3), + tf.keras.layers.ReLU(), + tf.keras.layers.Softmax(), +]) + +fully_connected = tf.function( + fully_connected.call, + input_signature=[tf.TensorSpec((1,2), tf.float32)], +) + +inp = np.random.standard_normal((1, 2)).astype(np.float32) +save_tflite_model(fully_connected, inp, 'fully_connected') diff --git a/testdata/dnn/tflite/split.tflite b/testdata/dnn/tflite/split.tflite new file mode 100644 index 000000000..1b4bd033d Binary files /dev/null and b/testdata/dnn/tflite/split.tflite differ diff --git a/testdata/dnn/tflite/split_inp.npy b/testdata/dnn/tflite/split_inp.npy new file mode 100644 index 000000000..109d1d980 Binary files /dev/null and b/testdata/dnn/tflite/split_inp.npy differ diff --git a/testdata/dnn/tflite/split_out_Identity.npy b/testdata/dnn/tflite/split_out_Identity.npy new file mode 100644 index 000000000..a1ab63fd3 Binary files /dev/null and b/testdata/dnn/tflite/split_out_Identity.npy differ diff --git a/testdata/highgui/readwrite/test_1_c4.jpg b/testdata/highgui/readwrite/test_1_c4.jpg new file mode 100644 index 000000000..bfe51e42a Binary files /dev/null and b/testdata/highgui/readwrite/test_1_c4.jpg differ