|
1 | 1 | # Example Use: A building detector with TensorFlow API
|
2 | 2 |
|
3 |
| -Google TensorFlow Object Detection API is an open source framework built on top of TensorFlow that makes it easy to construct, train, and deploy object detection models. In this example, we use it to detect buildings in Vietnam. If you follow these steps, you'll be able to train a TensorFlow Object Detection model with the following results: |
| 3 | +Google TensorFlow Object Detection API is an open source framework built on top of TensorFlow that makes it easy to construct, train, and deploy object detection models. In this example, we use it to detect buildings in Mexico City. If you follow these steps, you'll be able to train a TensorFlow Object Detection model with the following results: |
4 | 4 |
|
5 | 5 | <p align="center">
|
6 |
| -<img src="images/tf_od_result.jpg" width="1000" /> |
| 6 | +<img src="images/ob_tf_result_fig1.jpg" width="1000" /> |
7 | 7 | </p>
|
8 | 8 |
|
9 | 9 | First install Label Maker (`pip install label-maker`), [tippecanoe](https://github.com/mapbox/tippecanoe) and Pandas (`pip install pandas`).
|
10 | 10 |
|
11 | 11 | ## Create the training dataset
|
12 | 12 |
|
13 |
| -Vietnam has good imagery via the Mapbox Satellite layer, so we are going to use the same configuration file we used for [another walkthrough](walkthrough-classification-mxnet-sagemaker.md), which we used to train a building classifier with MXNet and Amazon SageMaker. |
| 13 | +Mexico City has good imagery via the Mapbox Satellite layer, so we are going to use the same configuration file we used for [another walkthrough](walkthrough-classification-mxnet-sagemaker.md), which we used to train a building classifier with MXNet and Amazon SageMaker. |
14 | 14 |
|
15 | 15 | Create `config.json` as shown in following JSON file.
|
16 | 16 | ```json
|
17 | 17 | {
|
18 |
| - "country": "vietnam", |
19 |
| - "bounding_box": [105.42,20.75,106.41,21.53], |
20 |
| - "zoom": 15, |
| 18 | + "country": "mexico", |
| 19 | + "bounding_box": [-99.17,19.47,-99.12,19.52], |
| 20 | + "zoom": 17, |
21 | 21 | "classes": [
|
22 |
| - { "name": "Buildings", "filter": ["has", "building"] } |
| 22 | + { "name": "Buildings", "filter": ["has", "building"] , "buffer":3} |
23 | 23 | ],
|
24 | 24 | "imagery": "http://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.jpg?access_token=ACCESS_TOKEN",
|
25 | 25 | "background_ratio": 1,
|
@@ -49,7 +49,7 @@ This will download ten images to the folder `data/examples/Buildings/`
|
49 | 49 | <img src="images/preview_tiles.jpg" width="1000" />
|
50 | 50 | </p>
|
51 | 51 |
|
52 |
| -You can tell from the above image tiles that some buildings in Vietnam haven't been mapped yet which will impact our model prediction accuracy. If you’d like to help improve the labeling accuracy, [start mapping on OpenStreetMap](https://www.openstreetmap.org/#map=10/20.9755/105.4118). |
| 52 | +You can tell from the above image tiles that some buildings in Mexico City haven't been mapped yet which will impact our model prediction accuracy. If you’d like to help improve the labeling accuracy, [start mapping on OpenStreetMap](https://www.openstreetmap.org/#map=12/19.3815/-99.1653). |
53 | 53 |
|
54 | 54 | To download all the image tiles that contain buildings:
|
55 | 55 | ```shell
|
@@ -150,8 +150,20 @@ python tf_od_predict.py --model_name=building_od_ssd \
|
150 | 150 | --test_image_path=images/test
|
151 | 151 | ```
|
152 | 152 |
|
153 |
| -This code will read through all your test images in `images/test` folder and output the final prediction into the same folder. You will see a final prediction like this: |
| 153 | +This code will read through all your test images in `images/test` folder and output the final prediction into the same folder. You will see a final prediction like this the first graph shows above. |
| 154 | + |
| 155 | +We also prepared a script to evaluate the model performance using intersection over union (IOU, also known [Jaccard index](https://en.wikipedia.org/wiki/Jaccard_index)). |
154 | 156 |
|
155 | 157 | <p align="center">
|
156 |
| -<img src="images/tf_od_result.jpg" width="1000" /> |
| 158 | +<img src="images/Intersection_over_Union.png" width="1000" /> |
157 | 159 | </p>
|
| 160 | + |
| 161 | +You will obtain a precision score for the model by running: |
| 162 | + |
| 163 | +```shell |
| 164 | +python tf_iou.py --model_name=building_od_ssd \ |
| 165 | + --path_to_label=data/building_od.pbtxt \ |
| 166 | + --test_image_path=images/test |
| 167 | +``` |
| 168 | + |
| 169 | +precision is when the model predicts yes, how often is it correct. When the IOU is higher than 0.5, we consider the model has predicted the buildings correctly. |
0 commit comments