Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turning off windowed read? #18

Open
fangzp opened this issue Aug 21, 2024 · 0 comments
Open

Turning off windowed read? #18

fangzp opened this issue Aug 21, 2024 · 0 comments

Comments

@fangzp
Copy link

fangzp commented Aug 21, 2024

Thanks for building such a helpful tool for converting georeferenced vector annotations to COCO-compatible json.

I'm trying to generate COCO-formatted labels for agricultural fields in the AI4Boundaries dataset, which includes vector annotations for Sentinel-2 image tiles as well as an aerial orthophoto centered in but smaller (by a factor of 1/4th) than the S2 tiles. Ultimately I would like to have the aerial orthophoto as the reference image to be passed into my DL model with the COCO-formatted labels.

When I tried generating the COCO-formatted labels using the S2 images I noticed that the annotations had been split up into 4 parts, which is not the behavior I expected. I observed that the append_dataset function requires a window_bounds which, I think, needs to be smaller than the size of the image. At least when I try to pass a window_bounds=[(512,512)] into the append_dataset I get an error saying that no WindowSchema objects could be created from the given bounds, because the width_step and height_step which are passed into WindowSchema need to be greater than 0. Is there a way to turn off the windowed read entirely, since I would rather not use it for my conversion of the labels?

Relevant code:

test_img = # <-- path to orthophoto TIFF
test_label = # <-- path to geojson
output_dir = # <-- pathlib to output_dir
output_name = # <-- pathlib filename to give output

description = 'Test AI4B dataset'
contributor = 'fangzp'

dataset = create_dataset(description=description, contributor=contributor)
with open(test_label) as f:
    labels = geojson.load(f)
raster_source = rasterio.open(test_img)

labels = gpd.GeoDataFrame.from_features(labels['features'], crs=labels['crs']['properties']['name'])

dataset = append_dataset(dataset=dataset,
                         images_dir = output_dir, # output directory for all label images
                         labels=labels, # GeoDataFrame containing labels and class info
                         src=raster_source, # open rasterio reader for input raster
                         window_bounds=[(raster_source.width, raster_source.height)], # list of window bounds for each tile
                         id_attribute='category_id', #Column containing category_id values
                         name_attribute='category_name', # Column with category_name values
                         super_attribute=None) # Optional column with supercategory values

Final function is where I'm getting the WindowSchema error. Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant