Skip to content

Commit 13acc8f

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 8349b55 + 7e270e2 commit 13acc8f

29 files changed

+61
-0
lines changed
800 Bytes
Binary file not shown.
560 Bytes
Binary file not shown.
560 Bytes
Binary file not shown.
240 Bytes
Binary file not shown.
656 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.
272 Bytes
Binary file not shown.
104 Bytes
Binary file not shown.
416 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.

testdata/dnn/onnx/generate_onnx_models.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,23 @@ def forward(self, x):
263263
model = Unsqueeze()
264264
model.eval()
265265
save_data_and_model("unsqueeze", input, model)
266+
267+
input = Variable(torch.randn(1, 2, 4, 5))
268+
deconv_adjpad2d = nn.ConvTranspose2d(2, 3, (3, 2), stride=(1, 2), padding=(1, 2), output_padding=(0, 1))
269+
save_data_and_model("deconv_adjpad_2d", input, deconv_adjpad2d)
270+
271+
input = Variable(torch.randn(1, 2, 3, 4, 5))
272+
conv3d = nn.Conv3d(2, 3, (2, 3, 2), stride=(1, 1, 1), padding=(0, 0, 0), groups=1, dilation=(1, 1, 1), bias=False)
273+
save_data_and_model("conv3d", input, conv3d)
274+
275+
input = Variable(torch.randn(1, 2, 3, 4, 5))
276+
conv3d = nn.Conv3d(2, 3, (2, 3, 3), stride=(1, 2, 3), padding=(0, 1, 2), groups=1, dilation=(1, 2, 3), bias=True)
277+
save_data_and_model("conv3d_bias", input, conv3d)
278+
279+
input = torch.randn(1, 2, 3, 4, 6)
280+
maxpool3d = nn.MaxPool3d((3, 2, 5), stride=(2, 1, 2), padding=(1, 0, 2))
281+
save_data_and_model("max_pool3d", input, maxpool3d)
282+
283+
input = torch.randn(1, 2, 3, 5, 6)
284+
avepool3d = nn.AvgPool3d((3, 4, 3), stride=(1, 2, 3), padding=(1, 2, 0))
285+
save_data_and_model("ave_pool3d", input, avepool3d)
278 Bytes
Binary file not shown.

testdata/dnn/onnx/models/conv3d.onnx

570 Bytes
Binary file not shown.
757 Bytes
Binary file not shown.
480 Bytes
Binary file not shown.
200 Bytes
Binary file not shown.
880 Bytes
Binary file not shown.
188 Bytes
Binary file not shown.
208 Bytes
Binary file not shown.

testdata/dnn/tensorflow/conv3d_in.npy

1.48 KB
Binary file not shown.

testdata/dnn/tensorflow/conv3d_net.pb

995 Bytes
Binary file not shown.
1.02 KB
Binary file not shown.

testdata/dnn/tensorflow/generate_tf_models.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def writeBlob(data, name):
4444
if data.ndim == 4:
4545
# NHWC->NCHW
4646
np.save(name + '.npy', data.transpose(0, 3, 1, 2).astype(np.float32))
47+
elif data.ndim == 5:
48+
# NDHWC->NCDHW
49+
np.save(name + '.npy', data.transpose(0, 4, 1, 2, 3).astype(np.float32))
4750
else:
4851
# Save raw data.
4952
np.save(name + '.npy', data.astype(np.float32))
@@ -724,6 +727,44 @@ def pad_depth(x, desired_channels):
724727

725728
with tf.gfile.FastGFile('slim_softmax_v2_net.pb', 'wb') as f:
726729
f.write(graph_def.SerializeToString())
730+
################################################################################
731+
inp = tf.placeholder(tf.float32, [1, 4, 6, 5, 3], 'input') # NDHWC format
732+
conv3d = tf.layers.conv3d(inputs=inp, filters=2, kernel_size=[2, 3, 4], use_bias=True, padding='same')
733+
save(inp, conv3d, 'conv3d')
734+
################################################################################
735+
inp = tf.placeholder(tf.float32, [1, 4, 6, 5, 3], 'input') # NDHWC format
736+
maxpool3d = tf.layers.max_pooling3d(inputs=inp, pool_size=(3, 2, 3), strides=(1, 2, 1), padding='same')
737+
save(inp, maxpool3d, 'max_pool3d')
738+
################################################################################
739+
inp = tf.placeholder(tf.float32, [1, 5, 4, 5, 2], 'input') # NDHWC format
740+
avepool3d = tf.layers.average_pooling3d(inputs=inp, pool_size=(3, 3, 2), strides=(2, 1, 1), padding='valid')
741+
save(inp, avepool3d, 'ave_pool3d')
742+
################################################################################
743+
# issue https://github.com/opencv/opencv/issues/13494
744+
inp_node = 'input_image'
745+
out_node = 'SUBPIXEL/SUBPIXEL/subpixel_image/Identity'
746+
with tf.Session(graph=tf.Graph()) as localSession:
747+
localSession.graph.as_default()
748+
749+
with tf.gfile.FastGFile('simple_subpixel.optimized.pb') as f:
750+
graph_def = tf.GraphDef()
751+
graph_def.ParseFromString(f.read())
752+
753+
tf.import_graph_def(graph_def, name='')
754+
755+
inputData = gen_data(tf.placeholder(tf.float32, [1, 1, 1, 4], inp_node))
756+
outputData = localSession.run(localSession.graph.get_tensor_by_name(out_node + ':0'),
757+
feed_dict={inp_node + ':0': inputData})
758+
writeBlob(inputData, 'subpixel_in')
759+
writeBlob(outputData, 'subpixel_out')
760+
761+
for node in graph_def.node:
762+
if node.op == 'Placeholder':
763+
node.attr["data_format"].s = "NHWC"
764+
765+
with tf.gfile.FastGFile('subpixel_net.pb', 'wb') as f:
766+
f.write(graph_def.SerializeToString())
767+
################################################################################
727768

728769
# Uncomment to print the final graph.
729770
# with tf.gfile.FastGFile('fused_batch_norm_net.pb') as f:
1.48 KB
Binary file not shown.
183 Bytes
Binary file not shown.
800 Bytes
Binary file not shown.
96 Bytes
Binary file not shown.
2.18 KB
Binary file not shown.
96 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)