Darkflow: using graph-yolo.pb error android example

Created on 16 Feb 2017  ·  4Comments  ·  Source: thtrieu/darkflow

i have generate two file graph-tiny-yolo-voc.pb and graph-yolo.pb.

the file "graph-tiny-yolo-voc.pb" is ok, but graph-yolo.pb error

I/native: tensorflow_inference_jni.cc:139 Creating TensorFlow graph from GraphDef.
E/native: tensorflow_inference_jni.cc:146 Could not create TensorFlow graph: Invalid argument: No OpKernel was registered to support Op 'ExtractImagePatches' with these attrs. Registered devices: [CPU], Registered kernels:

[[Node: ExtractImagePatches = ExtractImagePatchesT=DT_FLOAT, ksizes=[1, 2, 2, 1], padding="VALID", rates=[1, 1, 1, 1], strides=[1, 2, 2, 1]]]
E/tensorflow: TensorFlowYoloDetector: TF init status: 3

Most helpful comment

No Opkernel means there is no implementation for the hardware running this .pb.
To resolve this, look at class reorg of ./net/ops/convolution.py. It has two methods _forward and forward. The current default option is using forward, which has extract_image_patches - a built-in method of tensorflow.

Swap the names of two methods and you will be using my manual implementation, which should have no problem with Opkernel implementation.

All 4 comments

No Opkernel means there is no implementation for the hardware running this .pb.
To resolve this, look at class reorg of ./net/ops/convolution.py. It has two methods _forward and forward. The current default option is using forward, which has extract_image_patches - a built-in method of tensorflow.

Swap the names of two methods and you will be using my manual implementation, which should have no problem with Opkernel implementation.

i have change the code, but can not generate .pb
/usr/bin/python3 ./flow.py --model /home/qkj/projects/dark_flow/darkflow/cfg/yolo-voc.cfg --load /home/qkj/projects/dark_flow/darkflow/bin/yolo-voc.weights --savepb

Traceback (most recent call last):
File "./flow.py", line 42, in
tfnet = TFNet(FLAGS)
File "/home/qkj/projects/dark_flow/darkflow/net/build.py", line 50, in __init__
self.build_forward()
File "/home/qkj/projects/dark_flow/darkflow/net/build.py", line 70, in build_forward
state = op_create(*args)
File "/home/qkj/projects/dark_flow/darkflow/net/ops/__init__.py", line 27, in op_create
return op_typeslayer_type
File "/home/qkj/projects/dark_flow/darkflow/net/ops/baseop.py", line 42, in __init__
self.forward()
File "/home/qkj/projects/dark_flow/darkflow/net/ops/convolution.py", line 13, in forward
for i in range(h/s):
TypeError: 'float' object cannot be interpreted as an integer

class reorg(BaseOp):
def forward(self):
inp = self.inp.out
shape = inp.get_shape().as_list()
_, h, w, c = shape
s = self.lay.stride
out = list()
for i in range(h/s):
row_i = list()
for j in range(w/s):
si, sj = s * i, s * j
boxij = inp[:, si: si+s, sj: sj+s,:]
flatij = tf.reshape(boxij, [-1,1,1,css])
row_i += [flatij]
out += [tf.concat(2, row_i)]
self.out = tf.concat(1, out)

def _forward(self):
    inp = self.inp.out
    s = self.lay.stride
    self.out = tf.extract_image_patches(
        inp, [1,s,s,1], [1,s,s,1], [1,1,1,1], 'VALID')

Hey, that's a bug when translating from Python2 to Python3. Thanks for pointing it out, I updated the code.

I got same problem and I swapped 2 function's names but the yolo.pb file is still cause error in Android. Please help me fix this!!!

[[Node: ExtractImagePatches = ExtractImagePatches[T=DT_FLOAT, ksizes=[1, 2, 2, 1], padding="VALID", rates=[1, 1, 1, 1], strides=[1, 2, 2, 1]] (47-leaky)]]

Thanks

Was this page helpful?
0 / 5 - 0 ratings