sinapsis-huggingface 0.2.6__py3-none-any.whl → 0.2.8__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_huggingface-0.2.6.dist-info → sinapsis_huggingface-0.2.8.dist-info}/METADATA +1 -1
- {sinapsis_huggingface-0.2.6.dist-info → sinapsis_huggingface-0.2.8.dist-info}/RECORD +10 -11
- sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/base_diffusers.py +2 -0
- sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino.py +5 -2
- sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/base_transformers.py +1 -0
- sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_base.py +12 -1
- sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_inference.py +3 -1
- sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/speaker_embedding_from_dataset.py +0 -93
- {sinapsis_huggingface-0.2.6.dist-info → sinapsis_huggingface-0.2.8.dist-info}/WHEEL +0 -0
- {sinapsis_huggingface-0.2.6.dist-info → sinapsis_huggingface-0.2.8.dist-info}/licenses/LICENSE +0 -0
- {sinapsis_huggingface-0.2.6.dist-info → sinapsis_huggingface-0.2.8.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
sinapsis_huggingface-0.2.
|
|
1
|
+
sinapsis_huggingface-0.2.8.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
2
2
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/helpers/tags.py,sha256=TFmVD7r70vKmpNqSweVGme4riZZiRQWIfxySTexyJp8,522
|
|
5
5
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/__init__.py,sha256=9FHbS4hse9WIE-1a5jJlG-23gB3wahlULANJAWQ464c,947
|
|
6
|
-
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/base_diffusers.py,sha256=
|
|
6
|
+
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/base_diffusers.py,sha256=xQgt6ehlJ5ESNFgqWbMbL31sTCLJwz3zJNNNATooPw4,8745
|
|
7
7
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/image_to_image_diffusers.py,sha256=OYT5fZBzCZoW7WTFi9kpvibGJw8wHTMm_O0eu74CRT4,6595
|
|
8
8
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/image_to_video_gen_xl_diffusers.py,sha256=XVm3HD1WtgteviwrVtvVyzNShKK8G8J5Nb_8iKdf74c,2394
|
|
9
9
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/inpainting_diffusers.py,sha256=9-y2nslRPvUxcx8A7CpYEkERhOHUI2g-VKuK1Zk_sFI,13807
|
|
@@ -14,31 +14,30 @@ sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/helpers/tags
|
|
|
14
14
|
sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/__init__.py,sha256=ihRhuXZAxpilful4Wrfa2n6HVJZqP9sdv3ycNoNuWqM,625
|
|
15
15
|
sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/hugging_face_embedding_extractor.py,sha256=GWExQCefsmSoMK-fIDcdjEt1XlhIqZzsW2fihnoACjg,3587
|
|
16
16
|
sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/speaker_embedding_from_audio.py,sha256=MTCULlf5CG5Jct9atXQG_HcGx7oKzWo9IdUqG0WU4BM,6497
|
|
17
|
-
sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/speaker_embedding_from_dataset.py,sha256=6Px0WUju4IlfFGtTxRVRZQahU-RGX95n_t4L8Q8AqSU,3679
|
|
18
17
|
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
18
|
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
19
|
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/grounding_dino_keys.py,sha256=XacOtRkd099sM64pXg_N0oxtnBCQHgY6N6XAcI4WCzo,791
|
|
21
20
|
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/tags.py,sha256=q_QiumP-iCGLbiV0LOSc-Y4anUASmPwgplhnCXEiuXI,368
|
|
22
21
|
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/__init__.py,sha256=PbNLyfrBTHZOmwF6mNFYLikFWEnVq9s-eFsRjFzIIWk,791
|
|
23
|
-
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino.py,sha256=
|
|
22
|
+
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino.py,sha256=GvU80V7QTk3ZPeGzfcQLIjWVezU9ot98kQ5AXPgsM_E,14379
|
|
24
23
|
sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino_classification.py,sha256=UeOarFsC8z0jg5WtOO9NAvhYnOFpEaLkM75fsGhRiZI,9171
|
|
25
24
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
25
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/__init__.py,sha256=RYEd6xTaVlItleSPoq9RVJIFgXfY6aOHqy2SIO7zwjc,168
|
|
27
26
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/tags.py,sha256=F6zVOBh8mVnl9AG0s_t1ftZ-1Fg1RoO3zgng9PxfLWk,652
|
|
28
27
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/text_to_sentences.py,sha256=teaJXoTAVzGwar9gxenBabkA9VBJd-VAxsNXlzkKMuU,1676
|
|
29
28
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/__init__.py,sha256=3BgUm6C_tRgzxh2ADMBcu6OHzR-U5Tl1eFVtU0PwxB0,1095
|
|
30
|
-
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/base_transformers.py,sha256=
|
|
29
|
+
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/base_transformers.py,sha256=neVmQJdWjmHKud2-rT7fAdOCORwFm-80VdUtkwjY-lU,6126
|
|
31
30
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/image_to_text_transformers.py,sha256=960Yo3GayKwevwFAbVsYhde-70e5oTKbd9r3gji8LCE,2965
|
|
32
31
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/speech_to_text_transformers.py,sha256=upTfDzjJEMN7RiKMPNQ1ecOTnjVONGMNaok4-GGqlO4,2648
|
|
33
32
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/summarization_transformers.py,sha256=jYFN9chcvzGFCSCbHzcDFIHFOvJ9ErzU0q_neY6kZ7Y,2373
|
|
34
33
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/text_to_speech_transformers.py,sha256=L4hYhwNk3bO6GC3Ld1b0gXnQVhH38e3SDrV3lCug-Eo,6214
|
|
35
34
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/translation_transformers.py,sha256=4Rg-wevpjYTn3TBW6ULtV7Y_lapqziWO-RLEOiccktM,2899
|
|
36
|
-
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_base.py,sha256=
|
|
35
|
+
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_base.py,sha256=u4easZKy6arm2wCwwIzoy6e9qrYZT_11-LOa2cMPqXk,4442
|
|
37
36
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_detection.py,sha256=Pur2GwPJshTzh6Fu7CAm2mgG4cutx_cZDMCtOCGvoIw,4134
|
|
38
|
-
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_inference.py,sha256=
|
|
37
|
+
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_inference.py,sha256=lm1YIGi777c3ko4cWOwuoUTzQlRovfN6htIcrmpuHD4,10817
|
|
39
38
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/thirdparty/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
39
|
sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/thirdparty/helpers.py,sha256=IGeYd5U2xpimpwTQW_5xm1pUYB5tqHlpq-fjwBHI4gY,2187
|
|
41
|
-
sinapsis_huggingface-0.2.
|
|
42
|
-
sinapsis_huggingface-0.2.
|
|
43
|
-
sinapsis_huggingface-0.2.
|
|
44
|
-
sinapsis_huggingface-0.2.
|
|
40
|
+
sinapsis_huggingface-0.2.8.dist-info/METADATA,sha256=y5TlDs5TE7n4Zo0AZo1NPp0CzmCwRMKF6sbROaeAp5M,11400
|
|
41
|
+
sinapsis_huggingface-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
42
|
+
sinapsis_huggingface-0.2.8.dist-info/top_level.txt,sha256=ZxHwnMjSWRceQL_6-B7GJBPxQWdlwkba-SYMVufhj5s,133
|
|
43
|
+
sinapsis_huggingface-0.2.8.dist-info/RECORD,,
|
sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/base_diffusers.py
CHANGED
|
@@ -193,8 +193,10 @@ class BaseDiffusers(Template, ABC):
|
|
|
193
193
|
This method performs garbage collection and clears GPU memory (if applicable) to prevent memory leaks
|
|
194
194
|
and ensure efficient resource usage.
|
|
195
195
|
"""
|
|
196
|
+
del self.generator
|
|
196
197
|
if self.attributes.device == "cuda":
|
|
197
198
|
torch.cuda.empty_cache()
|
|
199
|
+
torch.cuda.ipc_collect()
|
|
198
200
|
|
|
199
201
|
def reset_state(self, template_name: str | None = None) -> None:
|
|
200
202
|
self._clear_memory()
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import gc
|
|
4
3
|
from typing import Any, Literal
|
|
5
4
|
|
|
6
5
|
import torch
|
|
@@ -357,8 +356,12 @@ class GroundingDINO(Template):
|
|
|
357
356
|
This method performs garbage collection and clears GPU memory (if applicable) to prevent memory leaks
|
|
358
357
|
and ensure efficient resource usage.
|
|
359
358
|
"""
|
|
359
|
+
for child in self.model.children():
|
|
360
|
+
child.cpu()
|
|
361
|
+
gc.collect()
|
|
360
362
|
if self.attributes.device == "cuda":
|
|
361
363
|
torch.cuda.empty_cache()
|
|
364
|
+
torch.cuda.ipc_collect()
|
|
362
365
|
|
|
363
366
|
def reset_state(self, template_name: str | None = None) -> None:
|
|
364
367
|
self._clear_memory()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+
import gc
|
|
2
3
|
from abc import abstractmethod
|
|
3
4
|
from typing import Any, ClassVar, Literal
|
|
4
5
|
|
|
@@ -104,6 +105,16 @@ class PaliGemmaBase(Template):
|
|
|
104
105
|
"""
|
|
105
106
|
|
|
106
107
|
def reset_state(self, template_name: str | None = None) -> None:
|
|
107
|
-
|
|
108
|
+
with torch.no_grad():
|
|
109
|
+
for child in self.model.children():
|
|
110
|
+
child.cpu()
|
|
111
|
+
del child
|
|
112
|
+
gc.collect()
|
|
113
|
+
del self.model
|
|
114
|
+
|
|
115
|
+
del self.processor
|
|
116
|
+
|
|
108
117
|
torch.cuda.empty_cache()
|
|
118
|
+
torch.cuda.ipc_collect()
|
|
119
|
+
|
|
109
120
|
super().reset_state(template_name)
|
|
@@ -69,6 +69,7 @@ class PaliGemmaInference(PaliGemmaBase):
|
|
|
69
69
|
|
|
70
70
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
71
71
|
super().__init__(attributes)
|
|
72
|
+
self.model = self.model.eval()
|
|
72
73
|
self.prompt = self.attributes.prompt
|
|
73
74
|
|
|
74
75
|
def _prepare_inputs(self, image_content: np.ndarray) -> dict:
|
|
@@ -237,11 +238,12 @@ class PaliGemmaInference(PaliGemmaBase):
|
|
|
237
238
|
Returns:
|
|
238
239
|
DataContainer: Processed container with added annotations
|
|
239
240
|
"""
|
|
241
|
+
self.logger.debug("EXECUTING TEMPLATE")
|
|
240
242
|
if container.texts:
|
|
241
243
|
self.process_from_text_packet(container)
|
|
242
244
|
else:
|
|
243
245
|
self.process_from_prompt(container)
|
|
244
|
-
|
|
246
|
+
self.logger.debug("finished execution")
|
|
245
247
|
return container
|
|
246
248
|
|
|
247
249
|
@staticmethod
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
from typing import Literal
|
|
4
|
-
|
|
5
|
-
from datasets import load_dataset
|
|
6
|
-
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
7
|
-
from sinapsis_core.template_base import Template
|
|
8
|
-
from sinapsis_core.template_base.base_models import OutputTypes, TemplateAttributes, UIPropertiesMetadata
|
|
9
|
-
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class SpeakerEmbeddingFromDatasetAttributes(TemplateAttributes):
|
|
13
|
-
"""Attributes for the SpeakerEmbeddingFromDataset template.
|
|
14
|
-
|
|
15
|
-
Attributes:
|
|
16
|
-
dataset_path (str): Path or name of the Hugging Face dataset containing speaker embeddings.
|
|
17
|
-
For example, `"Matthijs/cmu-arctic-xvectors"`.
|
|
18
|
-
data_cache_dir (str): Directory to cache the downloaded dataset. Defaults to the value of
|
|
19
|
-
the `SINAPSIS_CACHE_DIR` environment variable.
|
|
20
|
-
split (str): Dataset split to use (e.g., "train", "validation", or "test").
|
|
21
|
-
Defaults to `"validation"`.
|
|
22
|
-
sample_idx (int): Index of the dataset sample to extract the embedding from.
|
|
23
|
-
xvector_key (str): Key in the dataset sample that stores the xvector. Defaults to `"xvector"`.
|
|
24
|
-
target_packet (Literal["texts", "audios"]): Type of packet in the `DataContainer` to which
|
|
25
|
-
the embedding will be attached. Must be either `"texts"` or `"audios"`.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
dataset_path: str
|
|
29
|
-
data_cache_dir: str = str(SINAPSIS_CACHE_DIR)
|
|
30
|
-
split: str = "validation"
|
|
31
|
-
sample_idx: int
|
|
32
|
-
xvector_key: str = "xvector"
|
|
33
|
-
target_packet: Literal["texts", "audios"]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class SpeakerEmbeddingFromDataset(Template):
|
|
37
|
-
"""
|
|
38
|
-
Template to retrieve and attach speaker embeddings from a Hugging Face dataset.
|
|
39
|
-
This template extracts a specified embedding (e.g., xvector) from a dataset and attaches
|
|
40
|
-
it to the `embedding` attribute of each `TextPacket` in a `DataContainer`.
|
|
41
|
-
|
|
42
|
-
Usage example:
|
|
43
|
-
|
|
44
|
-
agent:
|
|
45
|
-
name: my_test_agent
|
|
46
|
-
templates:
|
|
47
|
-
- template_name: InputTemplate
|
|
48
|
-
class_name: InputTemplate
|
|
49
|
-
attributes: {}
|
|
50
|
-
- template_name: SpeakerEmbeddingFromDataset
|
|
51
|
-
class_name: SpeakerEmbeddingFromDataset
|
|
52
|
-
template_input: InputTemplate
|
|
53
|
-
attributes:
|
|
54
|
-
dataset_path: '/path/to/hugging/face/dataset'
|
|
55
|
-
data_cache_dir: /path/to/cache/dir
|
|
56
|
-
split: validation
|
|
57
|
-
sample_idx: '1'
|
|
58
|
-
xvector_key: xvector
|
|
59
|
-
target_packet: 'audios'
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"""
|
|
64
|
-
|
|
65
|
-
AttributesBaseModel = SpeakerEmbeddingFromDatasetAttributes
|
|
66
|
-
UIProperties = UIPropertiesMetadata(category="HuggingFace", output_type=OutputTypes.AUDIO)
|
|
67
|
-
|
|
68
|
-
def execute(self, container: DataContainer) -> DataContainer:
|
|
69
|
-
"""Retrieve and attach speaker embeddings to specified packets in a DataContainer.
|
|
70
|
-
|
|
71
|
-
Args:
|
|
72
|
-
container (DataContainer): The container holding the packets to which the embedding will be
|
|
73
|
-
attached.
|
|
74
|
-
|
|
75
|
-
Returns:
|
|
76
|
-
DataContainer: The updated container with embeddings attached to the `embedding`
|
|
77
|
-
attribute of the specified packet type.
|
|
78
|
-
"""
|
|
79
|
-
packets = getattr(container, self.attributes.target_packet)
|
|
80
|
-
embeddings_dataset = load_dataset(
|
|
81
|
-
self.attributes.dataset_path,
|
|
82
|
-
split=self.attributes.split,
|
|
83
|
-
cache_dir=self.attributes.data_cache_dir,
|
|
84
|
-
)
|
|
85
|
-
speaker_embedding = embeddings_dataset[self.attributes.sample_idx][self.attributes.xvector_key]
|
|
86
|
-
self.logger.info(
|
|
87
|
-
f"Attaching embedding from index {self.attributes.sample_idx} to "
|
|
88
|
-
f"{len(packets)} {self.attributes.target_packet} packets."
|
|
89
|
-
)
|
|
90
|
-
for packet in packets:
|
|
91
|
-
packet.embedding = speaker_embedding
|
|
92
|
-
|
|
93
|
-
return container
|
|
File without changes
|
{sinapsis_huggingface-0.2.6.dist-info → sinapsis_huggingface-0.2.8.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|