
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/visualab/example_vlpart_sam_seg_w_prompt.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_visualab_example_vlpart_sam_seg_w_prompt.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_visualab_example_vlpart_sam_seg_w_prompt.py:


Part-level segmentation using SAM and VLPart with prompt
============================================================

This example allows user to provide a text prompt and generate a mask for the corresponding object part.

.. GENERATED FROM PYTHON SOURCE LINES 7-21

.. code-block:: default


    import os

    import cv2

    import rofunc as rf

    # obtain rgb and depth image of the grasping scene
    image_path = os.path.join(rf.oslab.get_rofunc_path(), "../examples/data/visualab/knife2.png")
    image = cv2.imread(image_path)
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

    text_prompt = "knife handle"
    affordance_masks = rf.visualab.vlpart_sam_predict(image, text_prompt)


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.000 seconds)


.. _sphx_glr_download_examples_visualab_example_vlpart_sam_seg_w_prompt.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example




    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: example_vlpart_sam_seg_w_prompt.py <example_vlpart_sam_seg_w_prompt.py>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: example_vlpart_sam_seg_w_prompt.ipynb <example_vlpart_sam_seg_w_prompt.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
