Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
{ "name": "Buildings", "filter": ["has", "building"] }
],
"imagery": "http://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.jpg?access_token=ACCESS_TOKEN",
"background_ratio": 1,
"background_ratio": 0,
"ml_type": "classification"
}
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Retiles the OSM data to the desired zoom level, creates label data (``labels.npz

Accepts one additional flag:

``-s`` or ``--sparse``: boolean
``-s`` or ``--sparse``: boolean
Specifies if features in the class of interest are sparse. If ``True``, only save labels for up to ``n`` background tiles, where ``n`` is equal to ``background_ratio`` times the number of tiles with a class label. Defaults to ``False``.

.. code-block:: bash
Expand Down Expand Up @@ -103,6 +103,8 @@ CLI Step 4: images
^^^^^^^^^^^^^^^^^^

Downloads all imagery tiles needed to create the training data. Requires the ``labels.npz`` file from the ``label-maker labels`` step.
The number of background tiles added depends on the `background_ratio` parameter specified in the `config.json` file.
A background_ratio of 0 will return no background tiles.

.. code-block:: bash

Expand Down
6 changes: 3 additions & 3 deletions label_maker/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ def class_test(value):
return None
class_tiles = [tile for tile in tiles.files if class_test(tiles[tile])]

# for classification problems with a single class, we also get background
# for classification problems, we also get background
# tiles up to len(class_tiles) * config.get('background_ratio')
background_tiles = []
limit = len(class_tiles) * background_ratio
if ml_type == 'classification' and len(classes) == 1:
if ml_type == 'classification':
limit = len(class_tiles) * background_ratio
background_tiles_full = [tile for tile in tiles.files if tile not in class_tiles]
shuffle(background_tiles_full)
background_tiles = background_tiles_full[:limit]
Expand Down