Add test data for layers

pull/265/head
Vitaliy Lyudvichenko 10 years ago
parent e644b5a358
commit f07c5647e3
  1. 17
      modules/dnn/test/test_layers.cpp
  2. BIN
      modules/dnn/testdata/dnn/layers/layer_convolution.caffemodel
  3. BIN
      modules/dnn/testdata/dnn/layers/layer_convolution.npy
  4. BIN
      modules/dnn/testdata/dnn/layers/layer_deconvolution.caffemodel
  5. BIN
      modules/dnn/testdata/dnn/layers/layer_deconvolution.input.npy
  6. BIN
      modules/dnn/testdata/dnn/layers/layer_deconvolution.npy
  7. 6
      modules/dnn/testdata/dnn/layers/layer_deconvolution.prototxt
  8. BIN
      modules/dnn/testdata/dnn/layers/layer_inner_product.caffemodel
  9. BIN
      modules/dnn/testdata/dnn/layers/layer_inner_product.npy
  10. BIN
      modules/dnn/testdata/dnn/layers/layer_lrn_channels.npy
  11. BIN
      modules/dnn/testdata/dnn/layers/layer_lrn_spatial.npy
  12. BIN
      modules/dnn/testdata/dnn/layers/layer_mvn.npy
  13. BIN
      modules/dnn/testdata/dnn/layers/layer_pooling_ave.npy
  14. BIN
      modules/dnn/testdata/dnn/layers/layer_pooling_max.npy
  15. BIN
      modules/dnn/testdata/dnn/layers/layer_softmax.npy
  16. 2
      modules/dnn/testdata/dnn/layers/layer_softmax.prototxt
  17. 13
      modules/dnn/testdata/dnn/layers/run.py

@ -15,21 +15,24 @@ static String _tf(TString filename)
return (getOpenCVExtraDir() + "/dnn/layers/") + filename;
}
static void testLayer(String basename, bool useCaffeModel = false)
static void testLayer(String basename, bool useCaffeModel = false, bool useCommonInputBlob = true)
{
Blob inp = blobFromNPY(_tf("blob.npy"));
Blob ref = blobFromNPY(_tf(basename + ".npy"));
String prototxt = _tf(basename + ".prototxt");
String caffemodel = _tf(basename + ".caffemodel");
String prototxt = basename + ".prototxt";
String caffemodel = basename + ".caffemodel";
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
String outfile = _tf(basename + ".npy");
Net net;
{
Ptr<Importer> importer = createCaffeImporter(_tf(prototxt), (useCaffeModel) ? _tf(caffemodel) : String());
Ptr<Importer> importer = createCaffeImporter(prototxt, (useCaffeModel) ? caffemodel : String());
ASSERT_TRUE(importer != NULL);
importer->populateNet(net);
}
Blob inp = blobFromNPY(inpfile);
Blob ref = blobFromNPY(outfile);
net.setBlob(".input", inp);
net.forward();
Blob out = net.getBlob("output");
@ -85,7 +88,7 @@ TEST(Layer_Test_Pooling_ave, Accuracy)
TEST(Layer_Test_DeConvolution, Accuracy)
{
testLayer("layer_deconvolution", true);
testLayer("layer_deconvolution", true, false);
}
TEST(Layer_Test_MVN, Accuracy)

@ -2,9 +2,9 @@ name: "test_Convolution"
input: "input"
input_dim: 2
input_dim: 6
input_dim: 75
input_dim: 113
input_dim: 12
input_dim: 36
input_dim: 37
layer {
type: "Deconvolution"

Binary file not shown.

@ -2,7 +2,7 @@ name: "test_Softmax"
input: "input"
input_dim: 2
input_dim: 5
input_dim: 6
input_dim: 75
input_dim: 113

@ -7,13 +7,13 @@ sys.path.insert(0, CAFFE_ROOT + 'python')
import numpy as np
import caffe
import cv2
#import cv2
def get_cafe_output(inp_blob, proto_name, caffemodel_name):
caffe.set_mode_cpu()
net = caffe.Net(proto_name, caffe.TEST)
net.blobs['input'].reshape(*inp_blob.shape)
#net.blobs['input'].reshape(*inp_blob.shape)
net.blobs['input'].data[...] = inp_blob
net.forward()
@ -28,16 +28,17 @@ def get_cafe_output(inp_blob, proto_name, caffemodel_name):
if __name__ == '__main__':
proto_filenames = glob.glob("layer_*.prototxt")
inp_blob = np.load('blob.npy')
print inp_blob.shape
for proto_filename in proto_filenames:
proto_filename = os.path.basename(proto_filename)
proto_basename = os.path.splitext(proto_filename)[0]
cfmod_basename = proto_basename + ".caffemodel"
npy_filename = proto_basename + ".npy"
print cfmod_basename
inp_blob_name = proto_basename + ".input.npy"
inp_blob = np.load(inp_blob_name) if os.path.exists(inp_blob_name) else np.load('blob.npy')
print "\nGenerate data for:"
print cfmod_basename, inp_blob.shape
out_blob = get_cafe_output(inp_blob, proto_filename, cfmod_basename)
print out_blob.shape

Loading…
Cancel
Save