sinapsis-data-readers 0.1.16__py3-none-any.whl → 0.1.19__py3-none-any.whl
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.
- sinapsis_data_readers/templates/datasets_readers/sklearn_datasets.py +3 -4
- sinapsis_data_readers/templates/datasets_readers/sktime_datasets.py +3 -2
- sinapsis_data_readers/templates/image_readers/coco_dataset_reader.py +1 -2
- sinapsis_data_readers/templates/video_readers/video_reader_dali.py +9 -9
- {sinapsis_data_readers-0.1.16.dist-info → sinapsis_data_readers-0.1.19.dist-info}/METADATA +3 -3
- {sinapsis_data_readers-0.1.16.dist-info → sinapsis_data_readers-0.1.19.dist-info}/RECORD +9 -10
- sinapsis_data_readers/helpers/image_color_space_converter.py +0 -53
- {sinapsis_data_readers-0.1.16.dist-info → sinapsis_data_readers-0.1.19.dist-info}/WHEEL +0 -0
- {sinapsis_data_readers-0.1.16.dist-info → sinapsis_data_readers-0.1.19.dist-info}/licenses/LICENSE +0 -0
- {sinapsis_data_readers-0.1.16.dist-info → sinapsis_data_readers-0.1.19.dist-info}/top_level.txt +0 -0
|
@@ -135,7 +135,7 @@ class SKLearnDatasets(BaseDynamicWrapperTemplate):
|
|
|
135
135
|
@staticmethod
|
|
136
136
|
def split_dataset(
|
|
137
137
|
results: pd.DataFrame, feature_name_cols: list, target_name_cols: list, n_features: int, split_size: float
|
|
138
|
-
) ->
|
|
138
|
+
) -> dict:
|
|
139
139
|
"""Method to split the dataset into training and testing samples"""
|
|
140
140
|
if feature_name_cols:
|
|
141
141
|
X = results[feature_name_cols]
|
|
@@ -144,8 +144,7 @@ class SKLearnDatasets(BaseDynamicWrapperTemplate):
|
|
|
144
144
|
X = results.iloc[:, :n_features]
|
|
145
145
|
y = results.iloc[:, n_features:]
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
# y_vals = results[TARGET]
|
|
147
|
+
|
|
149
148
|
x_train, x_test, y_train, y_test = train_test_split(X, y, train_size=split_size, random_state=0)
|
|
150
149
|
split_data = TabularDatasetSplit(
|
|
151
150
|
x_train=pd.DataFrame(x_train),
|
|
@@ -154,7 +153,7 @@ class SKLearnDatasets(BaseDynamicWrapperTemplate):
|
|
|
154
153
|
y_test=pd.DataFrame(y_test),
|
|
155
154
|
)
|
|
156
155
|
|
|
157
|
-
return split_data
|
|
156
|
+
return split_data.model_dump_json(indent=2)
|
|
158
157
|
|
|
159
158
|
def execute(self, container: DataContainer) -> DataContainer:
|
|
160
159
|
sklearn_dataset = self.wrapped_callable.__func__(**self.dataset_attributes.model_dump())
|
|
@@ -94,7 +94,7 @@ class SKTimeDatasets(BaseDynamicWrapperTemplate):
|
|
|
94
94
|
|
|
95
95
|
def initialize_attributes(self):
|
|
96
96
|
return getattr(self.attributes, self.wrapped_callable.__name__)
|
|
97
|
-
def split_time_series_dataset(self, dataset: Any) ->
|
|
97
|
+
def split_time_series_dataset(self, dataset: Any) -> dict:
|
|
98
98
|
"""Split a time series dataset into training and testing sets
|
|
99
99
|
|
|
100
100
|
Args:
|
|
@@ -104,12 +104,13 @@ class SKTimeDatasets(BaseDynamicWrapperTemplate):
|
|
|
104
104
|
TabularDatasetSplit: Object containing the split time series data
|
|
105
105
|
"""
|
|
106
106
|
y_train, y_test = temporal_train_test_split(dataset, train_size=self.attributes.train_size)
|
|
107
|
-
|
|
107
|
+
split_dataset = TabularDatasetSplit(
|
|
108
108
|
x_train=pd.DataFrame(index=y_train.index),
|
|
109
109
|
x_test=pd.DataFrame(index=y_test.index),
|
|
110
110
|
y_train=pd.DataFrame(y_train),
|
|
111
111
|
y_test=pd.DataFrame(y_test),
|
|
112
112
|
)
|
|
113
|
+
return split_dataset.model_dump_json(indent=2)
|
|
113
114
|
|
|
114
115
|
def split_classification_dataset(self, X: Any, y: Any) -> TabularDatasetSplit:
|
|
115
116
|
"""Split a classification dataset into training and testing sets
|
|
@@ -55,8 +55,7 @@ class CocoImageDatasetBaseCV2(FolderImageDatasetCV2):
|
|
|
55
55
|
annotations_path: str
|
|
56
56
|
|
|
57
57
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
58
|
-
self.annotations_file = os.path.join(attributes.get("root_dir", SINAPSIS_CACHE_DIR),
|
|
59
|
-
attributes.get("data_dir"), attributes.get("annotations_path"))
|
|
58
|
+
self.annotations_file = os.path.join(attributes.get("root_dir", SINAPSIS_CACHE_DIR), attributes.get("data_dir"), attributes.get("annotations_path"))
|
|
60
59
|
self.raw_annotations_dict: list[dict[str, dict[str, Any]]] = self.read_annotations_file(self.annotations_file)
|
|
61
60
|
self.annotations = self.images_annotations()
|
|
62
61
|
super().__init__(attributes)
|
|
@@ -134,19 +134,19 @@ class VideoReaderDali(BaseVideoReader):
|
|
|
134
134
|
del self.video_reader
|
|
135
135
|
|
|
136
136
|
def _read_video_frames(self) -> list[ImagePacket]:
|
|
137
|
-
"""Reads video frames from the dali pipeline.
|
|
138
|
-
|
|
139
|
-
This method runs the video reader pipeline and adds the frames to a list
|
|
140
|
-
of ImagePacket objects.
|
|
141
|
-
|
|
142
|
-
Returns:
|
|
143
|
-
list[ImagePacket]: A list of ImagePacket objects representing the video frames.
|
|
144
|
-
"""
|
|
137
|
+
"""Reads video frames from the dali pipeline."""
|
|
145
138
|
video_frames: list[ImagePacket] = []
|
|
146
139
|
sequences_out = self.video_reader.run()
|
|
140
|
+
tensor_batch = sequences_out[0]
|
|
141
|
+
|
|
142
|
+
shape_result = tensor_batch.shape()
|
|
143
|
+
batch_size = shape_result[0][0]
|
|
147
144
|
|
|
148
|
-
for idx
|
|
145
|
+
for idx in range(batch_size):
|
|
146
|
+
frame_tensor = tensor_batch.at(idx)
|
|
147
|
+
frame = torch.as_tensor(frame_tensor, device="cuda")
|
|
149
148
|
video_frames.append(self._make_image_packet(frame, frame_index=self.frame_count + idx))
|
|
149
|
+
|
|
150
150
|
return video_frames
|
|
151
151
|
|
|
152
152
|
def reset_state(self, template_name: str | None = None) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sinapsis-data-readers
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.19
|
|
4
4
|
Summary: Templates to read data in different formats
|
|
5
5
|
Author-email: SinapsisAI <dev@sinapsis.tech>
|
|
6
6
|
Project-URL: Homepage, https://sinapsis.tech
|
|
@@ -14,8 +14,8 @@ Requires-Dist: sinapsis>=0.1.1
|
|
|
14
14
|
Provides-Extra: nvidia-dali
|
|
15
15
|
Requires-Dist: nvidia-dali-cuda120>=1.43.0; extra == "nvidia-dali"
|
|
16
16
|
Provides-Extra: torch-codec
|
|
17
|
-
Requires-Dist: torch
|
|
18
|
-
Requires-Dist: torchcodec>=0.3
|
|
17
|
+
Requires-Dist: torch>=2.4.1; extra == "torch-codec"
|
|
18
|
+
Requires-Dist: torchcodec>=0.0.3; extra == "torch-codec"
|
|
19
19
|
Provides-Extra: sklearn-datasets
|
|
20
20
|
Requires-Dist: pandas>=2.2.3; extra == "sklearn-datasets"
|
|
21
21
|
Requires-Dist: scikit-learn>=1.5.2; extra == "sklearn-datasets"
|
|
@@ -4,7 +4,6 @@ sinapsis_data_readers/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
4
4
|
sinapsis_data_readers/helpers/coco_dataclasses.py,sha256=D5HVWQP95TdHpa9UnTYAClfaqsIYrODKDGbITCvYXsc,2290
|
|
5
5
|
sinapsis_data_readers/helpers/csv_reader.py,sha256=f_fk2Wgukdh93Um1Q5qczUD27iC3A71vKbhWxXe6Fyk,558
|
|
6
6
|
sinapsis_data_readers/helpers/file_path_helpers.py,sha256=ayuFe-AAEa4immcY19FcubAtKzZ3BtYkBus-QP5dADo,2205
|
|
7
|
-
sinapsis_data_readers/helpers/image_color_space_converter.py,sha256=SABsol7jp6veA_T13MSr0fQFVrI-NJdXkNYyX4YL90E,2099
|
|
8
7
|
sinapsis_data_readers/helpers/sklearn_dataset_subset.py,sha256=XpzdVTBr5OgG57oOz3W7eLpoj2vWlTKbX6NIH0OP3qc,792
|
|
9
8
|
sinapsis_data_readers/helpers/sktime_datasets_subset.py,sha256=aMmsaPuHuWkEP5BCAzeP6vV--y0UehBZL_fRHlDJweA,397
|
|
10
9
|
sinapsis_data_readers/helpers/tags.py,sha256=YeddHmiX9kq2wDUhQ6-elIDNxt3ojBs8oHQugzyjM3s,620
|
|
@@ -19,11 +18,11 @@ sinapsis_data_readers/templates/audio_readers/base_audio_reader.py,sha256=-3biMc
|
|
|
19
18
|
sinapsis_data_readers/templates/datasets_readers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
19
|
sinapsis_data_readers/templates/datasets_readers/csv_datasets.py,sha256=jn2x8QXpDn-wLoXML24xcfJ29WHT2OhRuFNrU105lOs,1210
|
|
21
20
|
sinapsis_data_readers/templates/datasets_readers/dataset_splitter.py,sha256=6FqN1x6V748Q_ESFfxfaCRJKJQY8cK-gwRHvzuYdVqI,8860
|
|
22
|
-
sinapsis_data_readers/templates/datasets_readers/sklearn_datasets.py,sha256=
|
|
23
|
-
sinapsis_data_readers/templates/datasets_readers/sktime_datasets.py,sha256=
|
|
21
|
+
sinapsis_data_readers/templates/datasets_readers/sklearn_datasets.py,sha256=Nr3RjdXxjtRz-mf2SwLDlpZ_AvWsno476n0j9GuLaOc,8244
|
|
22
|
+
sinapsis_data_readers/templates/datasets_readers/sktime_datasets.py,sha256=TEUQVBP7sCYh6hvCX3W1N6c3Cn_v012dfaFKzJFqek4,9500
|
|
24
23
|
sinapsis_data_readers/templates/image_readers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
24
|
sinapsis_data_readers/templates/image_readers/base_image_folder_data_loader.py,sha256=UM2SmBX7B2RE1OgwRtBn-GZdKmrgZILdN32itHIJKQI,4832
|
|
26
|
-
sinapsis_data_readers/templates/image_readers/coco_dataset_reader.py,sha256=
|
|
25
|
+
sinapsis_data_readers/templates/image_readers/coco_dataset_reader.py,sha256=cFVP50LeRSu9tppy4RYZbAmN775f6AuGUdDTzAHRf3k,14675
|
|
27
26
|
sinapsis_data_readers/templates/image_readers/csv_dataset_reader.py,sha256=k2eVDSLnX3dDkkq0ILgaB6X_sf0wgPyYbKTFX3rGBxo,4966
|
|
28
27
|
sinapsis_data_readers/templates/image_readers/image_folder_reader_cv2.py,sha256=XLoYT_5AZvqxaltek_MMUgA0gtJIzyKLL7YpUIvHaIU,2337
|
|
29
28
|
sinapsis_data_readers/templates/image_readers/image_folder_reader_kornia.py,sha256=LxrveCcVjtM7d3-tely03sfmATfSXOm0Smzdm7EugZI,2466
|
|
@@ -32,11 +31,11 @@ sinapsis_data_readers/templates/text_readers/text_input.py,sha256=d3NXeErhNqY9dY
|
|
|
32
31
|
sinapsis_data_readers/templates/video_readers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
32
|
sinapsis_data_readers/templates/video_readers/base_video_reader.py,sha256=QhW_VDzqA5YCDKdOxqzFFyEW8-LC1XAdeRGuQYWvMlw,14422
|
|
34
33
|
sinapsis_data_readers/templates/video_readers/video_reader_cv2.py,sha256=n3EYBYgKNC2zua7IHF6KCcIj41Mqpjp5sFRZLuPNeUs,4037
|
|
35
|
-
sinapsis_data_readers/templates/video_readers/video_reader_dali.py,sha256=
|
|
34
|
+
sinapsis_data_readers/templates/video_readers/video_reader_dali.py,sha256=TIsV1h4eYVOocdwC8tqW3aYz_9l5XJq5nTVc4rWlFUQ,8804
|
|
36
35
|
sinapsis_data_readers/templates/video_readers/video_reader_ffmpeg.py,sha256=uAnV02i9gy7p9mxTVcx20F6ily4JhBtJSDJ93Reyi4w,5046
|
|
37
36
|
sinapsis_data_readers/templates/video_readers/video_reader_torchcodec.py,sha256=wMCjRCaMknDYPOsspuf7NVEhy49h818lVq__AHTsFA8,4036
|
|
38
|
-
sinapsis_data_readers-0.1.
|
|
39
|
-
sinapsis_data_readers-0.1.
|
|
40
|
-
sinapsis_data_readers-0.1.
|
|
41
|
-
sinapsis_data_readers-0.1.
|
|
42
|
-
sinapsis_data_readers-0.1.
|
|
37
|
+
sinapsis_data_readers-0.1.19.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
38
|
+
sinapsis_data_readers-0.1.19.dist-info/METADATA,sha256=BAgUowN5EKwL35zhcJQB-O3YazivmRbiEpDtRBGWALs,6520
|
|
39
|
+
sinapsis_data_readers-0.1.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
40
|
+
sinapsis_data_readers-0.1.19.dist-info/top_level.txt,sha256=3R3oDiABqDVBW2Fc-SpWXYHkRdYFGZjT_wo6Q0Uqnhw,41
|
|
41
|
+
sinapsis_data_readers-0.1.19.dist-info/RECORD,,
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from enum import Enum
|
|
3
|
-
|
|
4
|
-
import cv2
|
|
5
|
-
from sinapsis_core.data_containers.data_packet import ImageColor, ImagePacket
|
|
6
|
-
from sinapsis_core.utils.logging_utils import sinapsis_logger
|
|
7
|
-
|
|
8
|
-
color_mapping = {
|
|
9
|
-
(ImageColor.RGB, ImageColor.BGR): cv2.COLOR_RGB2BGR,
|
|
10
|
-
(ImageColor.RGB, ImageColor.GRAY): cv2.COLOR_RGB2GRAY,
|
|
11
|
-
(ImageColor.RGB, ImageColor.RGBA): cv2.COLOR_RGB2RGBA,
|
|
12
|
-
(ImageColor.BGR, ImageColor.RGB): cv2.COLOR_BGR2RGB,
|
|
13
|
-
(ImageColor.BGR, ImageColor.GRAY): cv2.COLOR_BGR2GRAY,
|
|
14
|
-
(ImageColor.BGR, ImageColor.RGBA): cv2.COLOR_BGR2RGBA,
|
|
15
|
-
(ImageColor.GRAY, ImageColor.RGB): cv2.COLOR_GRAY2RGB,
|
|
16
|
-
(ImageColor.GRAY, ImageColor.BGR): cv2.COLOR_GRAY2BGR,
|
|
17
|
-
(ImageColor.GRAY, ImageColor.RGBA): cv2.COLOR_GRAY2RGBA,
|
|
18
|
-
(ImageColor.RGBA, ImageColor.RGB): cv2.COLOR_RGBA2RGB,
|
|
19
|
-
(ImageColor.RGBA, ImageColor.BGR): cv2.COLOR_RGBA2BGR,
|
|
20
|
-
(ImageColor.RGBA, ImageColor.GRAY): cv2.COLOR_RGBA2GRAY,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def convert_color_space_cv(image: ImagePacket, desired_color_space: Enum) -> ImagePacket:
|
|
25
|
-
"""Converts an image from one color space to another, provided
|
|
26
|
-
they are in the color mapping options.
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
image (ImagePacket): Image packet to apply the conversion
|
|
30
|
-
desired_color_space (Enum): Color space to convert the image
|
|
31
|
-
|
|
32
|
-
Returns:
|
|
33
|
-
ImagePacket: Updated ImagePacket with content converted into the new color space
|
|
34
|
-
|
|
35
|
-
Raises:
|
|
36
|
-
ValueError: If the conversion is not possible, return an error.
|
|
37
|
-
|
|
38
|
-
"""
|
|
39
|
-
current_color_space = image.color_space
|
|
40
|
-
|
|
41
|
-
if (current_color_space, desired_color_space) in color_mapping:
|
|
42
|
-
conversion_code = color_mapping[(current_color_space, desired_color_space)]
|
|
43
|
-
try:
|
|
44
|
-
image.content = cv2.cvtColor(image.content, conversion_code)
|
|
45
|
-
image.color_space = desired_color_space
|
|
46
|
-
|
|
47
|
-
except cv2.error:
|
|
48
|
-
sinapsis_logger.error(f"Invalid conversion between {current_color_space} and {desired_color_space}")
|
|
49
|
-
|
|
50
|
-
else:
|
|
51
|
-
raise ValueError(f"Conversion from {current_color_space} to {desired_color_space} is not supported.")
|
|
52
|
-
|
|
53
|
-
return image
|
|
File without changes
|
{sinapsis_data_readers-0.1.16.dist-info → sinapsis_data_readers-0.1.19.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{sinapsis_data_readers-0.1.16.dist-info → sinapsis_data_readers-0.1.19.dist-info}/top_level.txt
RENAMED
|
File without changes
|