sinapsis-data-readers 0.1.14__tar.gz → 0.1.16__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.
- {sinapsis_data_readers-0.1.14/src/sinapsis_data_readers.egg-info → sinapsis_data_readers-0.1.16}/PKG-INFO +1 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/pyproject.toml +1 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/sktime_datasets_subset.py +1 -4
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/audio_readers/audio_reader_pydub.py +4 -2
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/audio_readers/audio_reader_soundfile.py +1 -2
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/audio_readers/audio_reader_to_bytes.py +4 -4
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/audio_readers/base_audio_reader.py +8 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/base_file_data_loader.py +5 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/datasets_readers/csv_datasets.py +10 -6
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/image_readers/base_image_folder_data_loader.py +2 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/image_readers/coco_dataset_reader.py +3 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/image_readers/csv_dataset_reader.py +6 -4
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/image_readers/image_folder_reader_cv2.py +0 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/video_readers/base_video_reader.py +3 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/video_readers/video_reader_cv2.py +4 -2
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/video_readers/video_reader_dali.py +4 -4
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/video_readers/video_reader_ffmpeg.py +5 -3
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/video_readers/video_reader_torchcodec.py +4 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16/src/sinapsis_data_readers.egg-info}/PKG-INFO +1 -1
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/LICENSE +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/README.md +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/setup.cfg +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/coco_dataclasses.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/csv_reader.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/file_path_helpers.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/image_color_space_converter.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/sklearn_dataset_subset.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/tags.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/helpers/text_input_helpers.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/audio_readers/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/datasets_readers/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/datasets_readers/dataset_splitter.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/datasets_readers/sklearn_datasets.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/datasets_readers/sktime_datasets.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/image_readers/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/image_readers/image_folder_reader_kornia.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/text_readers/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/text_readers/text_input.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/templates/video_readers/__init__.py +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers.egg-info/SOURCES.txt +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers.egg-info/dependency_links.txt +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers.egg-info/requires.txt +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers.egg-info/top_level.txt +0 -0
- {sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/test_gradio_client.py +0 -0
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
""" Excluded sktime loaders"""
|
|
3
2
|
from typing import Callable
|
|
4
3
|
|
|
5
4
|
from sktime import datasets
|
|
6
5
|
|
|
7
|
-
class_datasets = [
|
|
8
|
-
"Airline",
|
|
9
|
-
"Longley",
|
|
6
|
+
class_datasets = ["Airline","Longley",
|
|
10
7
|
"Lynx",
|
|
11
8
|
"Macroeconomic",
|
|
12
9
|
"ShampooSales",
|
|
@@ -62,7 +62,7 @@ class AudioReaderPydub(_AudioBaseReader):
|
|
|
62
62
|
"""
|
|
63
63
|
|
|
64
64
|
sample_rate_khz: int = 16
|
|
65
|
-
from_bytes: bool =
|
|
65
|
+
from_bytes: bool = False
|
|
66
66
|
audio_reader_format: Literal["wav", "raw", "pcm"] | None = None
|
|
67
67
|
|
|
68
68
|
UIProperties = AudioReaderPydubUIProperties
|
|
@@ -84,7 +84,9 @@ class AudioReaderPydub(_AudioBaseReader):
|
|
|
84
84
|
audio_segment = AudioSegment.from_file(io.BytesIO(audio_bytes))
|
|
85
85
|
|
|
86
86
|
else:
|
|
87
|
-
|
|
87
|
+
|
|
88
|
+
audio_file_path = self.get_full_path()
|
|
89
|
+
#audio_file_path = os.path.join(self.attributes.root_dir, audio_file_path)
|
|
88
90
|
if os.path.exists(audio_file_path):
|
|
89
91
|
audio_segment = AudioSegment.from_file(audio_file_path, format=self.attributes.audio_reader_format)
|
|
90
92
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
from typing import cast
|
|
5
4
|
|
|
6
5
|
import soundfile as sf
|
|
7
6
|
from sinapsis_core.data_containers.data_packet import AudioPacket, DataContainer
|
|
@@ -60,7 +59,7 @@ class AudioReaderSoundfile(_AudioBaseReader):
|
|
|
60
59
|
AudioPacket|None: An AudioPacket containing the audio data and
|
|
61
60
|
sample rate, or None if the file could not be read or was invalid.
|
|
62
61
|
"""
|
|
63
|
-
audio_path =
|
|
62
|
+
audio_path = self.get_full_path()
|
|
64
63
|
if os.path.exists(audio_path):
|
|
65
64
|
try:
|
|
66
65
|
audio_content, sample_rate = sf.read(audio_path)
|
|
@@ -38,19 +38,19 @@ class AudioReaderToBytes(_AudioBaseReader):
|
|
|
38
38
|
FileNotFoundError: If the specified audio file does not exist.
|
|
39
39
|
IOError: If there is an error reading the audio file.
|
|
40
40
|
"""
|
|
41
|
-
|
|
41
|
+
full_path = self.get_full_path()
|
|
42
42
|
try:
|
|
43
|
-
with open(
|
|
43
|
+
with open(full_path, "rb") as audio_file:
|
|
44
44
|
audio_content = audio_file.read()
|
|
45
45
|
|
|
46
46
|
audio_file.close()
|
|
47
47
|
audio_packet = AudioPacket(
|
|
48
|
-
source=
|
|
48
|
+
source=full_path,
|
|
49
49
|
content=audio_content,
|
|
50
50
|
)
|
|
51
51
|
return audio_packet
|
|
52
52
|
except FileNotFoundError:
|
|
53
|
-
self.logger.error(f"Audio file not found: {
|
|
53
|
+
self.logger.error(f"Audio file not found: {full_path}")
|
|
54
54
|
return None
|
|
55
55
|
except IOError as e:
|
|
56
56
|
self.logger.error(f"Error reading audio file: {e}")
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
import abc
|
|
4
|
+
import os
|
|
5
|
+
from typing import cast
|
|
4
6
|
from uuid import uuid4
|
|
5
7
|
|
|
6
8
|
from sinapsis_core.data_containers.data_packet import AudioPacket, DataContainer
|
|
@@ -28,6 +30,8 @@ class _AudioBaseReader(_BaseDataReader):
|
|
|
28
30
|
The source identifier, defaults to "streamlit".
|
|
29
31
|
"""
|
|
30
32
|
|
|
33
|
+
|
|
34
|
+
root_dir: str | None = None
|
|
31
35
|
audio_file_path: str
|
|
32
36
|
source: str = str(uuid4())
|
|
33
37
|
|
|
@@ -42,6 +46,10 @@ class _AudioBaseReader(_BaseDataReader):
|
|
|
42
46
|
Returns:
|
|
43
47
|
AudioPacket: The audio data wrapped in an AudioPacket.
|
|
44
48
|
"""
|
|
49
|
+
def get_full_path(self):
|
|
50
|
+
audio_file_path = cast(str, self.attributes.audio_file_path)
|
|
51
|
+
full_path = os.path.join(self.attributes.root_dir, audio_file_path)
|
|
52
|
+
return full_path
|
|
45
53
|
|
|
46
54
|
def has_elements(self) -> bool:
|
|
47
55
|
"""Flag to indicate if there is still content to process"""
|
|
@@ -8,6 +8,7 @@ from sinapsis_core.template_base.base_models import (
|
|
|
8
8
|
TemplateAttributes,
|
|
9
9
|
TemplateAttributeType,
|
|
10
10
|
)
|
|
11
|
+
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def base_documentation() -> str:
|
|
@@ -80,7 +81,7 @@ class _BaseDataReader(Template, abc.ABC):
|
|
|
80
81
|
__doc__ = f"""
|
|
81
82
|
{base_attributes_documentation()}
|
|
82
83
|
"""
|
|
83
|
-
|
|
84
|
+
root_dir : str | None = None
|
|
84
85
|
data_dir: str
|
|
85
86
|
pattern: str = "**/*"
|
|
86
87
|
batch_size: int = 1
|
|
@@ -93,8 +94,10 @@ class _BaseDataReader(Template, abc.ABC):
|
|
|
93
94
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
94
95
|
super().__init__(attributes)
|
|
95
96
|
self.counter = 0
|
|
97
|
+
self.attributes.root_dir = self.attributes.root_dir or SINAPSIS_CACHE_DIR
|
|
96
98
|
self.data_collection = self.make_data_entries()
|
|
97
99
|
|
|
100
|
+
|
|
98
101
|
@abc.abstractmethod
|
|
99
102
|
def make_data_entries(self) -> list[Packet]:
|
|
100
103
|
"""
|
|
@@ -181,4 +184,5 @@ class _BaseDataReader(Template, abc.ABC):
|
|
|
181
184
|
self.append_packets_to_container(container)
|
|
182
185
|
else:
|
|
183
186
|
self.logger.debug(f"{self.class_name} has no more data to load.")
|
|
187
|
+
|
|
184
188
|
return container
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from sinapsis_core.data_containers.data_packet import DataContainer, TimeSeriesPacket
|
|
3
5
|
from sinapsis_core.template_base.base_models import TemplateAttributes, TemplateAttributeType
|
|
4
6
|
from sinapsis_core.template_base.template import Template
|
|
7
|
+
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
5
8
|
|
|
6
9
|
from sinapsis_data_readers.helpers.csv_reader import read_file
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
class CSVDatasetReader(Template):
|
|
10
13
|
class AttributesBaseModel(TemplateAttributes):
|
|
14
|
+
root_dir : str | None = None
|
|
11
15
|
path_to_csv: str
|
|
12
16
|
store_as_time_series: bool = False
|
|
13
|
-
store_as_text_packet: bool = True
|
|
14
17
|
|
|
15
18
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
16
19
|
super().__init__(attributes)
|
|
17
|
-
self.
|
|
20
|
+
self.attributes.root_dir = self.attributes.root_dir or SINAPSIS_CACHE_DIR
|
|
21
|
+
self.csv_file = read_file(os.path.join(self.attributes.root_dir, self.attributes.path_to_csv))
|
|
18
22
|
|
|
19
23
|
def execute(self, container: DataContainer) -> DataContainer:
|
|
20
24
|
if self.attributes.store_as_time_series:
|
|
21
25
|
packet = TimeSeriesPacket(content=self.csv_file)
|
|
22
26
|
container.time_series.append(packet)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
else:
|
|
28
|
+
self._set_generic_data(container, self.csv_file)
|
|
29
|
+
|
|
26
30
|
return container
|
|
@@ -115,9 +115,10 @@ class ImageBaseDataReader(_BaseDataReader, abc.ABC):
|
|
|
115
115
|
Returns:
|
|
116
116
|
list[str| path]: the path as string or Path object
|
|
117
117
|
"""
|
|
118
|
+
full_path = os.path.join(self.attributes.root_dir, self.attributes.data_dir)
|
|
118
119
|
data_items = [
|
|
119
120
|
img_path if not return_as_str else str(img_path.resolve())
|
|
120
|
-
for img_path in Path(
|
|
121
|
+
for img_path in Path(full_path).glob(self.attributes.pattern)
|
|
121
122
|
if img_path.suffix.lower() in SUPPORTED_IMAGE_TYPES
|
|
122
123
|
]
|
|
123
124
|
|
|
@@ -16,6 +16,7 @@ from sinapsis_core.data_containers.annotations import (
|
|
|
16
16
|
)
|
|
17
17
|
from sinapsis_core.data_containers.data_packet import ImagePacket
|
|
18
18
|
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
19
|
+
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
19
20
|
|
|
20
21
|
from sinapsis_data_readers.helpers.coco_dataclasses import (
|
|
21
22
|
CocoAnnotationsKeys,
|
|
@@ -54,7 +55,8 @@ class CocoImageDatasetBaseCV2(FolderImageDatasetCV2):
|
|
|
54
55
|
annotations_path: str
|
|
55
56
|
|
|
56
57
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
57
|
-
self.annotations_file = os.path.join(attributes.get("
|
|
58
|
+
self.annotations_file = os.path.join(attributes.get("root_dir", SINAPSIS_CACHE_DIR),
|
|
59
|
+
attributes.get("data_dir"), attributes.get("annotations_path"))
|
|
58
60
|
self.raw_annotations_dict: list[dict[str, dict[str, Any]]] = self.read_annotations_file(self.annotations_file)
|
|
59
61
|
self.annotations = self.images_annotations()
|
|
60
62
|
super().__init__(attributes)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import os
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
6
7
|
from sinapsis_core.data_containers.annotations import ImageAnnotations
|
|
@@ -10,6 +11,7 @@ from sinapsis_core.template_base.base_models import (
|
|
|
10
11
|
TemplateAttributeType,
|
|
11
12
|
UIPropertiesMetadata,
|
|
12
13
|
)
|
|
14
|
+
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
13
15
|
|
|
14
16
|
from sinapsis_data_readers.helpers.csv_reader import read_file
|
|
15
17
|
from sinapsis_data_readers.helpers.tags import Tags
|
|
@@ -75,11 +77,11 @@ class CSVImageDataset(_BaseDataReader):
|
|
|
75
77
|
"""
|
|
76
78
|
# Ensure 'data_dir' is available and convert it to string if it's not None
|
|
77
79
|
data_dir = getattr(self.attributes, "data_dir", None)
|
|
78
|
-
|
|
80
|
+
root_dir = getattr(self.attributes, "root_dir", SINAPSIS_CACHE_DIR)
|
|
79
81
|
if data_dir is None:
|
|
80
82
|
raise ValueError("The 'data_dir' attribute cannot be None.")
|
|
81
|
-
|
|
82
|
-
self.data_points = read_file(
|
|
83
|
+
full_path = os.path.join(root_dir, data_dir)
|
|
84
|
+
self.data_points = read_file(full_path)
|
|
83
85
|
super().__init__(attributes)
|
|
84
86
|
|
|
85
87
|
def read_packet_content(self, packet: ImagePacket) -> None:
|
|
@@ -21,7 +21,6 @@ def read_image_file(file_path: str | PosixPath | bytes) -> np.ndarray:
|
|
|
21
21
|
np.ndarray: the image as a numpy array
|
|
22
22
|
"""
|
|
23
23
|
np_image: np.ndarray
|
|
24
|
-
|
|
25
24
|
if isinstance(file_path, bytes):
|
|
26
25
|
image_arr = np.frombuffer(file_path, np.uint8)
|
|
27
26
|
np_image = cv2.imdecode(image_arr, cv2.IMREAD_COLOR)
|
|
@@ -22,6 +22,7 @@ from sinapsis_core.template_base.base_models import (
|
|
|
22
22
|
TemplateAttributeType,
|
|
23
23
|
UIPropertiesMetadata,
|
|
24
24
|
)
|
|
25
|
+
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
25
26
|
|
|
26
27
|
from sinapsis_data_readers.helpers.file_path_helpers import parse_file_paths
|
|
27
28
|
from sinapsis_data_readers.helpers.tags import Tags
|
|
@@ -40,7 +41,7 @@ class BaseVideoReaderAttributes(TemplateAttributes):
|
|
|
40
41
|
device (Literal["cpu", "gpu"]): Device to be used for loading the video. Default is "cpu".
|
|
41
42
|
loop_forever (bool): Whether to loop the video indefinitely. Default is False.
|
|
42
43
|
"""
|
|
43
|
-
|
|
44
|
+
root_dir: str | None = None
|
|
44
45
|
video_file_path: str | list[str]
|
|
45
46
|
batch_size: int = 1
|
|
46
47
|
video_source: int | str | None = str(get_uuid())
|
|
@@ -59,6 +60,7 @@ class BaseVideoReader(Template):
|
|
|
59
60
|
|
|
60
61
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
61
62
|
super().__init__(attributes)
|
|
63
|
+
self.attributes.root_dir = self.attributes.root_dir or SINAPSIS_CACHE_DIR
|
|
62
64
|
self.frame_count = 0
|
|
63
65
|
self.video_reader: Any
|
|
64
66
|
self.total_frames: int
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
import os
|
|
5
|
+
|
|
4
6
|
import cv2
|
|
5
7
|
from sinapsis_core.data_containers.data_packet import ImagePacket
|
|
6
8
|
|
|
@@ -55,8 +57,8 @@ class VideoReaderCV2(BaseVideoReader):
|
|
|
55
57
|
- If successful, returns (video_reader, num_frames),
|
|
56
58
|
where video_reader is the OpenCV VideoCapture object.
|
|
57
59
|
"""
|
|
58
|
-
|
|
59
|
-
video_reader = cv2.VideoCapture(
|
|
60
|
+
full_path = os.path.join(self.attributes.root_dir, self.attributes.video_file_path)
|
|
61
|
+
video_reader = cv2.VideoCapture(full_path)
|
|
60
62
|
num_frames = int(video_reader.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
61
63
|
|
|
62
64
|
if not video_reader.isOpened():
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import os.path
|
|
4
3
|
from typing import Literal, cast
|
|
5
4
|
|
|
6
5
|
import nvidia.dali.fn as fn
|
|
@@ -111,13 +110,13 @@ class VideoReaderDali(BaseVideoReader):
|
|
|
111
110
|
and the number of frames per epoch. If the pipeline cannot be created,
|
|
112
111
|
it returns None and 0.
|
|
113
112
|
"""
|
|
114
|
-
|
|
113
|
+
full_path = os.path.join(self.attributes.root_dir, self.attributes.video_file_path)
|
|
115
114
|
try:
|
|
116
115
|
pipe: Pipeline = video_pipe(
|
|
117
116
|
batch_size=self.attributes.batch_size,
|
|
118
117
|
num_threads=self.attributes.num_threads,
|
|
119
118
|
device_id=0,
|
|
120
|
-
filenames=
|
|
119
|
+
filenames=full_path,
|
|
121
120
|
seed=12345,
|
|
122
121
|
device=self.attributes.device,
|
|
123
122
|
random_shuffle=self.attributes.random_shuffle,
|
|
@@ -154,6 +153,7 @@ class VideoReaderDali(BaseVideoReader):
|
|
|
154
153
|
_ = template_name
|
|
155
154
|
if self.attributes.device == "gpu":
|
|
156
155
|
torch.cuda.empty_cache()
|
|
156
|
+
torch.cuda.ipc_collect()
|
|
157
157
|
super().reset_state(template_name)
|
|
158
158
|
|
|
159
159
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
2
|
+
import os.path
|
|
3
3
|
import subprocess
|
|
4
4
|
|
|
5
5
|
import ffmpeg
|
|
@@ -54,8 +54,9 @@ class VideoReaderFFMPEG(BaseVideoReader):
|
|
|
54
54
|
Returns:
|
|
55
55
|
tuple[int, int, int]: the values for height, width and frames as integers
|
|
56
56
|
"""
|
|
57
|
+
full_path = os.path.join(self.attributes.root_dir, self.attributes.video_file_path)
|
|
57
58
|
try:
|
|
58
|
-
probe = ffmpeg.probe(
|
|
59
|
+
probe = ffmpeg.probe(full_path)
|
|
59
60
|
except ffmpeg.Error as e:
|
|
60
61
|
self.logger.warning("ffmpeg error: %s", str(e))
|
|
61
62
|
return (0, 0, 0)
|
|
@@ -72,8 +73,9 @@ class VideoReaderFFMPEG(BaseVideoReader):
|
|
|
72
73
|
|
|
73
74
|
def make_video_reader(self) -> tuple[subprocess.Popen, int] | NotSetType:
|
|
74
75
|
"""This method asynchronously runs a subprocess to stream the video frames"""
|
|
76
|
+
full_path = os.path.join(self.attributes.root_dir, self.attributes.video_file_path)
|
|
75
77
|
video_reader = (
|
|
76
|
-
ffmpeg.input(
|
|
78
|
+
ffmpeg.input(full_path)
|
|
77
79
|
.output(
|
|
78
80
|
"pipe:",
|
|
79
81
|
format="rawvideo",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+
import os.path
|
|
3
|
+
|
|
2
4
|
import torch
|
|
3
5
|
from sinapsis_core.data_containers.data_packet import ImagePacket
|
|
4
6
|
from torchcodec.decoders import SimpleVideoDecoder
|
|
@@ -56,8 +58,9 @@ class VideoReaderTorchCodec(BaseVideoReader):
|
|
|
56
58
|
Raises:
|
|
57
59
|
ValueError: If there is an issue decoding the video file.
|
|
58
60
|
"""
|
|
61
|
+
full_path = os.path.join(self.attributes.root_dir, self.attributes.video_file_path)
|
|
59
62
|
try:
|
|
60
|
-
video_reader = SimpleVideoDecoder(
|
|
63
|
+
video_reader = SimpleVideoDecoder(full_path)
|
|
61
64
|
except ValueError as e:
|
|
62
65
|
self.logger.warning(f"Was unable to decode video file: {e}")
|
|
63
66
|
return NotSet
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sinapsis_data_readers-0.1.14 → sinapsis_data_readers-0.1.16}/src/sinapsis_data_readers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|