Error in running executeAsync

716 views
Skip to first unread message

Sina

unread,
Nov 1, 2018, 12:09:29 AM11/1/18
to TensorFlow.js Discussion
Hi there,

I have created a SSD model with object detection api. I used tensorflowjs to convert the model and loaded it in tensorflowjs. I could not find any issue in the converted model. Please find the summarize_graph report below:

Found 1 possible inputs: (name=image_tensor, type=uint8(4), shape=[?,?,?,3]) 

No variables spotted.

Found 4 possible outputs: (name=detection_boxes, op=Identity) (name=detection_scores, op=Identity) (name=detection_classes, op=Identity) (name=num_detections, op=Identity) 

Found 3171502 (3.17M) const parameters, 0 (0) variable parameters, and 32 control_edges

Op types used: 249 Const, 35 Relu6, 35 FusedBatchNorm, 34 Conv2D, 29 StridedSlice, 28 Enter, 25 Shape, 24 Pack, 24 Reshape, 19 GatherV2, 19 Sub, 18 Mul, 14 Range, 13 DepthwiseConv2dNative, 12 BiasAdd, 12 Add, 11 TensorArrayV3, 10 NextIteration, 10 Switch, 10 Merge, 8 Slice, 8 Select, 8 ConcatV2, 7 ExpandDims, 6 TensorArrayWriteV3, 6 TensorArrayGatherV3, 6 Greater, 6 Less, 6 Minimum, 6 Cast, 6 Identity, 6 TensorArraySizeV3, 6 Exit, 5 TensorArrayReadV3, 5 TensorArrayScatterV3, 5 Fill, 5 Unpack, 4 ZerosLike, 4 Squeeze, 4 Maximum, 3 Pad, 3 Transpose, 3 Split, 2 Exp, 2 NonMaxSuppressionV3, 2 LoopCond, 2 TopKV2, 2 LogicalAnd, 1 Sum, 1 Tile, 1 ResizeBilinear, 1 Sigmoid, 1 Placeholder, 1 Where, 1 GreaterEqual

To use with tensorflow/tools/benchmark:benchmark_model try these arguments:

bazel run tensorflow/tools/benchmark:benchmark_model -- --show_flops --input_layer=image_tensor --input_layer_type=uint8 --input_layer_shape=-1,-1,-1,3 --output_layer=detection_boxes,detection_scores,detection_classes,num_detections


When I try to use the model to predict I get 2 errors. Appreciate your help! Please find the error trace and the code below:

Uncaught (in promise) Error: Error in concat1D: rank of tensors[2] must be the same as the rank of the rest (1) Error: Error in concat1D: rank of tensors[2] must be the same as the rank of the rest (1)
and
Uncaught (in promise) Error: Error in concat1D: rank of tensors[2] must be the same as the rank of the rest (1)

const croppedImage = tf.fromPixels(document.getElementById('canvas-'+1));
const batchedImage = croppedImage.expandDims(0);
const normalizedModel = batchedImage.toFloat().div(tf.scalar(255));
const res = await model.executeAsync(normalizedModel);

Uncaught (in promise) Error: Error in concat1D: rank of tensors[2] must be the same as the rank of the rest (1) Error: Error in concat1D: rank of tensors[2] must be the same as the rank of the rest (1)
    at assert (tfjs.js:2)
    at tfjs.js:2
    at Array.forEach (<anonymous>)
    at assertParamsConsistent (tfjs.js:2)
    at concat_ (tfjs.js:2)
    at concat (tfjs.js:2)
    at executeOp$13 (tfjs.js:2)
    at executeOp$15 (tfjs.js:2)
    at s (tfjs.js:2)
    at e.processStack (tfjs.js:2)
assert @ tfjs.js:2
(anonymous) @ tfjs.js:2
assertParamsConsistent @ tfjs.js:2
concat_ @ tfjs.js:2
concat @ tfjs.js:2
executeOp$13 @ tfjs.js:2
executeOp$15 @ tfjs.js:2
s @ tfjs.js:2
e.processStack @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
i @ tfjs.js:2
setTimeout (async)
i @ tfjs.js:2
(anonymous) @ tfjs.js:2
repeatedTry @ tfjs.js:2
e.addItemToPoll @ tfjs.js:2
(anonymous) @ tfjs.js:2
e.pollFence @ tfjs.js:2
e.createAndWaitForFence @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
__awaiter @ tfjs.js:2
e.read @ tfjs.js:2
e.read @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
__awaiter @ tfjs.js:2
e.data @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
(anonymous) @ tfjs.js:2
__awaiter @ tfjs.js:2
nonMaxSuppressionAsync_ @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
__awaiter$2 @ tfjs.js:2
executeOp$5 @ tfjs.js:2
executeOp$15 @ tfjs.js:2
s @ tfjs.js:2
e.processStack @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
i @ tfjs.js:2
Promise.then (async)
u @ tfjs.js:2
(anonymous) @ tfjs.js:2
__awaiter$2 @ tfjs.js:2
e.executeWithControlFlow @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
__awaiter$2 @ tfjs.js:2
e.executeAsync @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
(anonymous) @ tfjs.js:2
__awaiter$2 @ tfjs.js:2
e.executeAsync @ tfjs.js:2
(anonymous) @ VM697:1
(anonymous) @ VM697:1
tfjs.js:2 Uncaught (in promise) Error: Error in concat1D: rank of tensors[2] must be the same as the rank of the rest (1)
    at assert (tfjs.js:2)
    at tfjs.js:2
    at Array.forEach (<anonymous>)
    at assertParamsConsistent (tfjs.js:2)
    at concat_ (tfjs.js:2)
    at concat (tfjs.js:2)
    at executeOp$13 (tfjs.js:2)
    at executeOp$15 (tfjs.js:2)
    at s (tfjs.js:2)
    at e.processStack (tfjs.js:2)

