0

尝试在训练有素的模型 Faster-RCNN 和 Tensorflow 1.13.1 上运行 RunGraphExample frozen_graph.pb , org.deeplearning4j "1.0.0-beta6" (Tensorflow 1.15)

val data: Array[Array[Int]] = new Array[Array[Int]](img.getWidth * img.getHeight);
    for (i <- 0 until img.getWidth) {
      for (j <- 0 until img.getHeight()) {
        val ar: Array[Int] = new Array(3)
        ar(0) = color.getRed.byteValue() & 0xff
        ar(1) = color.getGreen.byteValue() & 0xff
        ar(2) = color.getBlue.byteValue() & 0xff
        data(i * img.getHeight + j) = ar
      }
    }
var arr: INDArray = Nd4j.createFromArray(data) 
//.castTo( org.nd4j.linalg.api.buffer.DataType.UBYTE)

错误出现在行inputMap.put(inputs.get(0), shapeArray)

如果 shapeArray 是 int 则错误是:

Unable to run session Expects arg[0] to be uint8 but int32 is provided

如果 shapeArray 很短或 .castTo(UBYTE) 则错误为:

Unsupported data type: UBYTE
or
Unsupported data type: SHORT

从大约 1.0.0-beta3 Deeplearning4j 移除了对val 压缩器 = BasicNDArrayCompressor.getInstance.setDefaultCompression("UINT8")的支持

如何使用 uint8 DataType 将图像正确转换为 INDArray?

https://github.com/eclipse/deeplearning4j-examples/blob/master/tf-import-examples/src/main/java/org/nd4j/examples/RunGraphExample.java

4

0 回答 0