Пример #1
0
 def test_rgb_class_config_null_class(self):
     raster_source_cfg = RasterioSourceConfig(uris=['/abc/def.tif'])
     rgb_class_config = ClassConfig(names=['a'], colors=['#010101'])
     cfg = SemanticSegmentationLabelSourceConfig(
         raster_source=raster_source_cfg, rgb_class_config=rgb_class_config)
     cfg.update()
     self.assertEqual(len(cfg.rgb_class_config), 2)
     self.assertIn('null', cfg.rgb_class_config.names)
Пример #2
0
def hrefs_to_sceneconfig(
        imagery: str,
        labels: Optional[str],
        name: str,
        class_id_filter_dict: Dict[int, str],
        extent_crop: Optional[CropOffsets] = None) -> SceneConfig:

    transformers = [CastTransformerConfig(to_dtype='float16')]
    image_source = RasterioSourceConfig(
        channel_order=list(range(224)),
        uris=[imagery],
        allow_streaming=True,
        transformers=transformers,
        extent_crop=extent_crop,
    )

    label_vector_source = GeoJSONVectorSourceConfig(
        uri=labels,
        class_id_to_filter=class_id_filter_dict,
        default_class_id=0xff)
    label_raster_source = RasterizedSourceConfig(
        vector_source=label_vector_source,
        rasterizer_config=RasterizerConfig(background_class_id=0,
                                           all_touched=True))
    label_source = SemanticSegmentationLabelSourceConfig(
        raster_source=label_raster_source)

    return SceneConfig(id=name,
                       raster_source=image_source,
                       label_source=label_source)
Пример #3
0
    def make_scene(id, img_path, label_path):
        raster_source = RasterioSourceConfig(channel_order=[0, 1, 2],
                                             uris=[img_path])
        label_source = SemanticSegmentationLabelSourceConfig(
            rgb_class_config=class_config,
            raster_source=RasterioSourceConfig(uris=[label_path]))
        label_store = SemanticSegmentationLabelStoreConfig(
            rgb=True,
            vector_output=[
                PolygonVectorOutputConfig(class_id=0),
                BuildingVectorOutputConfig(class_id=1)
            ])

        return SceneConfig(id=id,
                           raster_source=raster_source,
                           label_source=label_source,
                           label_store=label_store)
Пример #4
0
def make_label_source(
    class_config: ClassConfig, label_uri: Union[UriPath, str]
) -> Tuple[SemanticSegmentationLabelSourceConfig,
           SemanticSegmentationLabelStoreConfig]:
    label_uri = str(label_uri)
    # 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)])

    return label_source, label_store