Example #1
0
def resNet152Test():
	net = loadResNet(modelpath="../TestData/ResNet-152-model.hdf", layers="152")

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

	res = net(gpuarray.to_gpu(sample)).get().reshape(-1)
	showLabelResults(res, labels, header=net.name)
Example #2
0
def graphTest():
	from PuzzleLib.Models.Nets.ResNet import loadResNet
	net = loadResNet(None, layers="50")

	from PuzzleLib.Passes.ConvertToGraph import toGraph
	graph = toGraph(net, nodesOnly=True)

	drawBoard(graph, filename="./TestData/graph.gv", view=False, modulesOnly=False)
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 netTest():
    from PuzzleLib.Models.Nets.ResNet import loadResNet
    net = loadResNet(None, layers="50", initscheme="xavier")

    data = gpuarray.to_gpu(np.random.randn(1, 3, 224, 224).astype(np.float32))
    outdata = net(data)

    graph = toGraph(net)
    graphdata = graph(data)

    assert np.allclose(outdata.get(), graphdata.get())
def main():
    inshape = (1, 3, 224, 224)

    net = loadResNet(modelpath="../../TestData/ResNet-50-model.hdf",
                     layers="50")
    outshape = net.dataShapeFrom(inshape)

    caffeengine = buildRTEngineFromCaffe(
        ("../TestData/ResNet-50-deploy.prototxt",
         "../TestData/ResNet-50-model.caffemodel"),
        inshape=inshape,
        outshape=outshape,
        outlayers=["prob"],
        dtype=DataType.float32,
        savepath="../TestData")

    onnxengine = buildRTEngineFromOnnx("../TestData/resnet50.onnx",
                                       inshape=inshape,
                                       outshape=outshape,
                                       dtype=DataType.float32,
                                       savepath="../TestData")

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

    netData = net(data).get()
    caffeData = caffeengine(data).get()

    data = np.moveaxis(
        np.array(Image.open("../../TestData/tarantula.jpg"), dtype=np.float32),
        2, 0)
    data = gpuarray.to_gpu(preprocessCaffe2Onnx(data)[np.newaxis, ...])

    onnxData = onnxengine(data).get()

    printResults(netData, labels, "Net")
    printResults(caffeData, labels, "Caffe")
    printResults(onnxData, labels, "Onnx")
Example #6
0
def unittest():
	net = loadResNet(modelpath="../TestData/ResNet-50-model.hdf", layers="50")
	ONNXExporter().export(net, inshape=(1, 3, 224, 224), savepath="../TestData/")