makinacorpus / geolabel-maker

Data preparation for geospatial artificial intelligence
MIT License
24 stars 7 forks source link

Question on usage #1

Open ashnair1 opened 3 years ago

ashnair1 commented 3 years ago

Hi,

I have a geotiff of size 5000 x 5000 and its corresponding geojson. Would it be possible to use geolabel-maker to create a coco dataset (where image tile size is 256 x 256)? If so how?

TrueCactus commented 3 years ago

Hi, Yes, you can create tiles 256 * 256 and also create the annotation file in coco format You can use the fonction make_all of geolabels-maker in command line interface or by importing the package in Python, that do all the process !

cli

geolabels make_all IMG TILES CATEGORIES

python code

geolabels.make_all(img, tiles, categories)

So you need :

I think you have all that is needed, you just have to create the CATEGORIES file . You can check the Data folder and the Readme for more explanation.

Example of the categories file :

{
    "category_1": {
        "id": 1,
        "file": "path to your category_1 vector file",
        "color": [150, 0, 0]
    },
    "category_2": {
        "id": 2,
        "file": "path to your category_2 vector file",
        "color": [255, 255, 255]
    }
}
ashnair1 commented 3 years ago

This is my directory tree

.
├── categories.json
├── raster
│   └── test.tif
├── tiles
└── vector
    └── test.geojson

This is my categories.json

 {
   "building": {
     "id": 1,
     "file": "./vector/test.geojson",
     "color": [255, 255, 255]
   }
 }

When I run

geolabels make_all raster/ tiles/ categories.json

I run into this error:

MAKE LABELS
Please check your configuration file.
MAKE VIRTUAL RASTERS
1 images are merged in the file raster/images.vrt.
Traceback (most recent call last):
  File "/Users/ashwinnair/anaconda3/envs/geo/bin/geolabels", line 8, in <module>
    sys.exit(main.start())
  File "/Users/ashwinnair/anaconda3/envs/geo/lib/python3.7/site-packages/begin/main.py", line 54, in start
    collector=self._collector)
  File "/Users/ashwinnair/anaconda3/envs/geo/lib/python3.7/site-packages/begin/cmdline.py", line 258, in apply_options
    return_value = call_function(subfunc, signature(subfunc), opts)
  File "/Users/ashwinnair/anaconda3/envs/geo/lib/python3.7/site-packages/begin/cmdline.py", line 236, in call_function
    return func(*pargs, **kwargs)
  File "/Users/ashwinnair/anaconda3/envs/geo/lib/python3.7/site-packages/geolabel_maker/geolabels.py", line 153, in make_all
    images_vrt, labels_vrt = make_rasters(img)
  File "/Users/ashwinnair/anaconda3/envs/geo/lib/python3.7/site-packages/geolabel_maker/geolabels.py", line 71, in make_rasters
    raise ValueError(f'Your directory {dir_img} does not contain labels.')
ValueError: Your directory raster/ does not contain labels.
  1. How can I fix this?
  2. Where do I specify that I want the coco images to be of size 256 x 256?