Skip to content

Segmentation IOProcessor Plugin#

This plugin targets segmentation tasks and allows for the input image to be split in to 512x512 tiles on an arbitrary number of bands.

During initialization, the plugin accesses the model's data module configuration from the vLLM configuration and instantiates a DataModule object dynamically.

This plugin is installed as terratorch_segmentation.

Plugin configuration#

This plugin allows for additional configuration data to be passed via the TERRATORCH_SEGMENTATION_IO_PROCESSOR_CONFIG environment variable. If set, the variable should contain the plugin configuration in json string format.

The plugin configuration format is defined in the PluginConfig class.

terratorch.vllm.plugins.segmentation.types.PluginConfig #

Bases: BaseModel

Source code in terratorch/vllm/plugins/segmentation/types.py
class PluginConfig(BaseModel):
    output_path: str = None
    """
    Default output folder path to be used when the out_data_format is set to path. 
    If omitted, the plugin will default to the current user home directory.
    """

    @model_validator(mode="after")
    def validate_values(self) -> Self:
        if not self.output_path:
            self.output_path = str(Path.home())
        elif os.path.exists(self.output_path):
            if not os.access(self.output_path, os.W_OK):
                raise ValueError(f"The path: {self.output_path} is not writable")
        else:
            raise ValueError(f"The path: {self.output_path} does not exist")

        return self

output_path = None class-attribute instance-attribute #

Default output folder path to be used when the out_data_format is set to path. If omitted, the plugin will default to the current user home directory.

Request Data Format#

The input format for for the plugin is defined in the RequestData class.

terratorch.vllm.plugins.segmentation.types.RequestData #

Bases: BaseModel

Source code in terratorch/vllm/plugins/segmentation/types.py
class RequestData(BaseModel):

    data_format: Literal["b64_json", "path", "url"]
    """
    Data type for the input image.
    Allowed values are: [`b64_json`, `path`, `url`]
    """

    out_data_format: Literal["b64_json", "path"]
    """
    Data type for the output image.
    Allowed values are: [`b64_json`, `url`]
    """

    data: Any
    """
    Input image data
    """

    indices: Optional[list[int]] = None

data instance-attribute #

Input image data

data_format instance-attribute #

Data type for the input image. Allowed values are: [b64_json, path, url]

out_data_format instance-attribute #

Data type for the output image. Allowed values are: [b64_json, url]

Depending on the values set in data_format, the plugin expects data to contain a string that complies to the format. Similarly, out_data_format controls the data format returned to the user.

Request Output Format#

The output format for the plugin is defined in the RequestOutput class.

terratorch.vllm.plugins.segmentation.types.RequestOutput #

Bases: BaseModel

Source code in terratorch/vllm/plugins/segmentation/types.py
class RequestOutput(BaseModel):

    data_format: Literal["b64_json", "path"]
    """
    Data type for the output image.
    Allowed values are: [`b64_json`, `path`]
    """

    data: Any
    """
    Output image data
    """

    request_id: Optional[str] = None
    """
    The vlLM request ID if applicable
    """

data instance-attribute #

Output image data

data_format instance-attribute #

Data type for the output image. Allowed values are: [b64_json, path]

request_id = None class-attribute instance-attribute #

The vlLM request ID if applicable