mapbox / robosat

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

not enough values to unpack (expected 3, got 2) #179

Closed EugenePisotsky closed 4 years ago

EugenePisotsky commented 4 years ago

Hello!

Any ideas what is the reason of this error?

docker run --runtime=nvidia -it --rm -v $PWD:/data --ipc=host mapbox/robosat:latest-gpu features /data/masks/ /data/result.json --dataset /data/dataset.toml --type parking
  0%|                                                                                                        | 0/5196 [00:00<?, ?mask/s]
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/robosat/tools/__main__.py", line 58, in <module>
    args.func(args)
  File "/usr/src/app/robosat/tools/features.py", line 49, in main
    handler.apply(tile, mask)
  File "/usr/src/app/robosat/features/parking.py", line 39, in apply
    multipolygons, hierarchy = contours(grown)
  File "/usr/src/app/robosat/features/core.py", line 107, in contours
    _, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)
EugenePisotsky commented 4 years ago

related to this part of code and changes in library: https://github.com/mapbox/robosat/blob/1d0cf506cde4600ab7063c238f7f9e25d65ba611/robosat/features/core.py#L107

can be fixed by removing _

daniel-j-h commented 4 years ago

Do you happen to know the tile where it fails and could you provide it? It's probably all foreground or all background - or the opencv findContour function signature has changed and we didn't notice.

EugenePisotsky commented 4 years ago

Sorry, can't provide any additional details, I have already removed that environment But looks like findContour was changed: https://stackoverflow.com/questions/54164630/want-to-find-contours-valueerror-not-enough-values-to-unpack-expected-3-go

daniel-j-h commented 4 years ago

Cool, thanks! Want to make a pull request we can merge in? :D