CLIPSeg

class grid.model.perception.segmentation.clipseg.CLIPSeg(*args, **kwargs)

CLIPSeg: Image Segmentation Model

This class implements a wrapper for the CLIPSeg model, which segments images based on a given text prompt.

Credits:

https://github.com/timojl/clipseg

License:

This code is licensed under the MIT License.

__init__()
Return type:

None

segment_image(rgbimage, prompt)

Uses CLIPSeg to predict a segmentation heat map corresponding to the prompt given an RGB image

Parameters:
  • rgbimage (np.ndarray) -- _description_

  • prompt (str) -- _description_

Returns:

_description_

Return type:

np.ndarray

Example

>>> clipseg = CLIPSeg()
>>> img = np.array(Image.open("data/rgb.png").convert("RGB"))
>>> seg = clipseg.segment_image(img, "turbine")