Skip to content

(5.x) Merge 4.x #972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added testdata/cv/aruco/regression_2492.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/aruco/regression_3192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed testdata/cv/aruco/trivial_board_detection.png
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_lstm_cell_forward.npy
Binary file not shown.
Binary file not shown.
Binary file modified testdata/dnn/onnx/data/input_slice_neg_starts.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_lstm_cell_forward.npy
Binary file not shown.
Binary file not shown.
Binary file modified testdata/dnn/onnx/data/output_slice_neg_starts.npy
Binary file not shown.
82 changes: 74 additions & 8 deletions testdata/dnn/onnx/generate_onnx_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,49 @@ def forward(self, x):
save_data_and_model("slice", input, model)
save_data_and_model("slice_opset_11", input, model, version=11)

class SliceStarts(nn.Module):
def __init__(self, *args, **kwargs):
super(SliceStarts, self).__init__()
def generate_slice_neg_starts():
x = np.random.randn(2, 3, 4, 3).astype(np.float32)
y = x[-1:2, -3:-1, 2:3, 1:-1]

def forward(self, x):
return x[-1:]
starts = np.array([-1, -3, 2, 1], dtype=np.int64)
starts = onnx.numpy_helper.from_array(starts, name='starts')
ends = np.array([ 2, -1, 3, -1], dtype=np.int64)
ends = onnx.numpy_helper.from_array(ends, name='ends')

model = SliceStarts()
input_ = Variable(torch.randn(1, 10, dtype=torch.float32))
save_data_and_model("slice_neg_starts", input_, model)
node = onnx.helper.make_node(
'Slice',
inputs=['X', 'starts', 'ends'],
outputs=['Y'],
)

X = onnx.helper.make_tensor_value_info('X', onnx.TensorProto.FLOAT, list(x.shape))
Y = onnx.helper.make_tensor_value_info('Y', onnx.TensorProto.FLOAT, list(y.shape))

graph = onnx.helper.make_graph(
[node], # nodes
'slice_neg_starts', # name
[X], # inputs
[Y], # outputs
)

graph.initializer.append(starts)
graph.initializer.append(ends)

model = onnx.helper.make_model(graph, producer_name='onnx')
onnx.checker.check_model(model)

name = 'slice_neg_starts'

input_files = os.path.join("data", "input_" + name)
np.save(input_files, x.data)

output_files = os.path.join("data", "output_" + name)
np.save(output_files, np.ascontiguousarray(y.data))

models_files = os.path.join("models", name + ".onnx")
onnx.save(model, models_files)

generate_slice_neg_starts()

input_2 = Variable(torch.randn(6, 6))
custom_slice_list = [
Expand Down Expand Up @@ -898,6 +931,39 @@ def forward(self, t):
save_data_and_model("gru_bi", input, hidden_lstm, version=11, export_params=True)


batch = 5
features = 4
hidden = 3
seq_len = 2
num_layers=1
bidirectional=True

class LSTM(nn.Module):

def __init__(self):
super(LSTM, self).__init__()
self.lstm = nn.LSTM(features, hidden, num_layers, bidirectional=bidirectional)
self.h0 = torch.from_numpy(np.ones((num_layers + int(bidirectional), batch, hidden), dtype=np.float32))
self.c0 = torch.from_numpy(np.ones((num_layers + int(bidirectional), batch, hidden), dtype=np.float32))

def forward(self, x):
a, (b, c) = self.lstm(x, (self.h0, self.c0))
if bidirectional:
return torch.cat((a, b, c), dim=2)
else:
return torch.cat((a, b, c), dim=0)


input_ = Variable(torch.randn(seq_len, batch, features))
lstm = LSTM()
save_data_and_model("lstm_cell_bidirectional", input_, lstm, export_params=True)

bidirectional = False
input_ = Variable(torch.randn(seq_len, batch, features))
lstm = LSTM()
save_data_and_model("lstm_cell_forward", input_, lstm, export_params=True)


class MatMul(nn.Module):
def __init__(self):
super(MatMul, self).__init__()
Expand Down
Binary file not shown.
Binary file added testdata/dnn/onnx/models/lstm_cell_forward.onnx
Binary file not shown.
Binary file not shown.
Binary file modified testdata/dnn/onnx/models/slice_neg_starts.onnx
Binary file not shown.
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_10uc1.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_10uc3.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_10uc4.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_12uc1.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_12uc3.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_12uc4.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_14uc1.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_14uc3.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_14uc4.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_16uc1.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_16uc3.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_16uc4.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_8uc1.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_8uc3.tif
Binary file not shown.
Binary file added testdata/highgui/readwrite/pattern_8uc4.tif
Binary file not shown.