mapbox / robosat

Semantic segmentation on aerial and satellite imagery. Extracts features such as: buildings, parking lots, roads, water, clouds
MIT License
2.02k stars 382 forks source link

Allow building type for ./rs features #130

Closed wboykinm closed 5 years ago

wboykinm commented 5 years ago

Currently the only supported option is parking, which is incompatible with inputs trained on buildings.

root@3d58a7d0d5c3:/app# ./rs features --type building --dataset config/dataset-building-middlebury.toml vt/rutland/masks/ vt/rutland/features/buildings-out.geojson
usage: ./rs features [-h] --type {parking} --dataset DATASET masks out
./rs features: error: argument --type: invalid choice: 'building' (choose from 'parking')

root@3d58a7d0d5c3:/app# ./rs features --dataset config/dataset-building-middlebury.toml vt/rutland/masks/ vt/rutland/features/buildings-out.geojson
usage: ./rs features [-h] --type {parking} --dataset DATASET masks out
./rs features: error: the following arguments are required: --type
root@3d58a7d0d5c3:/app# ./rs features --type parking --dataset config/dataset-building-middlebury.toml vt/rutland/masks/ vt/rutland/features/buildings-out.geojson
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/app/robosat/tools/__main__.py", line 60, in <module>
    args.func(args)
  File "/app/robosat/tools/features.py", line 38, in main
    assert set(labels).issuperset(set(handlers.keys())), "handlers have a class label"
AssertionError: handlers have a class label

Am I correct that this will require another well-thought-out postprocessing handler?

daniel-j-h commented 5 years ago

The parking handler right now really works for any polygons. What we need to do is

A generic polygon post-processing handler works as long as we don't want to do e.g. special case post-processing for buildings. Also for the zoom level generalization check https://github.com/mapbox/robosat/issues/51 and https://github.com/mapbox/robosat/pull/88.

What you can do for now is

Or better give https://github.com/mapbox/robosat/pull/88 a try and see if it works for you.

wboykinm commented 5 years ago

@daniel-j-h I ran it as faux-parking per your suggestion above (I did not run the linked branch), and it threw this:

root@3d58a7d0d5c3:/app# ./rs features --type parking --dataset config/dataset-parking-middlebury.toml vt/rutland/masks/ vt/rutland/features/buildings-out.geojson
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/app/robosat/tools/__main__.py", line 60, in <module>
    args.func(args)
  File "/app/robosat/tools/features.py", line 41, in main
    handler = handlers[args.type]()
  File "/app/robosat/features/parking.py", line 26, in __init__
    denoised = denoise(mask, self.kernel_size_denoise)
NameError: name 'mask' is not defined

Indeed, I don't see that param being handed in.

daniel-j-h commented 5 years ago

The mask is passed in here

https://github.com/mapbox/robosat/blob/b7f6ebf79ddac7fc4c04a4f3698b1deae16cd7d1/robosat/features/parking.py#L19

from the callsite here

https://github.com/mapbox/robosat/blob/b7f6ebf79ddac7fc4c04a4f3698b1deae16cd7d1/robosat/tools/features.py#L49

Are you sure you didn't accidentally delete it or change something when removing the tile check?

wboykinm commented 5 years ago

I may well have. Also using a several-days-old, cpu-specific image at this point. Lemme update and try again.

wboykinm commented 5 years ago

@daniel-j-h Pulling the updates did the trick! Thanks!

I'd definitely love to see the generic polygon handler though; I'll be trying any number of feature types that are neither parking nor buildings.

wucangeo commented 5 years ago

Wish we can set type ,instead of updating code. Could you update features command please?

daniel-j-h commented 5 years ago

@wucangeo see the branch in

https://github.com/mapbox/robosat/pull/88

then it should be easy to re-use the existing handler.

Grifel79 commented 4 years ago

@daniel-j-h How rs features should work with roads detection? I am blocked on the pipeline here. Could you advice please?

daniel-j-h commented 4 years ago

You'd have to implement the featurization for roads first. I'm no longer with Mapbox or actively developing or maintaining this project; please talk to Mapbox folks if you have questions.

On May 13, 2020 1:46:44 PM UTC, Grifel79 notifications@github.com wrote:

@daniel-j-h How rs features should work with roads detection? I am blocked on the pipeline here. Could you advice please?