Multiple Classes with Semantic Segmentation #2079
-
I'm trying to input multiple classes into my semantic segmentation model, and I'm having trouble passing my class information into my Here's what I'm trying: class_config = ClassConfig(
names=['class1', 'class2', 'class3'],
colors=['lightgreen', 'lightblue', 'darkred'],
)
train_image_uri = "path"
train_label_uri = "path"
val_image_uri = "path"
val_label_uri = "path"
class SemanticSegmentationSlidingWindowGeoDatasetCustom(SemanticSegmentationSlidingWindowGeoDataset):
def __getitem__(self, key):
x, y = super().__getitem__(key)
y = y.long()
return x, y
train_ds = SemanticSegmentationSlidingWindowGeoDatasetCustom.from_uris(
class_config=class_config,
image_uri=train_image_uri,
label_vector_uri=train_label_uri,
label_vector_source_kw=dict(
transformers=[ClassInferenceTransformerConfig(
class_id_to_filter={0: ['==', 'id', 0], 1: ['==', 'id', 1], 3: ['==', 'id', 3]})]), # where 'id' is the name of the field containing my classes in the .geojson
size=400,
stride=400,
transform=A.Resize(400, 400)
) Which yields the error:
After reading the documentation for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yeah, I agree that is confusing. This is because of a discrepancy between the implementations of train_ds = SemanticSegmentationSlidingWindowGeoDatasetCustom.from_uris(
...
label_vector_source_kw=dict(
vector_transformers=[ClassInferenceTransformer(
default_class_id=None,
class_id_to_filter={0: ['==', 'id', 0], 1: ['==', 'id', 1], 3: ['==', 'id', 3]})]),
...
)
|
Beta Was this translation helpful? Give feedback.
Yeah, I agree that is confusing. This is because of a discrepancy between the implementations of
make_od_scene
andmake_ss_scene
. For semantic segmentation, you'll have to do it like this:transformers
-->vector_transformers
ClassInferenceTransformerConfig
-->ClassInferenceTransformer