Thanks!
Sina

Sina

unread,
Nov 1, 2018, 12:40:41 AM11/1/18
to TensorFlow.js Discussion
it is happening in "Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/Concatenate/concat_3" node
  1. name"Postprocessor/BatchMultiClassNonMaxSuppression/map/while/MultiClassNonMaxSuppression/Concatenate/concat_3"
  2. op"concat"
  3. params:

Ping Yu

unread,
Nov 1, 2018, 12:34:55 PM11/1/18
to sina....@gmail.com, tf...@tensorflow.org
Hi Sina

couple questions before we dive into the issue, 
1. what version of tfjs you are using?
2. have you tried the coco-ssd model we published? It performs much better than the directly converted version of ssd model.

Ping

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/4c2cb7f6-377a-43d8-9f0e-073186b80318%40tensorflow.org.

Sina Viseh

unread,
Nov 1, 2018, 1:03:08 PM11/1/18
to pi...@google.com, tf...@tensorflow.org
Hi Ping,

Thank you very much for the help. I appreciate it.

I am using tfjs 13.2
{tfjs-core: "0.13.6", tfjs-layers: "0.8.2", tfjs-converter: "0.6.4", tfjs: "0.13.2"}

and the convertor's version is:

tensorflowjs_converter --version

Using TensorFlow backend.


tensorflowjs 0.6.5


Dependency versions:

  keras 2.2.2

  tensorflow 1.11.0


I have trained 3 models with different config using models/research/object_detection/model_main.py and I used these pretrained models:
ssd_mobilenet_v1_coco, ssd_mobilenet_v1_0.75_depth_coco, ssd_mobilenet_v1_fpn_coco from https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md

Screen Shot 2018-11-01 at 9.55.29 AM.png
After that I used models/research/object_detection/export_inference_graph.py to export frozen model and then used tensorflowjs_converter to convert model. 

I am getting that error from model I train off of ssd_mobilenet_v1_0.75_depth_coco. I am waiting for my training to be done for others so I can test those as well. 

Is there anything I should change here?

Thanks,
Sina

Sina Viseh

unread,
Nov 1, 2018, 6:06:09 PM11/1/18
to pi...@google.com, tf...@tensorflow.org
Hi Ping,

That error was happening in the post processing node. Except the post processing the rest of the model works as expected. I did the post processing in CPU and I am not blocked anymore. 

Thanks,
Sina

Ping Yu

unread,
Nov 2, 2018, 12:32:02 PM11/2/18
to sina....@gmail.com, tf...@tensorflow.org
Hi Sina 
Thanks for the update. It is good to know you are unblocked. You can also follow the instruction here,
which cut off the postprocess blocks, and use a single class NonMaxSuppression on cpu for faster speed, you can check the code for details.

Thanks

Ping

Sina Viseh

unread,
Nov 3, 2018, 1:54:53 PM11/3/18
to Ping Yu, tf...@tensorflow.org
Thanks Ping. Appreciate your help!

mmmaks2004 mmmaks2004

unread,
Dec 8, 2018, 11:08:08 AM12/8/18
to TensorFlow.js Discussion, pi...@google.com
Sina, Have you solved this problem?

Sina Viseh

unread,
Dec 9, 2018, 9:04:16 PM12/9/18
to imperi...@gmail.com, tf...@tensorflow.org, Ping Yu
Hi there,

Yes I ended up removing post processing from model and do it myself. This link should give you an idea:


Cheers,
Sina

On Sat, Dec 8, 2018 at 8:08 AM mmmaks2004 mmmaks2004 <imperi...@gmail.com> wrote:
Sina, Have you solved this problem?

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.

mmmaks2004 mmmaks2004

unread,
Dec 10, 2018, 1:52:18 PM12/10/18
to TensorFlow.js Discussion, imperi...@gmail.com, pi...@google.com
Sina, You have taken steps 2 and 3?
(2.Used single class NonMaxSuppression instead of original multiple
classes NonMaxSuppression for faster speed with similar accuracy.
3. Executes NonMaxSuppression operations on CPU backend instead of
WebGL to avoid delays on the texture downloads.)

mmmaks2004 mmmaks2004

unread,
Dec 19, 2018, 3:19:10 AM12/19/18
to TensorFlow.js Discussion, imperi...@gmail.com
Sina,
Can you please share the js code you used to predict for steps 2 and 3?

Sina Viseh

unread,
Dec 19, 2018, 1:04:33 PM12/19/18
to mmmaks2004 mmmaks2004, TensorFlow.js Discussion
Hi there,

The code is in the github project I shared with you. All you need is in the index.ts

Cheers,
Sina

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
Reply all
Reply to author
Forward
0 new messages