LSegModel

class grid.model.perception.segmentation.lseg.LSegModel(*args, **kwargs)

Language-driven semantic segmentation model integrated with CLIP features.

Credits:

https://github.com/krrish94/lseg-minimal and https://github.com/isl-org/lang-seg

License:

This code is licensed under the MIT License.

__init__()
Return type:

None

run(image, segclasses)

Run segmentation with feature extraction for similarity matching based on a prompt.

Parameters:
  • image (np.ndarray) -- The input image as a NumPy array.

  • segclasses (str) -- Comma-separated string of segmentation classes.

Returns:

The segmented image as a NumPy array.

Return type:

np.ndarray

Example

>>> lseg_model = LSegModel()
>>> img = np.array(Image.open("data/safelanding.png").convert("RGB"))
>>> seg = lseg_model.run(img, "grass,water")