Skip to content

Commit 4a4932c

Browse files
authored
Merge pull request #40 from developmentseed/tf_od_walkthrough
update walkthrough after trained a new model
2 parents 35d064f + 7e834a4 commit 4a4932c

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed
86.7 KB
Loading

examples/images/ob_tf_result_fig1.jpg

253 KB
Loading

examples/images/preview_tiles.jpg

14.9 KB
Loading

examples/images/tf_od_result.jpg

-85.2 KB
Binary file not shown.

examples/images/tf_tiles.jpg

16.2 KB
Loading

examples/walkthrough-tensorflow-object-detection.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Example Use: A building detector with TensorFlow API
22

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:
44

55
<p align="center">
6-
<img src="images/tf_od_result.jpg" width="1000" />
6+
<img src="images/ob_tf_result_fig1.jpg" width="1000" />
77
</p>
88

99
First install Label Maker (`pip install label-maker`), [tippecanoe](https://github.com/mapbox/tippecanoe) and Pandas (`pip install pandas`).
1010

1111
## Create the training dataset
1212

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.
1414

1515
Create `config.json` as shown in following JSON file.
1616
```json
1717
{
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,
2121
"classes": [
22-
{ "name": "Buildings", "filter": ["has", "building"] }
22+
{ "name": "Buildings", "filter": ["has", "building"] , "buffer":3}
2323
],
2424
"imagery": "http://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.jpg?access_token=ACCESS_TOKEN",
2525
"background_ratio": 1,
@@ -49,7 +49,7 @@ This will download ten images to the folder `data/examples/Buildings/`
4949
<img src="images/preview_tiles.jpg" width="1000" />
5050
</p>
5151

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).
5353

5454
To download all the image tiles that contain buildings:
5555
```shell
@@ -150,8 +150,20 @@ python tf_od_predict.py --model_name=building_od_ssd \
150150
--test_image_path=images/test
151151
```
152152

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)).
154156

155157
<p align="center">
156-
<img src="images/tf_od_result.jpg" width="1000" />
158+
<img src="images/Intersection_over_Union.png" width="1000" />
157159
</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

Comments
 (0)