developmentseed / label-maker

Data Preparation for Satellite Machine Learning
http://devseed.com/label-maker/
MIT License
461 stars 110 forks source link

Can we label already downloaded imagery with the custom labels ? #177

Closed shubham-scisar closed 4 years ago

shubham-scisar commented 4 years ago

I have an imagery (in geotiff) and have a separate geojson to label the image.Kindly guide how can I use these two as inputs for label-maker to create npz file.I do not wish to use OSM data as I already have the data in geotiff and label in geojson.

drewbo commented 4 years ago

Yes, you can specify the geojson parameter and skip the label-maker download step

shubham-scisar commented 4 years ago

I am trying to create labels but unfortunately it is not able to find the path,I have checked the path there is no issue with path.

(base) C:\Users\SHUBHAM>label-maker labels --dest U:\new_pune\pune_1 --config U:\pune_config.json
Traceback (most recent call last):
  File "C:\Users\SHUBHAM\Anaconda3\Scripts\label-maker-script.py", line 9, in <module>
    sys.exit(cli())
  File "C:\Users\SHUBHAM\Anaconda3\lib\site-packages\label_maker\main.py", line 104, in cli
    make_labels(dest_folder=dest_folder, sparse=sparse, **config)
  File "C:\Users\SHUBHAM\Anaconda3\lib\site-packages\label_maker\label.py", line 84, in make_labels
    mbtiles_file_zoomed, filtered_geo])
  File "C:\Users\SHUBHAM\Anaconda3\lib\subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\SHUBHAM\Anaconda3\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:\Users\SHUBHAM\Anaconda3\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

This is my json file :

{
  "country": "india",
  "bounding_box": [1.09725, 6.05520, 1.34582, 6.30915],
  "geojson":"E:\\pune_corp\\labels.geojson",
  "zoom":19,
  "classes": [{ "name": "schools","filter":["has"]}],
  "imagery": "E:\\part1_cog.tif",
  "background_ratio": 1,
  "ml_type": "object-detection"
}
drewbo commented 4 years ago

@shubhamsharma1609 can you try the paths with single slashes (rather than double)?

shubham-scisar commented 4 years ago

Tried but Getting this error :

Traceback (most recent call last):
  File "C:\Users\SHUBHAM\Anaconda3\Scripts\label-maker-script.py", line 9, in <module>
    sys.exit(cli())
  File "C:\Users\SHUBHAM\Anaconda3\lib\site-packages\label_maker\main.py", line 73, in cli
    config = json.load(open(args.get('config')))
  File "C:\Users\SHUBHAM\Anaconda3\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\SHUBHAM\Anaconda3\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "C:\Users\SHUBHAM\Anaconda3\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\SHUBHAM\Anaconda3\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 4 column 16 (char 95)

Invalid escape.

drewbo commented 4 years ago

@shubhamsharma1609 unfortunately I don't have access to a Windows machine to debug this. Can you check anything related to not finding the path (file permissions, file name, spaces, case, etc)?

shubham-scisar commented 4 years ago

I am checking that.Also, I am utilising the geojson file having mutlipolygon but as per the documentation it is mentioned that only polygon should be there. Can you please guide how I can package this as .npz for creation of npz file as per label maker or any other approach ?

drewbo commented 4 years ago

@shubhamsharma1609 you can convert the MultiPolygon into a FeatureCollection of Polygons

shubham-scisar commented 4 years ago

I am running in linux and getting the following error. Even when the geojson(containing feature collection) is supplied at the right path now it is giving bounding box error.Whereas in the documentation it is given as that the bounding box and country will be overridden by the geojson. If we can label every geotiff file with custom labels,this will prove to be very powerful.Please help.

(env) abc@linux:~/Downloads$ label-maker labels --config pune_config.json
Determining labels for each tile
Traceback (most recent call last):
  File "/home/abc/miniconda3/envs/env/bin/label-maker", line 10, in <module>
    sys.exit(cli())
  File "/home/abc/miniconda3/envs/env/lib/python3.8/site-packages/label_maker/main.py", line 104, in cli
    make_labels(dest_folder=dest_folder, sparse=sparse, **config)
  File "/home/abc/miniconda3/envs/env/lib/python3.8/site-packages/label_maker/label.py", line 89, in make_labels
    tilereduce(dict(zoom=zoom, source=mbtiles_to_reduce, bbox=bounding_box,
  File "/home/abc/miniconda3/envs/env/lib/python3.8/site-packages/tilepie/__init__.py", line 21, in tilereduce
    tiles = tm.tileslist(bbox=options.get('bbox'), zoomlevels=[zoom])
  File "/home/abc/miniconda3/envs/env/lib/python3.8/site-packages/tilepie/reader.py", line 68, in tileslist
    return proj.tileslist(bbox)
  File "/home/abc/miniconda3/envs/env/lib/python3.8/site-packages/tilepie/proj.py", line 106, in tileslist
    raise InvalidCoverageError(_("Wrong format of bounding box."))
tilepie.proj.InvalidCoverageError: Wrong format of bounding box.
drewbo commented 4 years ago

which version of label-maker are you using?

shubham-scisar commented 4 years ago

label-maker 0.8.0. Also,my geojson is a feature collection only.

drewbo commented 4 years ago

If you have non-polygon features, you'll need to update to 0.9.0 (just released)

shubham-scisar commented 4 years ago

The geojson consists of multi polygons in the form of feature collection.

shubham-scisar commented 4 years ago

The geojson file which I have is created from the groundwork tool from azavea and I am using the same geojson file to create labelled dataset https://github.com/developmentseed/label-maker/issues/32 and I am unable to generate custom labels for the local file.

drewbo commented 4 years ago

Can you upgrade to 0.9.0 and show me the geojson file + config.json?