Home | History | Annotate | only in /external/tensorflow/tensorflow/examples/multibox_detector
Up to higher level directory
NameDateSize
BUILD21-Aug-2018916
data/21-Aug-2018
main.cc21-Aug-201816.7K
README.md21-Aug-20183.3K

README.md

      1 # TensorFlow C++ MultiBox Object Detection Demo
      2 
      3 This example shows how you can load a pre-trained TensorFlow network and use it
      4 to detect objects in images in C++. For an alternate implementation see the
      5 [Android TensorFlow demo](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android)
      6 
      7 ## Description
      8 
      9 This demo uses a model based on [Scalable Object Detection using Deep NeuralNetworks](https://arxiv.org/abs/1312.2249) to detect people in images passed in from
     10 the command line. This is the same model also used in the Android TensorFlow
     11 demo for real-time person detection and tracking in the camera preview.
     12 
     13 ## To build/install/run
     14 
     15 The TensorFlow `GraphDef` that contains the model definition and weights is not
     16 packaged in the repo because of its size. Instead, you must first download the
     17 file to the `data` directory in the source tree:
     18 
     19 ```bash
     20 $ wget https://storage.googleapis.com/download.tensorflow.org/models/mobile_multibox_v1a.zip -O tensorflow/examples/multibox_detector/data/mobile_multibox_v1a.zip
     21 
     22 $ unzip tensorflow/examples/multibox_detector/data/mobile_multibox_v1a.zip -d tensorflow/examples/multibox_detector/data/
     23 ```
     24 
     25 Then, as long as you've managed to build the main TensorFlow framework, you
     26 should have everything you need to run this example installed already.
     27 
     28 Once extracted, see the box priors file in the data directory. This file
     29 contains means and standard deviations for all 784 possible detections,
     30 normalized from 0-1 in left top right bottom order.
     31 
     32 To build it, run this command:
     33 
     34 ```bash
     35 $ bazel build --config opt tensorflow/examples/multibox_detector/...
     36 ```
     37 
     38 That should build a binary executable that you can then run like this:
     39 
     40 ```bash
     41 $ bazel-bin/tensorflow/examples/multibox_detector/detect_objects --image_out=$HOME/x20/surfers_labeled.png
     42 ```
     43 
     44 This uses the default example image that ships with the framework, and should
     45 output something similar to this:
     46 
     47 ```
     48 I0125 18:24:13.804047    8677 main.cc:293] ===== Top 5 Detections ======
     49 I0125 18:24:13.804058    8677 main.cc:307] Detection 0: L:324.542 T:76.5764 R:373.26 B:214.957 (635) score: 0.267425
     50 I0125 18:24:13.804077    8677 main.cc:307] Detection 1: L:332.896 T:76.2751 R:372.116 B:204.614 (523) score: 0.245334
     51 I0125 18:24:13.804087    8677 main.cc:307] Detection 2: L:306.605 T:76.2228 R:371.356 B:217.32 (634) score: 0.216121
     52 I0125 18:24:13.804096    8677 main.cc:307] Detection 3: L:143.918 T:86.0909 R:187.333 B:195.885 (387) score: 0.171368
     53 I0125 18:24:13.804104    8677 main.cc:307] Detection 4: L:144.915 T:86.2675 R:185.243 B:165.246 (219) score: 0.169244
     54 ```
     55 
     56 In this case, we're using a public domain stock image of surfers walking on the
     57 beach, and the top two few detections are of the two on the right. Adding more
     58 detections with --num_detections=N will also include the surfer on the left,
     59 and eventually non-person boxes below a certain threshold.
     60 
     61 You can visually inspect the detections by viewing the resulting png file
     62 '~/surfers_labeled.png'.
     63 
     64 Next, try it out on your own images by supplying the --image= argument, e.g.
     65 
     66 ```bash
     67 $ bazel-bin/tensorflow/examples/multibox_detector/detect_objects --image=my_image.png
     68 ```
     69 
     70 For another implementation of this work, you can check out the [Android
     71 TensorFlow demo](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android).
     72