Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using graph-yolo.pb error android example #56

Closed
xunkaixin opened this issue Feb 16, 2017 · 4 comments
Closed

using graph-yolo.pb error android example #56

xunkaixin opened this issue Feb 16, 2017 · 4 comments

Comments

@xunkaixin
Copy link

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

@thtrieu
Copy link
Owner

thtrieu commented Feb 16, 2017

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.

@xunkaixin
Copy link
Author

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')

@thtrieu
Copy link
Owner

thtrieu commented Feb 16, 2017

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

@thtrieu thtrieu closed this as completed Feb 17, 2017
@truongbb
Copy link

truongbb commented Dec 20, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants