QGIS polygon shapefile as YOLOv8 image segmentation label files

60 Views Asked by At

I want to train a YOLOv8 image segmentation model using my own data, which consists of UAV images with geospatial coordinates. I have annotated target objects in QGIS. Currently, I'm facing an issue where I have two shapefiles. The first shapefile defines fixed-sized training data patches, represented by connected squares of 15x15 meters each. The second shapefile contains polygons representing the target objects. I want to use Python to read both the TIFF and shapefile files. Initially, I'll read the first shapefile and then, for each 15x15 grid square, determine how many polygons from the second shapefile intersect or are contained within it. Following the YOLO image segmentation approach, I aim to generate label files. Currently, the first shapefile contains 20 grid squares of 15x15 meters, each potentially containing around 60 annotated target objects. If a polygon from the second shapefile lies between two 15x15 squares, I intend to ignore it to prevent errors. Therefore, I'm striving to produce 20 properly labeled text files but have been struggling to do so. I would greatly appreciate any guidance on this matter.

0

There are 0 best solutions below