models icon indicating copy to clipboard operation
models copied to clipboard

embedded ssd, too many redundant Ops

Open lcycoding opened this issue 8 years ago • 2 comments

System information

  • What is the top-level directory of the model you are using:Object Detection
  • Have I written custom code: Nope
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (use command below): 1.6
  • Bazel version (if compiling from source): 0.10.0
  • CUDA/cuDNN version: 9.0
  • GPU model and memory: K80 w/ 12GB mem
  • Exact command to reproduce:

Describe the problem

I'm currently working on mobile device object detection. And I found out that the published model for AIY vision kit is an embedded SSD model. I tried to reproduce a model like that one, I started diving into the embedded ssd training process. After few days of training, I tested the model's inference speed. Got a not-so-good performance which is around 250ms/image on my android phone. But the AIY model can reach 100ms/image. So I looked into the pb file, knowing that there are huge differences.

According to the results log below, the AIY model has fewer Ops than the train-from-scratch one.

Is there anything I could modify in the config file to reach the AIY model structure? Or is there any tips on transform_graph to reduce the model and inference size?

Also, when I looked into the graphDef, the BatchMultiClassNonMaxSuppression in my own model has 3.7k subgraph, but only 0.3k subgraph in the AIY model. Is that a key point to boost the inference speed?

Thanks for your kindly help.

Source code / logs

For the vision kit model: Found 1 possible inputs: (name=image_tensor, type=uint8(4), shape=[1,256,256,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 107597 (107.60k) const parameters, 0 (0) variable parameters, and 155 control_edges Op types used: 855 Const, 215 Identity, 94 Reshape, 66 Slice, 56 Mul, 50 ConcatV2, 39 ExpandDims, 36 StridedSlice, 33 FusedBatchNorm, 33 Relu6, 33 Fill, 32 Add, 31 Tile, 30 Conv2D, 30 Cast, 28 RealDiv, 28 Sub, 28 Switch, 27 Gather, 26 Range, 23 Enter, 17 Minimum, 16 Pack, 14 Shape, 13 Merge, 13 DepthwiseConv2dNative, 12 Greater, 12 Maximum, 10 BiasAdd, 9 TensorArrayV3, 9 Squeeze, 7 NextIteration, 6 Where, 6 Split, 6 Equal, 6 Unpack, 5 Sqrt, 5 TensorArraySizeV3, 5 Exit, 5 TensorArrayWriteV3, 5 Assert, 5 TensorArrayGatherV3, 4 TensorArrayReadV3, 4 TensorArrayScatterV3, 3 ZerosLike, 3 Transpose, 3 Rank, 3 NonMaxSuppressionV2, 2 All, 2 Less, 2 Exp, 2 LoopCond, 1 TopKV2, 1 Placeholder, 1 LogicalAnd, 1 Sigmoid, 1 Size

For the trained from scratch one: 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=num_detections, op=Identity) (name=detection_classes, op=Identity) Found 673347 (673.35k) const parameters, 0 (0) variable parameters, and 1540 control_edges Op types used: 1765 Const, 549 Gather, 451 Minimum, 360 Maximum, 285 Reshape, 191 Sub, 183 Greater, 183 Cast, 180 Where, 180 Split, 132 Add, 118 StridedSlice, 115 Shape, 109 Mul, 107 Pack, 101 ConcatV2, 94 Unpack, 93 Slice, 92 ZerosLike, 92 Squeeze, 90 NonMaxSuppressionV2, 33 Relu6, 30 Conv2D, 29 Switch, 27 Identity, 26 Enter, 14 Merge, 13 RealDiv, 13 DepthwiseConv2dNative, 12 Range, 11 TensorArrayV3, 10 BiasAdd, 8 NextIteration, 8 ExpandDims, 6 TensorArrayWriteV3, 6 TensorArrayGatherV3, 6 TensorArraySizeV3, 6 Exit, 5 TensorArrayScatterV3, 5 TensorArrayReadV3, 4 Fill, 3 Assert, 3 Transpose, 2 Less, 2 Equal, 2 LoopCond, 2 Exp, 1 Tile, 1 TopKV2, 1 ResizeBilinear, 1 Sigmoid, 1 Size, 1 Placeholder

2018-03-28 12 03 07 Train-from-scratch V.S. Vision kit model

lcycoding avatar Mar 27 '18 06:03 lcycoding

Anyone here can give some advice? : (

lcycoding avatar Mar 30 '18 02:03 lcycoding

It turns out that the NMS is class-related... So if I used coco as my dataset the Gather Op will eat up most of my time in detection... Stupid me.

lcycoding avatar Mar 30 '18 07:03 lcycoding