ads.data_labeling.visualizer package

Submodules

ads.data_labeling.visualizer.image_visualizer module

The module that helps to visualize Image Dataset.

ads.data_labeling.visualizer.image_visualizer.render(items: List[LabeledImageItem], options: Dict = None)[source]

Renders Labeled Image dataset.

Examples

>>> bbox1 = BoundingBoxItem(bottom_left=(0.3, 0.4),
>>>                        top_left=(0.3, 0.09),
>>>                        top_right=(0.86, 0.09),
>>>                        bottom_right=(0.86, 0.4),
>>>                        labels=['dolphin', 'fish'])
>>> record1 = LabeledImageItem(img_obj1, [bbox1])
>>> bbox2 = BoundingBoxItem(bottom_left=(0.2, 0.4),
>>>                        top_left=(0.2, 0.2),
>>>                        top_right=(0.8, 0.2),
>>>                        bottom_right=(0.8, 0.4),
>>>                        labels=['dolphin'])
>>> bbox3 = BoundingBoxItem(bottom_left=(0.5, 1.0),
>>>                        top_left=(0.5, 0.8),
>>>                        top_right=(0.8, 0.8),
>>>                        bottom_right=(0.8, 1.0),
>>>                        labels=['shark'])
>>> record2 = LabeledImageItem(img_obj2, [bbox2, bbox3])
>>> render(items = [record1, record2], options={"default_color":"blue", "colors": {"dolphin":"blue", "whale":"red"}})
class ads.data_labeling.visualizer.image_visualizer.ImageLabeledDataFormatter[source]

Bases: object

The ImageRender class to render Image items in a notebook session.

static render_item(item: LabeledImageItem, options: Dict | None = None, path: str | None = None) None[source]

Renders image dataset.

Parameters:
  • item (LabeledImageItem) – Item to render.

  • options (Optional[dict]) – Render options.

  • path (str) – Path to save the image with annotations to local directory.

Returns:

Nothing.

Return type:

None

Raises:
  • ValueError – If items not provided. If path is not valid.

  • TypeError – If items provided in a wrong format.

class ads.data_labeling.visualizer.image_visualizer.LabeledImageItem(img: ImageFile, boxes: List[BoundingBoxItem])[source]

Bases: object

Data class representing Image Item.

img

the labeled image object.

Type:

ImageFile

boxes

a list of BoundingBoxItem

Type:

List[BoundingBoxItem]

boxes: List[BoundingBoxItem]
img: ImageFile
class ads.data_labeling.visualizer.image_visualizer.RenderOptions(default_color: str, colors: dict | None)[source]

Bases: object

Data class representing render options.

default_color

The specified default color.

Type:

str

colors

The multiple specified colors.

Type:

Optional[dict]

colors: dict | None
default_color: str
classmethod from_dict(options: dict) RenderOptions[source]

Constructs an instance of RenderOptions from a dictionary.

Parameters:

options (dict) – Render options in dictionary format.

Returns:

The instance of RenderOptions.

Return type:

RenderOptions

to_dict()[source]

Converts RenderOptions instance to dictionary format.

Returns:

The render options in dictionary format.

Return type:

dict

exception ads.data_labeling.visualizer.image_visualizer.WrongEntityFormat[source]

Bases: ValueError

ads.data_labeling.visualizer.image_visualizer.render(items: List[LabeledImageItem], options: Dict | None = None, path: str | None = None) None[source]

Render image dataset.

Parameters:
  • items (List[LabeledImageItem]) – The list of LabeledImageItem to render.

  • options (dict, optional) – The options for rendering.

  • path (str) – Path to save the images with annotations to local directory.

Returns:

Nothing.

Return type:

None

Raises:
  • ValueError – If items not provided. If path is not valid.

  • TypeError – If items provided in a wrong format.

Examples

>>> bbox1 = BoundingBoxItem(bottom_left=(0.3, 0.4),
>>>                        top_left=(0.3, 0.09),
>>>                        top_right=(0.86, 0.09),
>>>                        bottom_right=(0.86, 0.4),
>>>                        labels=['dolphin', 'fish'])
>>> record1 = LabeledImageItem(img_obj1, [bbox1])
>>> render(items = [record1])

ads.data_labeling.visualizer.text_visualizer module

The module that helps to visualize NER Text Dataset.

ads.data_labeling.visualizer.text_visualizer.render(items: List[LabeledTextItem], options: Dict = None) str[source]

Renders NER dataset to Html format.

Examples

>>> record1 = LabeledTextItem("London is the capital of the United Kingdom", [NERItem('city', 0, 6), NERItem("country", 29, 14)])
>>> record2 = LabeledTextItem("Houston area contractor seeking a Sheet Metal Superintendent.", [NERItem("city", 0, 6)])
>>> result = render(items = [record1, record2], options={"default_color":"#DDEECC", "colors": {"city":"#DDEECC", "country":"#FFAAAA"}})
>>> display(HTML(result))
class ads.data_labeling.visualizer.text_visualizer.LabeledTextItem(txt: str, ents: List[NERItem])[source]

Bases: object

Data class representing NER Item.

txt

The labeled sentence.

Type:

str

ents

The list of entities.

Type:

List[NERItem]

ents: List[NERItem]
txt: str
class ads.data_labeling.visualizer.text_visualizer.RenderOptions(default_color: str, colors: dict | None)[source]

Bases: object

Data class representing render options.

default_color

The specified default color.

Type:

str

colors

The multiple specified colors.

Type:

Optional[dict]

colors: dict | None
default_color: str
classmethod from_dict(options: dict) RenderOptions[source]

Constructs an instance of RenderOptions from a dictionary.

Parameters:

options (dict) – Render options in dictionary format.

Returns:

The instance of RenderOptions.

Return type:

RenderOptions

to_dict()[source]

Converts RenderOptions instance to dictionary format.

Returns:

The render options in dictionary format.

Return type:

dict

class ads.data_labeling.visualizer.text_visualizer.TextLabeledDataFormatter[source]

Bases: object

The TextLabeledDataFormatter class to render NER items into Html format.

static render(items: List[LabeledTextItem], options: Dict | None = None) str[source]

Renders NER dataset to Html format.

Parameters:
  • items (List[LabeledTextItem]) – Items to render.

  • options (Optional[dict]) – Render options.

Returns:

Html representation of rendered NER dataset.

Return type:

str

Raises:
ads.data_labeling.visualizer.text_visualizer.render(items: List[LabeledTextItem], options: Dict | None = None) str[source]

Renders NER dataset to Html format.

Parameters:
  • items (List[LabeledTextItem]) – The list of NER items to render.

  • options (dict, optional) – The options for rendering.

Returns:

Html string.

Return type:

str

Examples

>>> record = LabeledTextItem("London is the capital of the United Kingdom", [NERItem('city', 0, 6), NERItem("country", 29, 14)])
>>> result = render(items = [record], options={"default_color":"#DDEECC", "colors": {"city":"#DDEECC", "country":"#FFAAAA"}})
>>> display(HTML(result))

Module contents