Example #1
0
def main():
    inshape = (1, 3, 368, 368)

    net = loadNet(inplace=False, modelpath="../TestData/pose_iter_440000.hdf")
    outshape = net.dataShapeFrom(inshape)

    pzlEngine = buildRTEngine(net,
                              inshape=inshape,
                              dtype=DataType.float32,
                              savepath="../TestData")
    caffeEngine = buildRTEngineFromCaffe(
        ("../TestData/pose_deploy_linevec.prototxt",
         "../TestData/pose_iter_440000.caffemodel"),
        inshape=inshape,
        outshape=outshape,
        outlayers=["net_output"],
        dtype=DataType.float32,
        savepath="../TestData")

    data = gpuarray.to_gpu(np.random.randn(*inshape).astype(np.float32))

    pzlData = pzlEngine(data)
    caffeData = caffeEngine(data)

    assert np.allclose(pzlData.get(), caffeData.get(), atol=1e-7)
    benchModels(pzlEngine, caffeEngine, data, lognames=("puzzle", "caffe "))
Example #2
0
def main():
	batchsize, insize = 16, 1000

	inNode = Linear(insize, 1000, name="linear1").node()
	node = Activation(relu, name="relu1").node(inNode)

	node1 = Linear(1000, 800, name="linear2").node(node)
	node1 = Activation(relu, name="relu2").node(node1)

	node2 = Linear(1000, 800, name="linear3").node(node)
	node2 = Activation(relu, name="relu3").node(node2)

	outNode = Add(name="add").node(node1, node2)

	graph = Graph(inputs=inNode, outputs=outNode, name="graph")

	data = gpuarray.to_gpu(np.random.randn(batchsize, insize).astype(np.float32))

	engine = buildRTEngine(graph, (batchsize, insize), savepath="../TestData", dtype=DataType.float32)

	outdata = graph(data)
	enginedata = engine(data)

	assert np.allclose(outdata.get(), enginedata.get(), atol=1e-6)
	benchModels(graph, engine, data)
Example #3
0
def main():
	net = loadResNet(modelpath="../../TestData/ResNet-50-model.hdf", layers="50")

	data = gpuarray.to_gpu(loadResNetSample(net, "../../TestData/tarantula.jpg"))
	labels = loadLabels(synpath="../../TestData/synsets.txt", wordpath="../../TestData/synset_words.txt")

	engine = buildRTEngine(net, inshape=data.shape, savepath="../TestData", dtype=DataType.float32)

	scoreModels(net, engine, data, labels)
	benchModels(net, engine, data)
Example #4
0
def main():
    net = loadUNet(None)
    data = gpuarray.to_gpu(np.random.randn(1, 1, 256, 256).astype(np.float32))

    engine = buildRTEngine(net,
                           inshape=data.shape,
                           savepath="../TestData",
                           dtype=DataType.float32)

    net.evalMode()
    outdata = net(data)

    enginedata = engine(data)

    assert np.allclose(outdata.get(), enginedata.get())
    benchModels(net, engine, data)
Example #5
0
def main():
    inmaps = 161
    net = loadW2L(None, inmaps, nlabels=29)

    data = gpuarray.to_gpu(np.random.randn(1, inmaps, 200).astype(np.float32))
    engine = buildRTEngine(net,
                           inshape=data.shape,
                           savepath="../TestData",
                           dtype=DataType.float32)

    net.evalMode()
    outdata = net(data)

    enginedata = engine(data)

    assert np.allclose(outdata.get(), enginedata.get())
    benchModels(net, engine, data)
Example #6
0
def main():
	mnist = MnistLoader()
	data, labels = mnist.load(path="../TestData/")
	data, labels = data[:], labels[:]
	print("Loaded mnist")

	np.random.seed(1234)

	net = buildNet()
	trainNet(net, data, labels, 15)

	calibrator = DataCalibrator(data[:60000])
	net.evalMode()

	engine = buildRTEngine(
		net, inshape=data[:1].shape, savepath="../TestData", dtype=DataType.int8, calibrator=calibrator
	)

	benchModels(net, engine, gpuarray.to_gpu(data[:1]))

	print("Net    accuracy: %s" % validate(net, data, labels))
	print("Engine accuracy: %s" % validate(engine, data, labels, batchsize=1))
def main():
    inshape = (1, 3, 368, 368)

    net = loadNet("../TestData/pose_iter_116000.hdf")
    net.optimizeForShape(inshape)

    outshape = net.dataShapeFrom(inshape)

    engine = buildRTEngineFromCaffe(
        ("../TestData/pose_deploy.prototxt",
         "../TestData/pose_iter_116000.caffemodel"),
        inshape=inshape,
        outshape=outshape,
        outlayers=["net_output"],
        dtype=DataType.float32,
        savepath="../TestData")

    data = gpuarray.to_gpu(np.random.randn(*inshape).astype(np.float32))

    netData = net(data).get()
    engineData = engine(data).get()

    assert np.allclose(netData, engineData)
    benchModels(net, engine, data)