sinapsis-data-visualization 0.1.0__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. sinapsis_data_visualization-0.1.3/PKG-INFO +194 -0
  2. sinapsis_data_visualization-0.1.3/README.md +175 -0
  3. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/pyproject.toml +14 -4
  4. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/helpers/annotation_drawer_tools.py +1 -2
  5. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/helpers/color_utils.py +0 -1
  6. sinapsis_data_visualization-0.1.3/src/sinapsis_data_visualization/templates/base_annotation_drawer.py +167 -0
  7. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/templates/bbox_drawer.py +0 -1
  8. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/templates/data_distribution_visualization_template.py +2 -3
  9. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/templates/key_points_drawer.py +0 -1
  10. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/templates/label_drawer.py +1 -2
  11. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/templates/oriented_bbox_drawer.py +1 -2
  12. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/templates/segmentation_mask_drawer.py +0 -1
  13. sinapsis_data_visualization-0.1.3/src/sinapsis_data_visualization.egg-info/PKG-INFO +194 -0
  14. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization.egg-info/SOURCES.txt +1 -0
  15. sinapsis_data_visualization-0.1.0/PKG-INFO +0 -674
  16. sinapsis_data_visualization-0.1.0/src/sinapsis_data_visualization/templates/base_annotation_drawer.py +0 -103
  17. sinapsis_data_visualization-0.1.0/src/sinapsis_data_visualization.egg-info/PKG-INFO +0 -674
  18. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/LICENSE +0 -0
  19. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/setup.cfg +0 -0
  20. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/__init__.py +0 -0
  21. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/__init__.py +0 -0
  22. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/helpers/__init__.py +0 -0
  23. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/helpers/annotation_drawer_types.py +0 -0
  24. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/helpers/detection_utils.py +0 -0
  25. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/helpers/plot_distributions.py +0 -0
  26. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/helpers/scikit_pca_analysis.py +0 -0
  27. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization/templates/__init__.py +0 -0
  28. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization.egg-info/dependency_links.txt +0 -0
  29. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization.egg-info/requires.txt +0 -0
  30. {sinapsis_data_visualization-0.1.0 → sinapsis_data_visualization-0.1.3}/src/sinapsis_data_visualization.egg-info/top_level.txt +0 -0
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: sinapsis-data-visualization
3
+ Version: 0.1.3
4
+ Summary: Templates to perform visualization of data distributions and image annotations.
5
+ Author-email: SinapsisAI <dev@sinapsis.tech>
6
+ Project-URL: Homepage, https://sinapsis.tech
7
+ Project-URL: Documentation, https://docs.sinapsis.tech/docs
8
+ Project-URL: Tutorials, https://docs.sinapsis.tech/tutorials
9
+ Project-URL: Repository, https://github.com/Sinapsis-AI/sinapsis-data-tools.git
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: sinapsis>=0.1.1
14
+ Provides-Extra: visualization-matplotlib
15
+ Requires-Dist: matplotlib>=3.9.2; extra == "visualization-matplotlib"
16
+ Provides-Extra: all
17
+ Requires-Dist: sinapsis-data-visualization[visualization-matplotlib]; extra == "all"
18
+ Dynamic: license-file
19
+
20
+ <h1 align="center">
21
+ <br>
22
+ <a href="https://sinapsis.tech/">
23
+ <img
24
+ src="https://github.com/Sinapsis-AI/brand-resources/blob/main/sinapsis_logo/4x/logo.png?raw=true"
25
+ alt="" width="300">
26
+ </a>
27
+
28
+ <br>
29
+ Sinapsis Data Visualization
30
+ <br>
31
+ </h1>
32
+
33
+ <h4 align="center"> Package with templates to visualize images and data distribution using different libraries and techniques</h4>
34
+
35
+ <p align="center">
36
+ <a href="#installation">🐍 Installation</a> •
37
+ <a href="#features">🚀 Features</a> •
38
+ <a href="#usage">📚 Usage example</a> •
39
+ <a href="#documentation">📙 Documentation</a> •
40
+ <a href="#license">🔍 License</a>
41
+ </p>
42
+
43
+ <h2 id="installation">🐍 Installation</h2>
44
+
45
+ Install using your package manager of choice. We encourage the use of <code>uv</code>
46
+
47
+ Example with <code>uv</code>:
48
+
49
+ ```bash
50
+ uv pip install sinapsis-data-visualization --extra-index-url https://pypi.sinapsis.tech
51
+ ```
52
+ or with raw <code>pip</code>:
53
+ ```bash
54
+ pip install sinapsis-data-visualization --extra-index-url https://pypi.sinapsis.tech
55
+ ```
56
+
57
+ > [!IMPORTANT]
58
+ > Templates in each package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:
59
+ >
60
+
61
+ with <code>uv</code>:
62
+
63
+ ```bash
64
+ uv pip install sinapsis-data-visualization[all] --extra-index-url https://pypi.sinapsis.tech
65
+ ```
66
+ or with raw <code>pip</code>:
67
+ ```bash
68
+ pip install sinapsis-data-visualization[all] --extra-index-url https://pypi.sinapsis.tech
69
+ ```
70
+
71
+
72
+ <h2 id="features">🚀 Features</h2>
73
+
74
+
75
+
76
+ > [!TIP]
77
+ > Use CLI command ``` sinapsis info --all-template-names``` to show a list with all the available Template names installed with Sinapsis Data Tools.
78
+
79
+ > [!TIP]
80
+ > Use CLI command ```sinapsis info --example-template-config TEMPLATE_NAME``` to produce an example Agent config for the Template specified in ***TEMPLATE_NAME***.
81
+
82
+ For example, for ***ImageSaver*** use ```sinapsis info --example-template-config ImageSaver``` to produce the following example config:
83
+ <details id='packages'><summary><strong><span style="font-size: 1.0em;"> Config</span></strong></summary>
84
+
85
+ ```yaml
86
+ agent:
87
+ name: my_test_agent
88
+ description: agent to read images from a local folder and draw annotations if available
89
+ templates:
90
+ - template_name: InputTemplate
91
+ class_name: InputTemplate
92
+ attributes: {}
93
+ - template_name: FolderImageDatasetCV2
94
+ class_name: FolderImageDatasetCV2
95
+ template_input: InputTemplate
96
+ attributes:
97
+ data_dir: '/path/to/sinapsis/cache/dir'
98
+ pattern: '**/*'
99
+ batch_size: 1
100
+ shuffle_data: false
101
+ samples_to_load: -1
102
+ load_on_init: false
103
+ label_path_index: -2
104
+ is_ground_truth: false
105
+ - template_name: BBoxDrawer
106
+ class_name: BBoxDrawer
107
+ template_input: FolderImageDatasetCV2
108
+ attributes:
109
+ overwrite: false
110
+ randomized_color: true
111
+ draw_confidence: true
112
+ draw_extra_labels: true
113
+ text_style:
114
+ font: 0
115
+ font_scale: 0.5
116
+ thickness: 2
117
+ draw_classification_label: false
118
+ classification_label_position: top_right
119
+ text_box_to_border_offset: 0.01
120
+
121
+ ```
122
+
123
+
124
+ <h2 id="usage">📚 Usage example</h2>
125
+ You can copy and paste the following config and run it using the sinapsis cli, changing the <code>data_dir</code> attribute in the <code>FolderImageDatasetCV2</code> and the <code>root_dir</code> attribute in the <code>ImageSaver</code> template
126
+
127
+ <details id='usage'><summary><strong><span style="font-size: 1.0em;"> Example agent config</span></strong></summary>
128
+
129
+ ```yaml
130
+ agent:
131
+ name: my_test_agent
132
+ description: agent to save image locally
133
+ templates:
134
+ - template_name: InputTemplate
135
+ class_name: InputTemplate
136
+ attributes: {}
137
+ - template_name: FolderImageDatasetCV2
138
+ class_name: FolderImageDatasetCV2
139
+ attributes:
140
+ data_dir: /path/to/image
141
+ pattern: '**/*'
142
+ batch_size: 1
143
+ load_on_init: true
144
+ label_path_index: 0
145
+ is_ground_truth: false
146
+ - template_name: BBoxDrawer
147
+ class_name: BBoxDrawer
148
+ template_input: FolderImageDatasetCV2
149
+ attributes:
150
+ overwrite: false
151
+ randomized_color: true
152
+ draw_confidence: true
153
+ draw_extra_labels: true
154
+ text_style:
155
+ font: 0
156
+ font_scale: 0.5
157
+ thickness: 2
158
+ draw_classification_label: false
159
+ classification_label_position: top_right
160
+ text_box_to_border_offset: 0.01
161
+ - template_name: ImageSaver
162
+ class_name: ImageSaver
163
+ template_input: BBoxDrawer
164
+ attributes:
165
+ save_dir: /path/to/save/dir
166
+ extension: jpg
167
+ root_dir: '/path/to/sinapsis/cache'
168
+ save_full_image: true
169
+ save_bbox_crops: false
170
+ save_mask_crops: false
171
+ min_bbox_dim: 5
172
+ ```
173
+ </details>
174
+
175
+ To run, simply use:
176
+
177
+ ```bash
178
+ sinapsis run name_of_the_config.yml
179
+ ```
180
+ </details>
181
+ <h2 id="documentation">📙 Documentation</h2>
182
+
183
+ Documentation for this and other sinapsis packages is available on the [sinapsis website](https://docs.sinapsis.tech/docs)
184
+
185
+ Tutorials for different projects within sinapsis are available at [sinapsis tutorials page](https://docs.sinapsis.tech/tutorials)
186
+
187
+ <h2 id="license">🔍 License</h2>
188
+
189
+ This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the [LICENSE](LICENSE) file.
190
+
191
+ For commercial use, please refer to our [official Sinapsis website](https://sinapsis.tech) for information on obtaining a commercial license.
192
+
193
+
194
+
@@ -0,0 +1,175 @@
1
+ <h1 align="center">
2
+ <br>
3
+ <a href="https://sinapsis.tech/">
4
+ <img
5
+ src="https://github.com/Sinapsis-AI/brand-resources/blob/main/sinapsis_logo/4x/logo.png?raw=true"
6
+ alt="" width="300">
7
+ </a>
8
+
9
+ <br>
10
+ Sinapsis Data Visualization
11
+ <br>
12
+ </h1>
13
+
14
+ <h4 align="center"> Package with templates to visualize images and data distribution using different libraries and techniques</h4>
15
+
16
+ <p align="center">
17
+ <a href="#installation">🐍 Installation</a> •
18
+ <a href="#features">🚀 Features</a> •
19
+ <a href="#usage">📚 Usage example</a> •
20
+ <a href="#documentation">📙 Documentation</a> •
21
+ <a href="#license">🔍 License</a>
22
+ </p>
23
+
24
+ <h2 id="installation">🐍 Installation</h2>
25
+
26
+ Install using your package manager of choice. We encourage the use of <code>uv</code>
27
+
28
+ Example with <code>uv</code>:
29
+
30
+ ```bash
31
+ uv pip install sinapsis-data-visualization --extra-index-url https://pypi.sinapsis.tech
32
+ ```
33
+ or with raw <code>pip</code>:
34
+ ```bash
35
+ pip install sinapsis-data-visualization --extra-index-url https://pypi.sinapsis.tech
36
+ ```
37
+
38
+ > [!IMPORTANT]
39
+ > Templates in each package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:
40
+ >
41
+
42
+ with <code>uv</code>:
43
+
44
+ ```bash
45
+ uv pip install sinapsis-data-visualization[all] --extra-index-url https://pypi.sinapsis.tech
46
+ ```
47
+ or with raw <code>pip</code>:
48
+ ```bash
49
+ pip install sinapsis-data-visualization[all] --extra-index-url https://pypi.sinapsis.tech
50
+ ```
51
+
52
+
53
+ <h2 id="features">🚀 Features</h2>
54
+
55
+
56
+
57
+ > [!TIP]
58
+ > Use CLI command ``` sinapsis info --all-template-names``` to show a list with all the available Template names installed with Sinapsis Data Tools.
59
+
60
+ > [!TIP]
61
+ > Use CLI command ```sinapsis info --example-template-config TEMPLATE_NAME``` to produce an example Agent config for the Template specified in ***TEMPLATE_NAME***.
62
+
63
+ For example, for ***ImageSaver*** use ```sinapsis info --example-template-config ImageSaver``` to produce the following example config:
64
+ <details id='packages'><summary><strong><span style="font-size: 1.0em;"> Config</span></strong></summary>
65
+
66
+ ```yaml
67
+ agent:
68
+ name: my_test_agent
69
+ description: agent to read images from a local folder and draw annotations if available
70
+ templates:
71
+ - template_name: InputTemplate
72
+ class_name: InputTemplate
73
+ attributes: {}
74
+ - template_name: FolderImageDatasetCV2
75
+ class_name: FolderImageDatasetCV2
76
+ template_input: InputTemplate
77
+ attributes:
78
+ data_dir: '/path/to/sinapsis/cache/dir'
79
+ pattern: '**/*'
80
+ batch_size: 1
81
+ shuffle_data: false
82
+ samples_to_load: -1
83
+ load_on_init: false
84
+ label_path_index: -2
85
+ is_ground_truth: false
86
+ - template_name: BBoxDrawer
87
+ class_name: BBoxDrawer
88
+ template_input: FolderImageDatasetCV2
89
+ attributes:
90
+ overwrite: false
91
+ randomized_color: true
92
+ draw_confidence: true
93
+ draw_extra_labels: true
94
+ text_style:
95
+ font: 0
96
+ font_scale: 0.5
97
+ thickness: 2
98
+ draw_classification_label: false
99
+ classification_label_position: top_right
100
+ text_box_to_border_offset: 0.01
101
+
102
+ ```
103
+
104
+
105
+ <h2 id="usage">📚 Usage example</h2>
106
+ You can copy and paste the following config and run it using the sinapsis cli, changing the <code>data_dir</code> attribute in the <code>FolderImageDatasetCV2</code> and the <code>root_dir</code> attribute in the <code>ImageSaver</code> template
107
+
108
+ <details id='usage'><summary><strong><span style="font-size: 1.0em;"> Example agent config</span></strong></summary>
109
+
110
+ ```yaml
111
+ agent:
112
+ name: my_test_agent
113
+ description: agent to save image locally
114
+ templates:
115
+ - template_name: InputTemplate
116
+ class_name: InputTemplate
117
+ attributes: {}
118
+ - template_name: FolderImageDatasetCV2
119
+ class_name: FolderImageDatasetCV2
120
+ attributes:
121
+ data_dir: /path/to/image
122
+ pattern: '**/*'
123
+ batch_size: 1
124
+ load_on_init: true
125
+ label_path_index: 0
126
+ is_ground_truth: false
127
+ - template_name: BBoxDrawer
128
+ class_name: BBoxDrawer
129
+ template_input: FolderImageDatasetCV2
130
+ attributes:
131
+ overwrite: false
132
+ randomized_color: true
133
+ draw_confidence: true
134
+ draw_extra_labels: true
135
+ text_style:
136
+ font: 0
137
+ font_scale: 0.5
138
+ thickness: 2
139
+ draw_classification_label: false
140
+ classification_label_position: top_right
141
+ text_box_to_border_offset: 0.01
142
+ - template_name: ImageSaver
143
+ class_name: ImageSaver
144
+ template_input: BBoxDrawer
145
+ attributes:
146
+ save_dir: /path/to/save/dir
147
+ extension: jpg
148
+ root_dir: '/path/to/sinapsis/cache'
149
+ save_full_image: true
150
+ save_bbox_crops: false
151
+ save_mask_crops: false
152
+ min_bbox_dim: 5
153
+ ```
154
+ </details>
155
+
156
+ To run, simply use:
157
+
158
+ ```bash
159
+ sinapsis run name_of_the_config.yml
160
+ ```
161
+ </details>
162
+ <h2 id="documentation">📙 Documentation</h2>
163
+
164
+ Documentation for this and other sinapsis packages is available on the [sinapsis website](https://docs.sinapsis.tech/docs)
165
+
166
+ Tutorials for different projects within sinapsis are available at [sinapsis tutorials page](https://docs.sinapsis.tech/tutorials)
167
+
168
+ <h2 id="license">🔍 License</h2>
169
+
170
+ This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the [LICENSE](LICENSE) file.
171
+
172
+ For commercial use, please refer to our [official Sinapsis website](https://sinapsis.tech) for information on obtaining a commercial license.
173
+
174
+
175
+
@@ -1,11 +1,11 @@
1
1
  [project]
2
2
  name = "sinapsis-data-visualization"
3
- version = "0.1.0"
3
+ version = "0.1.3"
4
4
  description = "Templates to perform visualization of data distributions and image annotations."
5
5
  authors = [{ name = "SinapsisAI", email = "dev@sinapsis.tech" }]
6
6
 
7
7
  readme = "README.md"
8
- license = { file = "LICENSE" }
8
+ license-files = ["LICENSE"]
9
9
  requires-python = ">=3.10"
10
10
  dependencies = [
11
11
  "sinapsis>=0.1.1",
@@ -20,5 +20,15 @@ sinapsis-data-visualization = { workspace = true }
20
20
  [build-system]
21
21
  requires = ["setuptools"]
22
22
  build-backend = "setuptools.build_meta"
23
- [tool.setuptools]
24
- license-files = []
23
+
24
+
25
+ [[tool.uv.index]]
26
+ name = "sinapsis"
27
+ url = "https://pypi.sinapsis.tech/"
28
+
29
+
30
+ [project.urls]
31
+ Homepage = "https://sinapsis.tech"
32
+ Documentation = "https://docs.sinapsis.tech/docs"
33
+ Tutorials = "https://docs.sinapsis.tech/tutorials"
34
+ Repository = "https://github.com/Sinapsis-AI/sinapsis-data-tools.git"
@@ -4,7 +4,6 @@ from typing import cast
4
4
  import cv2
5
5
  import numpy as np
6
6
  from sinapsis_core.data_containers.annotations import BoundingBox, ImageAnnotations
7
-
8
7
  from sinapsis_data_visualization.helpers.annotation_drawer_types import (
9
8
  TextInstanceProperties,
10
9
  TextStyle,
@@ -70,7 +69,7 @@ def get_dynamic_text_properties(image: np.ndarray) -> tuple[float, float]:
70
69
 
71
70
  def get_numeric_str(label: str, numeric_val: float | int) -> str:
72
71
  """Writes numeric value of label as string
73
-
72
+
74
73
  Args:
75
74
  label (str): label of the annotation
76
75
  numeric_val (float|int): numeric_val to convert to string
@@ -4,7 +4,6 @@ import math
4
4
  import random
5
5
 
6
6
  from matplotlib import colors
7
-
8
7
  from sinapsis_data_visualization.helpers.annotation_drawer_types import RGB_TYPE
9
8
 
10
9
 
@@ -0,0 +1,167 @@
1
+ # -*- coding: utf-8 -*-
2
+ import abc
3
+ import random
4
+ from pathlib import Path
5
+
6
+ import numpy as np
7
+ from sinapsis_core.data_containers.annotations import ImageAnnotations
8
+ from sinapsis_core.data_containers.data_packet import DataContainer, ImagePacket
9
+ from sinapsis_core.template_base import Template
10
+ from sinapsis_core.template_base.base_models import (
11
+ TemplateAttributes,
12
+ TemplateAttributeType,
13
+ )
14
+ from sinapsis_data_visualization.helpers.color_utils import (
15
+ RGB_TYPE,
16
+ build_color_map,
17
+ get_color_rgb_tuple,
18
+ )
19
+
20
+ random.seed(0)
21
+
22
+
23
+ class BaseAnnotationDrawer(Template, abc.ABC):
24
+ """Base template to handle and draw annotations in images.
25
+
26
+ This class incorporates methods to determine if an ImagePacket
27
+ has annotations and to draw annotations on images.
28
+
29
+ The execute method calls the draw_annotation method for
30
+ the list of ImagePackets
31
+ """
32
+
33
+ COLOR_MAP = build_color_map()
34
+
35
+ class AttributesBaseModel(TemplateAttributes):
36
+ """
37
+ Attributes for Image Annotation Drawer
38
+
39
+ Args:
40
+ overwrite (bool): Enable overwriting original image content.
41
+ If False Image drawing is performed on a copy of the original one.
42
+ randomized_color (bool): Flag to use random colors in the annotations.
43
+ Defaults to True
44
+ """
45
+
46
+ overwrite: bool = False
47
+ randomized_color: bool = True
48
+
49
+ def __init__(self, attributes: TemplateAttributeType) -> None:
50
+ """Initializes the Image Annotation Drawer with the given attributes."""
51
+ super().__init__(attributes)
52
+ self.drawing_strategies: list = []
53
+ self.set_drawing_strategy()
54
+
55
+ def set_drawing_strategy(self) -> None:
56
+ """Abstract method to determine which annotations to draw
57
+ (e.g., labels, bbox, kpts, etc.)"""
58
+
59
+ @staticmethod
60
+ def image_has_annotations(image: ImagePacket) -> bool:
61
+ """
62
+ Checks if the image packet contains annotations.
63
+
64
+ Args:
65
+ image (ImagePacket): The image packet to check.
66
+
67
+ Returns:
68
+ bool: True if the image has annotations, False otherwise.
69
+ """
70
+ return image.annotations is not None
71
+
72
+ def get_annotation_color(self, ann: ImageAnnotations) -> RGB_TYPE:
73
+ """
74
+ Retrieves the color for an annotation.
75
+
76
+ Args:
77
+ ann: The annotation to fetch the color for.
78
+
79
+ Returns:
80
+ RGB_TYPE: The color corresponding to the annotation.
81
+ """
82
+ return get_color_rgb_tuple(
83
+ color_map=self.COLOR_MAP,
84
+ class_id=ann.label,
85
+ randomized=self.attributes.randomized_color,
86
+ )
87
+
88
+ def apply_drawing_strategies(self, image_packet: ImagePacket) -> np.ndarray:
89
+ """
90
+ Applies drawing strategies to the image packet.
91
+
92
+ Args:
93
+ image_packet (ImagePacket): The image packet containing annotations to draw.
94
+
95
+ Returns:
96
+ np.ndarray: The image content after applying the drawing strategies.
97
+ """
98
+ annotated_image = image_packet.content
99
+ for ann in image_packet.annotations:
100
+ ann_color = self.get_annotation_color(ann)
101
+ for strategy in self.drawing_strategies:
102
+ annotated_image = strategy(annotated_image, ann, ann_color)
103
+ return annotated_image
104
+
105
+ def draw_annotation(self, image_packet: ImagePacket) -> np.ndarray:
106
+ """
107
+ Draws annotations on the provided image packet.
108
+
109
+ This method checks if the image packet contains annotations and, if so, applies
110
+ drawing strategies to annotate the image.
111
+
112
+ Args:
113
+ image_packet (ImagePacket): The image packet containing annotations to draw.
114
+
115
+ Returns:
116
+ np.ndarray: The annotated image content as a NumPy array. If the image doesn't
117
+ have annotations, the original image content is returned without modification.
118
+ """
119
+ image_packet.content = np.ascontiguousarray(image_packet.content)
120
+
121
+ if not self.image_has_annotations(image_packet):
122
+ return image_packet.content
123
+
124
+ annotated_image = self.apply_drawing_strategies(image_packet)
125
+
126
+ return annotated_image
127
+
128
+ def process_images(self, container: DataContainer) -> None:
129
+ """
130
+ Process and annotate images in the container.
131
+ If self.attributes.overwrite is True, it overwrites the image content;
132
+ otherwise, it adds annotated images to the container.
133
+
134
+ Args:
135
+ container (DataContainer): The data container containing image packets.
136
+ """
137
+ if self.attributes.overwrite:
138
+ for image_packet in container.images:
139
+ image_packet.content = self.draw_annotation(image_packet)
140
+ else:
141
+ annotated_images: list[ImagePacket] = []
142
+ for image_packet in container.images:
143
+ annotated_image = self.draw_annotation(image_packet)
144
+
145
+ if annotated_image is not image_packet.content:
146
+ annotated_images.append(
147
+ ImagePacket(
148
+ content=annotated_image,
149
+ color_space=image_packet.color_space,
150
+ source=f"a_{Path(image_packet.source).name}",
151
+ )
152
+ )
153
+ container.images.extend(annotated_images)
154
+
155
+ def execute(self, container: DataContainer) -> DataContainer:
156
+ """
157
+ Executes image drawer for images in the container.
158
+
159
+ Args:
160
+ container (DataContainer): The data container containing image packets.
161
+
162
+ Returns:
163
+ DataContainer: The updated data container with images annotated.
164
+ """
165
+ self.process_images(container)
166
+
167
+ return container
@@ -3,7 +3,6 @@
3
3
  import cv2
4
4
  import numpy as np
5
5
  from sinapsis_core.data_containers.annotations import BoundingBox, ImageAnnotations
6
-
7
6
  from sinapsis_data_visualization.helpers.color_utils import RGB_TYPE
8
7
  from sinapsis_data_visualization.templates.label_drawer import LabelDrawer
9
8
 
@@ -10,13 +10,12 @@ import numpy as np
10
10
  from pydantic import Field
11
11
  from pydantic.dataclasses import dataclass
12
12
  from sinapsis_core.data_containers.data_packet import DataContainer
13
- from sinapsis_core.template_base import (
14
- Template,
13
+ from sinapsis_core.template_base import Template
14
+ from sinapsis_core.template_base.base_models import (
15
15
  TemplateAttributes,
16
16
  TemplateAttributeType,
17
17
  )
18
18
  from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
19
-
20
19
  from sinapsis_data_visualization.helpers.plot_distributions import (
21
20
  plot_distribution,
22
21
  plot_map,
@@ -3,7 +3,6 @@
3
3
  import cv2
4
4
  import numpy as np
5
5
  from sinapsis_core.data_containers.annotations import ImageAnnotations, KeyPoint
6
-
7
6
  from sinapsis_data_visualization.helpers.annotation_drawer_types import (
8
7
  KeyPointAppearance,
9
8
  )
@@ -4,7 +4,6 @@ from typing import Literal
4
4
 
5
5
  import numpy as np
6
6
  from sinapsis_core.data_containers.annotations import BoundingBox, ImageAnnotations
7
-
8
7
  from sinapsis_data_visualization.helpers.annotation_drawer_tools import (
9
8
  draw_annotation_rectangle,
10
9
  draw_extra_labels,
@@ -128,7 +127,7 @@ class LabelDrawer(BaseAnnotationDrawer):
128
127
  def get_label_ann_str(self, annotation: ImageAnnotations) -> str:
129
128
  """
130
129
  Returns the annotation as string, appending confidence score if needed.
131
-
130
+
132
131
  Args:
133
132
  annotation (ImageAnnotations): Annotation object in the ImagePacket to
134
133
  extract the label from
@@ -7,7 +7,6 @@ from sinapsis_core.data_containers.annotations import (
7
7
  ImageAnnotations,
8
8
  OrientedBoundingBox,
9
9
  )
10
-
11
10
  from sinapsis_data_visualization.helpers.color_utils import RGB_TYPE
12
11
  from sinapsis_data_visualization.templates.bbox_drawer import BBoxDrawer
13
12
 
@@ -52,7 +51,7 @@ class OrientedBBoxDrawer(BBoxDrawer):
52
51
  Appends the method to draw the oriented bbox on the image, to
53
52
  the drawing_strategies list.
54
53
  """
55
- self.drawing_strategies.append(self.draw_bbox_strategy)
54
+ self.drawing_strategies.append(self.draw_oriented_bbox_strategy)
56
55
 
57
56
  @staticmethod
58
57
  def draw_oriented_bbox(
@@ -2,7 +2,6 @@
2
2
 
3
3
  import numpy as np
4
4
  from sinapsis_core.data_containers.annotations import ImageAnnotations, Segmentation
5
-
6
5
  from sinapsis_data_visualization.helpers.color_utils import RGB_TYPE
7
6
  from sinapsis_data_visualization.templates.bbox_drawer import BBoxDrawer
8
7