def make_scene(id: str) -> SceneConfig: raster_uri = join(raw_uri, '4_Ortho_RGBIR/top_potsdam_{}_RGBIR.tif'.format(id)) label_uri = join(processed_uri, 'labels', 'all', 'top_potsdam_{}_RGBIR.json'.format(id)) if test: crop_uri = join(processed_uri, 'crops', os.path.basename(raster_uri)) save_image_crop(raster_uri, crop_uri, label_uri=label_uri, size=2000, min_features=5) raster_uri = crop_uri raster_source = RasterioSourceConfig(uris=[raster_uri], channel_order=[0, 1, 2]) vector_source = GeoJSONVectorSourceConfig(uri=label_uri, default_class_id=0, ignore_crs_field=True) label_source = ObjectDetectionLabelSourceConfig( vector_source=vector_source) return SceneConfig(id=id, raster_source=raster_source, label_source=label_source)
def make_crop(processed_uri: UriPath, raster_uri: UriPath, label_uri: UriPath = None) -> Tuple[UriPath, UriPath]: crop_uri = processed_uri / TEST_CROP_DIR / raster_uri.name if label_uri is not None: label_crop_uri = processed_uri / TEST_CROP_DIR / label_uri.name else: label_crop_uri = None save_image_crop(str(raster_uri), str(crop_uri), label_uri=str(label_uri) if label_uri else None, label_crop_uri=str(label_crop_uri) if label_uri else None, size=TEST_CROP_SIZE, vector_labels=False) return crop_uri, label_crop_uri
def make_scene(id): id = id.replace('-', '_') raster_uri = '{}/4_Ortho_RGBIR/top_potsdam_{}_RGBIR.tif'.format( raw_uri, id) label_uri = '{}/5_Labels_for_participants/top_potsdam_{}_label.tif'.format( raw_uri, id) if test: crop_uri = join(processed_uri, 'crops', os.path.basename(raster_uri)) label_crop_uri = join(processed_uri, 'crops', os.path.basename(label_uri)) save_image_crop(raster_uri, crop_uri, label_uri=label_uri, label_crop_uri=label_crop_uri, size=600, vector_labels=False) raster_uri = crop_uri label_uri = label_crop_uri # infrared, red, green channel_order = [3, 0, 1] raster_source = RasterioSourceConfig(uris=[raster_uri], channel_order=channel_order) # Using with_rgb_class_map because label TIFFs have classes encoded as # RGB colors. label_source = SemanticSegmentationLabelSourceConfig( rgb_class_config=class_config, raster_source=RasterioSourceConfig(uris=[label_uri])) # URI will be injected by scene config. # Using rgb=True because we want prediction TIFFs to be in # RGB format. label_store = SemanticSegmentationLabelStoreConfig( rgb=True, vector_output=[PolygonVectorOutputConfig(class_id=0)]) scene = SceneConfig(id=id, raster_source=raster_source, label_source=label_source, label_store=label_store) return scene
def make_scene(scene_info): (raster_uri, label_uri) = scene_info raster_uri = join(raw_uri,"ESPG4326", raster_uri) label_uri = join(processed_uri, label_uri) # aoi_uri = label_uri aoi_uri = join(raw_uri, aoi_path) if test: crop_uri = join(processed_uri,'crops',os.path.basename(raster_uri)) label_crop_uri = join(processed_uri,'crops', os.path.basename(label_uri)) save_image_crop( raster_uri, crop_uri, label_uri=label_uri, label_crop_uri=label_crop_uri, size=600, min_features=20, class_config=class_config) raster_uri = crop_uri label_uri = label_crop_uri id = os.path.splitext((os.path.basename(raster_uri)))[0] raster_source = RasterioSourceConfig( channel_order=[0,1,2], uris=[raster_uri]) label_source = ChipClassificationLabelSourceConfig( vector_source=GeoJSONVectorSourceConfig( uri=label_uri,default_class_id=0, ignore_crs_field=True), # ioa_thresh=0.5, # use_interaction_over_cell=False, pick_min_class_id=False, # background_class_id=0, infer_cells=False # cell_sz=256 ) return SceneConfig( id=id, raster_source=raster_source, label_source=label_source, # aoi_uris=[aoi_uri] )
def make_scene(scene_info): (raster_uri, label_uri) = scene_info raster_uri = join(raw_uri, raster_uri) label_uri = join(processed_uri, label_uri) if test: crop_uri = join(processed_uri, 'crops', os.path.basename(raster_uri)) save_image_crop(raster_uri, crop_uri, size=600, min_features=5) raster_uri = crop_uri id = os.path.splitext(os.path.basename(raster_uri))[0] raster_source = RasterioSourceConfig(uris=[raster_uri], channel_order=[0, 1, 2]) label_source = ObjectDetectionLabelSourceConfig( vector_source=GeoJSONVectorSourceConfig( uri=label_uri, default_class_id=0, ignore_crs_field=True)) return SceneConfig(id=id, raster_source=raster_source, label_source=label_source)