sinapsis-huggingface 0.2.3__tar.gz → 0.2.6__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_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/PKG-INFO +1 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface.egg-info/PKG-INFO +1 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface.egg-info/SOURCES.txt +6 -0
- sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/helpers/tags.py +21 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/base_diffusers.py +11 -3
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/image_to_image_diffusers.py +6 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/image_to_video_gen_xl_diffusers.py +5 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/inpainting_diffusers.py +5 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/text_to_image_diffusers.py +6 -0
- sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/helpers/tags.py +13 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/__init__.py +0 -2
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/hugging_face_embedding_extractor.py +7 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/speaker_embedding_from_audio.py +15 -4
- sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/tags.py +15 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino.py +27 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino_classification.py +5 -0
- sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/__init__.py +0 -0
- sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/tags.py +24 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/base_transformers.py +11 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/image_to_text_transformers.py +7 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_base.py +11 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_inference.py +5 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/speech_to_text_transformers.py +18 -11
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/summarization_transformers.py +7 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/text_to_speech_transformers.py +7 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/translation_transformers.py +7 -1
- sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/thirdparty/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/pyproject.toml +1 -1
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/LICENSE +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/README.md +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface.egg-info/dependency_links.txt +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface.egg-info/requires.txt +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface.egg-info/top_level.txt +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings → sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/helpers}/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino → sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings}/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino → sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings}/helpers/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/speaker_embedding_from_dataset.py +0 -0
- {sinapsis_huggingface-0.2.3/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers → sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino}/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/thirdparty → sinapsis_huggingface-0.2.6/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers}/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/grounding_dino_keys.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/text_to_sentences.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/__init__.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/pali_gemma/pali_gemma_detection.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/thirdparty/helpers.py +0 -0
- {sinapsis_huggingface-0.2.3 → sinapsis_huggingface-0.2.6}/setup.cfg +0 -0
|
@@ -7,6 +7,8 @@ packages/sinapsis_huggingface.egg-info/dependency_links.txt
|
|
|
7
7
|
packages/sinapsis_huggingface.egg-info/requires.txt
|
|
8
8
|
packages/sinapsis_huggingface.egg-info/top_level.txt
|
|
9
9
|
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/__init__.py
|
|
10
|
+
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/helpers/__init__.py
|
|
11
|
+
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/helpers/tags.py
|
|
10
12
|
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/__init__.py
|
|
11
13
|
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/base_diffusers.py
|
|
12
14
|
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/image_to_image_diffusers.py
|
|
@@ -14,6 +16,8 @@ packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templ
|
|
|
14
16
|
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/inpainting_diffusers.py
|
|
15
17
|
packages/sinapsis_huggingface_diffusers/src/sinapsis_huggingface_diffusers/templates/text_to_image_diffusers.py
|
|
16
18
|
packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/__init__.py
|
|
19
|
+
packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/helpers/__init__.py
|
|
20
|
+
packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/helpers/tags.py
|
|
17
21
|
packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/__init__.py
|
|
18
22
|
packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/hugging_face_embedding_extractor.py
|
|
19
23
|
packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/templates/speaker_embedding_from_audio.py
|
|
@@ -21,11 +25,13 @@ packages/sinapsis_huggingface_embeddings/src/sinapsis_huggingface_embeddings/tem
|
|
|
21
25
|
packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/__init__.py
|
|
22
26
|
packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/__init__.py
|
|
23
27
|
packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/grounding_dino_keys.py
|
|
28
|
+
packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/helpers/tags.py
|
|
24
29
|
packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/__init__.py
|
|
25
30
|
packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino.py
|
|
26
31
|
packages/sinapsis_huggingface_grounding_dino/src/sinapsis_huggingface_grounding_dino/templates/grounding_dino_classification.py
|
|
27
32
|
packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/__init__.py
|
|
28
33
|
packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/__init__.py
|
|
34
|
+
packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/tags.py
|
|
29
35
|
packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/helpers/text_to_sentences.py
|
|
30
36
|
packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/__init__.py
|
|
31
37
|
packages/sinapsis_huggingface_transformers/src/sinapsis_huggingface_transformers/templates/base_transformers.py
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Tags(Enum):
|
|
6
|
+
BBOX = "bbox"
|
|
7
|
+
DIFFUSERS = "diffusers"
|
|
8
|
+
GENERATIVE = "generative"
|
|
9
|
+
HUGGINGFACE = "huggingface"
|
|
10
|
+
IMAGE = "image"
|
|
11
|
+
IMAGE_TO_IMAGE = "image_to_image"
|
|
12
|
+
IMAGE_TO_VIDEO = "image_to_video"
|
|
13
|
+
IMAGE_GENERATION = "image_generation"
|
|
14
|
+
INPAINTING = "inpainting"
|
|
15
|
+
MASK = "mask"
|
|
16
|
+
MODELS = "models"
|
|
17
|
+
PROMPTS = "prompts"
|
|
18
|
+
TEXT = "text"
|
|
19
|
+
TEXT_TO_IMAGE = "text_to_image"
|
|
20
|
+
VIDEO = "video"
|
|
21
|
+
VIDEO_GENERATION = "video_generation"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
|
-
import gc
|
|
4
3
|
from abc import ABC, abstractmethod
|
|
5
4
|
from typing import Any, Literal
|
|
6
5
|
|
|
@@ -18,6 +17,8 @@ from sinapsis_core.template_base.base_models import (
|
|
|
18
17
|
)
|
|
19
18
|
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
20
19
|
|
|
20
|
+
from sinapsis_huggingface_diffusers.helpers.tags import Tags
|
|
21
|
+
|
|
21
22
|
|
|
22
23
|
class BaseDiffusersAttributes(TemplateAttributes):
|
|
23
24
|
"""Configuration attributes for setting up a diffusion pipeline and generating images.
|
|
@@ -66,7 +67,11 @@ class BaseDiffusers(Template, ABC):
|
|
|
66
67
|
"""
|
|
67
68
|
|
|
68
69
|
AttributesBaseModel = BaseDiffusersAttributes
|
|
69
|
-
UIProperties = UIPropertiesMetadata(
|
|
70
|
+
UIProperties = UIPropertiesMetadata(
|
|
71
|
+
category="HuggingFace",
|
|
72
|
+
output_type=OutputTypes.IMAGE,
|
|
73
|
+
tags=[Tags.HUGGINGFACE, Tags.DIFFUSERS, Tags.MODELS, Tags.GENERATIVE],
|
|
74
|
+
)
|
|
70
75
|
TORCH_DTYPE: dict = TorchTypes().model_dump()
|
|
71
76
|
|
|
72
77
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
@@ -188,6 +193,9 @@ class BaseDiffusers(Template, ABC):
|
|
|
188
193
|
This method performs garbage collection and clears GPU memory (if applicable) to prevent memory leaks
|
|
189
194
|
and ensure efficient resource usage.
|
|
190
195
|
"""
|
|
191
|
-
gc.collect()
|
|
192
196
|
if self.attributes.device == "cuda":
|
|
193
197
|
torch.cuda.empty_cache()
|
|
198
|
+
|
|
199
|
+
def reset_state(self, template_name: str | None = None) -> None:
|
|
200
|
+
self._clear_memory()
|
|
201
|
+
super().reset_state(template_name)
|
|
@@ -10,8 +10,12 @@ from PIL import Image
|
|
|
10
10
|
from sinapsis_core.data_containers.data_packet import DataContainer, ImagePacket
|
|
11
11
|
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
12
12
|
|
|
13
|
+
from sinapsis_huggingface_diffusers.helpers.tags import Tags
|
|
13
14
|
from sinapsis_huggingface_diffusers.templates.base_diffusers import BaseDiffusers
|
|
14
15
|
|
|
16
|
+
ImageToImageDiffusersUIProperties = BaseDiffusers.UIProperties
|
|
17
|
+
ImageToImageDiffusersUIProperties.tags.extend([Tags.IMAGE, Tags.IMAGE_GENERATION, Tags.IMAGE_TO_IMAGE])
|
|
18
|
+
|
|
15
19
|
|
|
16
20
|
class ImageToImageDiffusers(BaseDiffusers):
|
|
17
21
|
"""Template for the image-to-image generative task using diffusers.
|
|
@@ -46,6 +50,8 @@ class ImageToImageDiffusers(BaseDiffusers):
|
|
|
46
50
|
|
|
47
51
|
"""
|
|
48
52
|
|
|
53
|
+
UIProperties = ImageToImageDiffusersUIProperties
|
|
54
|
+
|
|
49
55
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
50
56
|
super().__init__(attributes)
|
|
51
57
|
self.requires_pil = False
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
from diffusers import I2VGenXLPipeline
|
|
4
4
|
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
5
5
|
|
|
6
|
+
from sinapsis_huggingface_diffusers.helpers.tags import Tags
|
|
6
7
|
from sinapsis_huggingface_diffusers.templates.image_to_image_diffusers import (
|
|
7
8
|
ImageToImageDiffusers,
|
|
8
9
|
)
|
|
9
10
|
|
|
11
|
+
ImageToVideoGenXLDiffusersUIProperties = ImageToImageDiffusers.UIProperties
|
|
12
|
+
ImageToVideoGenXLDiffusersUIProperties.tags.extend([Tags.VIDEO, Tags.IMAGE_TO_VIDEO])
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class ImageToVideoGenXLDiffusers(ImageToImageDiffusers):
|
|
12
16
|
"""This class implements a specific template for image-to-video generation using Hugging Face's
|
|
@@ -38,6 +42,7 @@ class ImageToVideoGenXLDiffusers(ImageToImageDiffusers):
|
|
|
38
42
|
|
|
39
43
|
"""
|
|
40
44
|
|
|
45
|
+
UIProperties = ImageToVideoGenXLDiffusersUIProperties
|
|
41
46
|
DEFAULT_NUM_FRAMES = 16
|
|
42
47
|
|
|
43
48
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
@@ -9,6 +9,7 @@ from diffusers import AutoPipelineForInpainting
|
|
|
9
9
|
from sinapsis_core.data_containers.data_packet import ImageAnnotations, ImagePacket
|
|
10
10
|
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
11
11
|
|
|
12
|
+
from sinapsis_huggingface_diffusers.helpers.tags import Tags
|
|
12
13
|
from sinapsis_huggingface_diffusers.templates.base_diffusers import (
|
|
13
14
|
BaseDiffusersAttributes,
|
|
14
15
|
)
|
|
@@ -16,6 +17,9 @@ from sinapsis_huggingface_diffusers.templates.image_to_image_diffusers import (
|
|
|
16
17
|
ImageToImageDiffusers,
|
|
17
18
|
)
|
|
18
19
|
|
|
20
|
+
InpaintingDiffusersUIProperties = ImageToImageDiffusers.UIProperties
|
|
21
|
+
InpaintingDiffusersUIProperties.tags.extend([Tags.INPAINTING, Tags.BBOX, Tags.MASK])
|
|
22
|
+
|
|
19
23
|
|
|
20
24
|
class InpaintingDiffusersAttributes(BaseDiffusersAttributes):
|
|
21
25
|
"""Attributes specific to the InpaintingDiffusers template.
|
|
@@ -68,6 +72,7 @@ class InpaintingDiffusers(ImageToImageDiffusers):
|
|
|
68
72
|
|
|
69
73
|
"""
|
|
70
74
|
|
|
75
|
+
UIProperties = InpaintingDiffusersUIProperties
|
|
71
76
|
AttributesBaseModel = InpaintingDiffusersAttributes
|
|
72
77
|
|
|
73
78
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
from diffusers import AutoPipelineForText2Image
|
|
4
4
|
from sinapsis_core.data_containers.data_packet import DataContainer, ImagePacket
|
|
5
5
|
|
|
6
|
+
from sinapsis_huggingface_diffusers.helpers.tags import Tags
|
|
6
7
|
from sinapsis_huggingface_diffusers.templates.base_diffusers import BaseDiffusers
|
|
7
8
|
|
|
9
|
+
TextToImageDiffusersUIProperties = BaseDiffusers.UIProperties
|
|
10
|
+
TextToImageDiffusersUIProperties.tags.extend([Tags.TEXT, Tags.TEXT_TO_IMAGE, Tags.PROMPTS])
|
|
11
|
+
|
|
8
12
|
|
|
9
13
|
class TextToImageDiffusers(BaseDiffusers):
|
|
10
14
|
"""This class implements a specific template for text-to-image generation using Hugging Face's
|
|
@@ -34,6 +38,8 @@ class TextToImageDiffusers(BaseDiffusers):
|
|
|
34
38
|
generation_params: {}
|
|
35
39
|
"""
|
|
36
40
|
|
|
41
|
+
UIProperties = TextToImageDiffusersUIProperties
|
|
42
|
+
|
|
37
43
|
@staticmethod
|
|
38
44
|
def _pipeline_class() -> AutoPipelineForText2Image:
|
|
39
45
|
"""Returns the `AutoPipelineForText2Image` class to be used for text-to-image generation.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Tags(Enum):
|
|
6
|
+
AUDIO = "audio"
|
|
7
|
+
DATASET = "dataset"
|
|
8
|
+
EMBEDDINGS = "embeddings"
|
|
9
|
+
EXTRACTOR = "extractor"
|
|
10
|
+
HUGGINGFACE = "huggingface"
|
|
11
|
+
MODELS = "models"
|
|
12
|
+
SPEAKER_EMBEDDING = "speaker_embedding"
|
|
13
|
+
TEXT = "text"
|
|
@@ -5,10 +5,8 @@ from typing import Callable
|
|
|
5
5
|
_root_lib_path = "sinapsis_huggingface_embeddings.templates"
|
|
6
6
|
|
|
7
7
|
_template_lookup = {
|
|
8
|
-
"HuggingFaceEmbeddingNodeGenerator": f"{_root_lib_path}.embedding_node_generator",
|
|
9
8
|
"HuggingFaceEmbeddingExtractor": f"{_root_lib_path}.hugging_face_embedding_extractor",
|
|
10
9
|
"SpeakerEmbeddingFromAudio": f"{_root_lib_path}.speaker_embedding_from_audio",
|
|
11
|
-
"SpeakerEmbeddingFromDataset": f"{_root_lib_path}.speaker_embedding_from_dataset",
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
|
|
@@ -12,6 +12,8 @@ from sinapsis_core.template_base.base_models import (
|
|
|
12
12
|
UIPropertiesMetadata,
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
+
from sinapsis_huggingface_embeddings.helpers.tags import Tags
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
class HuggingFaceEmbeddingExtractorAttributes(TemplateAttributes):
|
|
17
19
|
"""
|
|
@@ -46,7 +48,11 @@ class HuggingFaceEmbeddingExtractor(Template):
|
|
|
46
48
|
"""
|
|
47
49
|
|
|
48
50
|
AttributesBaseModel = HuggingFaceEmbeddingExtractorAttributes
|
|
49
|
-
UIProperties = UIPropertiesMetadata(
|
|
51
|
+
UIProperties = UIPropertiesMetadata(
|
|
52
|
+
category="HuggingFace",
|
|
53
|
+
output_type=OutputTypes.TEXT,
|
|
54
|
+
tags=[Tags.TEXT, Tags.EXTRACTOR, Tags.TEXT, Tags.HUGGINGFACE, Tags.MODELS],
|
|
55
|
+
)
|
|
50
56
|
|
|
51
57
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
52
58
|
super().__init__(attributes)
|
|
@@ -9,10 +9,17 @@ import torch.nn.functional as F
|
|
|
9
9
|
import torchaudio
|
|
10
10
|
from sinapsis_core.data_containers.data_packet import AudioPacket, DataContainer
|
|
11
11
|
from sinapsis_core.template_base import Template
|
|
12
|
-
from sinapsis_core.template_base.base_models import
|
|
12
|
+
from sinapsis_core.template_base.base_models import (
|
|
13
|
+
OutputTypes,
|
|
14
|
+
TemplateAttributes,
|
|
15
|
+
TemplateAttributeType,
|
|
16
|
+
UIPropertiesMetadata,
|
|
17
|
+
)
|
|
13
18
|
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
14
19
|
from speechbrain.inference.speaker import EncoderClassifier
|
|
15
20
|
|
|
21
|
+
from sinapsis_huggingface_embeddings.helpers.tags import Tags
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
class SpeakerEmbeddingFromAudioAttributes(TemplateAttributes):
|
|
18
25
|
"""Attributes for SpeakerEmbeddingFromAudio template.
|
|
@@ -63,7 +70,11 @@ class SpeakerEmbeddingFromAudio(Template):
|
|
|
63
70
|
"""
|
|
64
71
|
|
|
65
72
|
AttributesBaseModel = SpeakerEmbeddingFromAudioAttributes
|
|
66
|
-
|
|
73
|
+
UIProperties = UIPropertiesMetadata(
|
|
74
|
+
category="HuggingFace",
|
|
75
|
+
output_type=OutputTypes.AUDIO,
|
|
76
|
+
tags=[Tags.EMBEDDINGS, Tags.HUGGINGFACE, Tags.MODELS, Tags.AUDIO, Tags.SPEAKER_EMBEDDING],
|
|
77
|
+
)
|
|
67
78
|
|
|
68
79
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
69
80
|
super().__init__(attributes)
|
|
@@ -134,8 +145,8 @@ class SpeakerEmbeddingFromAudio(Template):
|
|
|
134
145
|
packets.
|
|
135
146
|
"""
|
|
136
147
|
if not container.audios:
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
self.logger.debug("No audio packets found in the container.")
|
|
149
|
+
return container
|
|
139
150
|
embeddings = [
|
|
140
151
|
self._postprocess_speaker_embedding(
|
|
141
152
|
self.classifier.encode_batch(self._process_audio(audio_packet), normalize=self.attributes.normalize)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Tags(Enum):
|
|
6
|
+
ANNOTATIONS = "annotations"
|
|
7
|
+
CLASSIFICATION = "classification"
|
|
8
|
+
CLASSIFIER = "classifier"
|
|
9
|
+
GROUNDING_DINO = "grounding_dino"
|
|
10
|
+
HUGGINGFACE = "huggingface"
|
|
11
|
+
IMAGE = "image"
|
|
12
|
+
INFERENCE = "inference"
|
|
13
|
+
MODELS = "models"
|
|
14
|
+
TRANSFORMERS = "transformers"
|
|
15
|
+
ZERO_SHOT = "zero_shot"
|
|
@@ -22,6 +22,7 @@ from transformers import (
|
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
from sinapsis_huggingface_grounding_dino.helpers.grounding_dino_keys import GroundingDINOKeys
|
|
25
|
+
from sinapsis_huggingface_grounding_dino.helpers.tags import Tags
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
class GroundingBaseAttributes(TemplateAttributes):
|
|
@@ -80,7 +81,19 @@ class GroundingDINO(Template):
|
|
|
80
81
|
|
|
81
82
|
"""
|
|
82
83
|
|
|
83
|
-
UIProperties = UIPropertiesMetadata(
|
|
84
|
+
UIProperties = UIPropertiesMetadata(
|
|
85
|
+
category="HuggingFace",
|
|
86
|
+
output_type=OutputTypes.IMAGE,
|
|
87
|
+
tags=[
|
|
88
|
+
Tags.ANNOTATIONS,
|
|
89
|
+
Tags.GROUNDING_DINO,
|
|
90
|
+
Tags.HUGGINGFACE,
|
|
91
|
+
Tags.IMAGE,
|
|
92
|
+
Tags.INFERENCE,
|
|
93
|
+
Tags.MODELS,
|
|
94
|
+
Tags.TRANSFORMERS,
|
|
95
|
+
],
|
|
96
|
+
)
|
|
84
97
|
KEYS = GroundingDINOKeys()
|
|
85
98
|
|
|
86
99
|
class AttributesBaseModel(GroundingBaseAttributes):
|
|
@@ -337,3 +350,16 @@ class GroundingDINO(Template):
|
|
|
337
350
|
self._process_image_packet(image_packet)
|
|
338
351
|
|
|
339
352
|
return container
|
|
353
|
+
|
|
354
|
+
def _clear_memory(self) -> None:
|
|
355
|
+
"""Clears memory to free up resources.
|
|
356
|
+
|
|
357
|
+
This method performs garbage collection and clears GPU memory (if applicable) to prevent memory leaks
|
|
358
|
+
and ensure efficient resource usage.
|
|
359
|
+
"""
|
|
360
|
+
if self.attributes.device == "cuda":
|
|
361
|
+
torch.cuda.empty_cache()
|
|
362
|
+
|
|
363
|
+
def reset_state(self, template_name: str | None = None) -> None:
|
|
364
|
+
self._clear_memory()
|
|
365
|
+
super().reset_state(template_name)
|
|
@@ -5,8 +5,12 @@ from typing import Any
|
|
|
5
5
|
from sinapsis_core.data_containers.annotations import ImageAnnotations
|
|
6
6
|
from sinapsis_core.data_containers.data_packet import ImagePacket
|
|
7
7
|
|
|
8
|
+
from sinapsis_huggingface_grounding_dino.helpers.tags import Tags
|
|
8
9
|
from sinapsis_huggingface_grounding_dino.templates.grounding_dino import GroundingBaseAttributes, GroundingDINO
|
|
9
10
|
|
|
11
|
+
GroundingDINOClassificationUIProperties = GroundingDINO.UIProperties
|
|
12
|
+
GroundingDINOClassificationUIProperties.tags.extend([Tags.CLASSIFICATION, Tags.CLASSIFIER, Tags.ZERO_SHOT])
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class GroundingDINOClassificationAttributes(GroundingBaseAttributes):
|
|
12
16
|
"""Attributes for GroundingDINO Classification.
|
|
@@ -56,6 +60,7 @@ class GroundingDINOClassification(GroundingDINO):
|
|
|
56
60
|
"""
|
|
57
61
|
|
|
58
62
|
AttributesBaseModel = GroundingDINOClassificationAttributes
|
|
63
|
+
UIProperties = GroundingDINOClassificationUIProperties
|
|
59
64
|
|
|
60
65
|
def validate_and_format_text_input(self, text_input: str) -> str:
|
|
61
66
|
"""Validates and formats the text input for consistency.
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Tags(Enum):
|
|
6
|
+
AUDIO = "audio"
|
|
7
|
+
CAPTION_GENERATION = "caption_generation"
|
|
8
|
+
HUGGINGFACE = "huggingface"
|
|
9
|
+
IMAGE = "image"
|
|
10
|
+
IMAGE_TO_TEXT = "image_to_text"
|
|
11
|
+
INFERENCE = "inference"
|
|
12
|
+
LANGUAGE = "language"
|
|
13
|
+
MODELS = "models"
|
|
14
|
+
OBJECT_DETECTION = "object_detection"
|
|
15
|
+
PALIGEMMA = "paligemma"
|
|
16
|
+
PROMPT = "prompt"
|
|
17
|
+
SPEECH = "speech"
|
|
18
|
+
SPEECH_RECOGNITION = "speech_recognition"
|
|
19
|
+
SPEECH_TO_TEXT = "speech_to_text"
|
|
20
|
+
SUMMARIZATION = "summarization"
|
|
21
|
+
TEXT = "text"
|
|
22
|
+
TEXT_TO_SPEECH = "text_to_speech"
|
|
23
|
+
TRANSFORMERS = "transformers"
|
|
24
|
+
TRANSLATION = "translation"
|
|
@@ -13,6 +13,8 @@ from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
|
13
13
|
from transformers import AutoProcessor, pipeline
|
|
14
14
|
from transformers.pipelines import Pipeline
|
|
15
15
|
|
|
16
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
17
|
+
|
|
16
18
|
|
|
17
19
|
class TransformersBaseAttributes(TemplateAttributes):
|
|
18
20
|
"""Attributes for configuring the TransformersPipelineTemplate.
|
|
@@ -53,7 +55,10 @@ class TransformersBase(Template):
|
|
|
53
55
|
"""
|
|
54
56
|
|
|
55
57
|
AttributesBaseModel = TransformersBaseAttributes
|
|
56
|
-
UIProperties = UIPropertiesMetadata(
|
|
58
|
+
UIProperties = UIPropertiesMetadata(
|
|
59
|
+
category="Transformers",
|
|
60
|
+
tags=[Tags.HUGGINGFACE, Tags.TRANSFORMERS, Tags.MODELS],
|
|
61
|
+
)
|
|
57
62
|
|
|
58
63
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
59
64
|
super().__init__(attributes)
|
|
@@ -140,3 +145,8 @@ class TransformersBase(Template):
|
|
|
140
145
|
"""
|
|
141
146
|
transformed_data_container = self.transformation_method(container)
|
|
142
147
|
return transformed_data_container
|
|
148
|
+
|
|
149
|
+
def reset_state(self, template_name: str | None = None) -> None:
|
|
150
|
+
if self.attributes.device == "cuda":
|
|
151
|
+
torch.cuda.empty_cache()
|
|
152
|
+
super().reset_state(template_name)
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
from PIL import Image
|
|
5
5
|
from sinapsis_core.data_containers.data_packet import DataContainer, TextPacket
|
|
6
|
-
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
6
|
+
from sinapsis_core.template_base.base_models import OutputTypes, TemplateAttributeType
|
|
7
7
|
|
|
8
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
8
9
|
from sinapsis_huggingface_transformers.templates.base_transformers import TransformersBase
|
|
9
10
|
|
|
11
|
+
ImageToTextTransformersUIProperties = TransformersBase.UIProperties
|
|
12
|
+
ImageToTextTransformersUIProperties.output_type = OutputTypes.TEXT
|
|
13
|
+
ImageToTextTransformersUIProperties.tags.extend([Tags.IMAGE, Tags.TEXT, Tags.IMAGE_TO_TEXT])
|
|
14
|
+
|
|
10
15
|
|
|
11
16
|
class ImageToTextTransformers(TransformersBase):
|
|
12
17
|
"""
|
|
@@ -34,6 +39,7 @@ class ImageToTextTransformers(TransformersBase):
|
|
|
34
39
|
"""
|
|
35
40
|
|
|
36
41
|
GENERATED_TEXT_KEY = "generated_text"
|
|
42
|
+
UIProperties = ImageToTextTransformersUIProperties
|
|
37
43
|
|
|
38
44
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
39
45
|
super().__init__(attributes)
|
|
@@ -12,6 +12,7 @@ from sinapsis_core.template_base.base_models import (
|
|
|
12
12
|
UIPropertiesMetadata,
|
|
13
13
|
)
|
|
14
14
|
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
15
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
15
16
|
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
|
|
16
17
|
|
|
17
18
|
|
|
@@ -43,7 +44,11 @@ class PaliGemmaBase(Template):
|
|
|
43
44
|
"""Base class for PaliGemma implementations."""
|
|
44
45
|
|
|
45
46
|
AttributesBaseModel = PaliGemmaBaseAttributes
|
|
46
|
-
UIProperties = UIPropertiesMetadata(
|
|
47
|
+
UIProperties = UIPropertiesMetadata(
|
|
48
|
+
category="HuggingFace",
|
|
49
|
+
output_type=OutputTypes.IMAGE,
|
|
50
|
+
tags=[Tags.HUGGINGFACE, Tags.IMAGE, Tags.PALIGEMMA, Tags.MODELS],
|
|
51
|
+
)
|
|
47
52
|
_TORCH_DTYPE: ClassVar[dict[str, Any]] = {"float16": torch.float16, "float32": torch.float32}
|
|
48
53
|
|
|
49
54
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
@@ -97,3 +102,8 @@ class PaliGemmaBase(Template):
|
|
|
97
102
|
Returns:
|
|
98
103
|
DataContainer: The processed container with model outputs.
|
|
99
104
|
"""
|
|
105
|
+
|
|
106
|
+
def reset_state(self, template_name: str | None = None) -> None:
|
|
107
|
+
if self.attributes.device == "cuda":
|
|
108
|
+
torch.cuda.empty_cache()
|
|
109
|
+
super().reset_state(template_name)
|
|
@@ -5,12 +5,16 @@ from sinapsis_core.data_containers.annotations import BoundingBox, ImageAnnotati
|
|
|
5
5
|
from sinapsis_core.data_containers.data_packet import DataContainer, ImagePacket
|
|
6
6
|
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
7
7
|
from sinapsis_data_visualization.helpers.detection_utils import bbox_xyxy_to_xywh
|
|
8
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
8
9
|
from sinapsis_huggingface_transformers.templates.pali_gemma.pali_gemma_base import (
|
|
9
10
|
PaliGemmaBase,
|
|
10
11
|
PaliGemmaBaseAttributes,
|
|
11
12
|
)
|
|
12
13
|
from transformers.generation.utils import GenerateOutput
|
|
13
14
|
|
|
15
|
+
PaliGemmaInferenceUIProperties = PaliGemmaBase.UIProperties
|
|
16
|
+
PaliGemmaInferenceUIProperties.tags.extend([Tags.CAPTION_GENERATION, Tags.OBJECT_DETECTION, Tags.INFERENCE])
|
|
17
|
+
|
|
14
18
|
|
|
15
19
|
class PaliGemmaInferenceAttributes(PaliGemmaBaseAttributes):
|
|
16
20
|
"""Configuration attributes for PaliGemma inference.
|
|
@@ -61,6 +65,7 @@ class PaliGemmaInference(PaliGemmaBase):
|
|
|
61
65
|
|
|
62
66
|
AttributesBaseModel = PaliGemmaInferenceAttributes
|
|
63
67
|
INPUT_IDS = "input_ids"
|
|
68
|
+
UIProperties = PaliGemmaInferenceUIProperties
|
|
64
69
|
|
|
65
70
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
66
71
|
super().__init__(attributes)
|
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
from sinapsis_core.data_containers.data_packet import DataContainer, TextPacket
|
|
5
|
-
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
5
|
+
from sinapsis_core.template_base.base_models import OutputTypes, TemplateAttributeType
|
|
6
6
|
|
|
7
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
7
8
|
from sinapsis_huggingface_transformers.templates.base_transformers import TransformersBase
|
|
8
9
|
|
|
10
|
+
SpeechToTextTransformersUIProperties = TransformersBase.UIProperties
|
|
11
|
+
SpeechToTextTransformersUIProperties.output_type = OutputTypes.TEXT
|
|
12
|
+
SpeechToTextTransformersUIProperties.tags.extend(
|
|
13
|
+
[Tags.SPEECH, Tags.SPEECH_TO_TEXT, Tags.AUDIO, Tags.SPEECH_RECOGNITION, Tags.TEXT]
|
|
14
|
+
)
|
|
15
|
+
|
|
9
16
|
|
|
10
17
|
class SpeechToTextTransformers(TransformersBase):
|
|
11
18
|
"""
|
|
@@ -35,6 +42,7 @@ class SpeechToTextTransformers(TransformersBase):
|
|
|
35
42
|
"""
|
|
36
43
|
|
|
37
44
|
TEXT_KEY = "text"
|
|
45
|
+
UIProperties = SpeechToTextTransformersUIProperties
|
|
38
46
|
|
|
39
47
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
40
48
|
super().__init__(attributes)
|
|
@@ -51,14 +59,13 @@ class SpeechToTextTransformers(TransformersBase):
|
|
|
51
59
|
DataContainer: DataContainer including the transcribed audio.
|
|
52
60
|
"""
|
|
53
61
|
for audio_packet in container.audios:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
container.texts.append(transcribed_text_textpacket)
|
|
62
|
+
audio = audio_packet.content
|
|
63
|
+
audio = audio.astype(np.float32)
|
|
64
|
+
transcribed_text = self.pipeline(audio, **self.attributes.inference_kwargs)[self.TEXT_KEY]
|
|
65
|
+
transcribed_text_textpacket = TextPacket(
|
|
66
|
+
content=transcribed_text,
|
|
67
|
+
source=audio_packet.source,
|
|
68
|
+
)
|
|
69
|
+
self.logger.info(f"Speech-to-text transcription: {transcribed_text}")
|
|
70
|
+
container.texts.append(transcribed_text_textpacket)
|
|
64
71
|
return container
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
4
|
-
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
4
|
+
from sinapsis_core.template_base.base_models import OutputTypes, TemplateAttributeType
|
|
5
5
|
|
|
6
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
6
7
|
from sinapsis_huggingface_transformers.templates.base_transformers import TransformersBase
|
|
7
8
|
|
|
9
|
+
SummarizationTransformersUIProperties = TransformersBase.UIProperties
|
|
10
|
+
SummarizationTransformersUIProperties.output_type = OutputTypes.TEXT
|
|
11
|
+
SummarizationTransformersUIProperties.tags.extend([Tags.SUMMARIZATION, Tags.TEXT])
|
|
12
|
+
|
|
8
13
|
|
|
9
14
|
class SummarizationTransformers(TransformersBase):
|
|
10
15
|
"""
|
|
@@ -34,6 +39,7 @@ class SummarizationTransformers(TransformersBase):
|
|
|
34
39
|
"""
|
|
35
40
|
|
|
36
41
|
SUMMARY_TEXT_KEY = "summary_text"
|
|
42
|
+
UIProperties = SummarizationTransformersUIProperties
|
|
37
43
|
|
|
38
44
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
39
45
|
super().__init__(attributes)
|
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import torch
|
|
5
5
|
from sinapsis_core.data_containers.data_packet import AudioPacket, DataContainer, TextPacket
|
|
6
|
-
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
6
|
+
from sinapsis_core.template_base.base_models import OutputTypes, TemplateAttributeType
|
|
7
7
|
|
|
8
8
|
from sinapsis_huggingface_transformers.helpers import sentences_to_n_words, split_text_into_sentences
|
|
9
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
9
10
|
from sinapsis_huggingface_transformers.templates.base_transformers import (
|
|
10
11
|
TransformersBase,
|
|
11
12
|
TransformersBaseAttributes,
|
|
12
13
|
)
|
|
13
14
|
|
|
15
|
+
TextToSpeechTransformersUIProperties = TransformersBase.UIProperties
|
|
16
|
+
TextToSpeechTransformersUIProperties.output_type = OutputTypes.AUDIO
|
|
17
|
+
TextToSpeechTransformersUIProperties.tags.extend([Tags.AUDIO, Tags.TEXT, Tags.TEXT_TO_SPEECH])
|
|
18
|
+
|
|
14
19
|
|
|
15
20
|
class TextToSpeechAttributes(TransformersBaseAttributes):
|
|
16
21
|
"""Attributes for the TextToSpeech template.
|
|
@@ -61,6 +66,7 @@ class TextToSpeechTransformers(TransformersBase):
|
|
|
61
66
|
"""
|
|
62
67
|
|
|
63
68
|
AttributesBaseModel = TextToSpeechAttributes
|
|
69
|
+
UIProperties = TextToSpeechTransformersUIProperties
|
|
64
70
|
|
|
65
71
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
66
72
|
super().__init__(attributes)
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
5
|
-
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
5
|
+
from sinapsis_core.template_base.base_models import OutputTypes, TemplateAttributeType
|
|
6
6
|
|
|
7
|
+
from sinapsis_huggingface_transformers.helpers.tags import Tags
|
|
7
8
|
from sinapsis_huggingface_transformers.templates.base_transformers import (
|
|
8
9
|
TransformersBase,
|
|
9
10
|
TransformersBaseAttributes,
|
|
10
11
|
)
|
|
11
12
|
|
|
13
|
+
TranslationTransformersUIProperties = TransformersBase.UIProperties
|
|
14
|
+
TranslationTransformersUIProperties.output_type = OutputTypes.TEXT
|
|
15
|
+
TranslationTransformersUIProperties.tags.extend([Tags.LANGUAGE, Tags.TRANSLATION])
|
|
16
|
+
|
|
12
17
|
|
|
13
18
|
class TranslationTransformersAttributes(TransformersBaseAttributes):
|
|
14
19
|
"""Attributes for the transformers pipeline translation task.
|
|
@@ -52,6 +57,7 @@ class TranslationTransformers(TransformersBase):
|
|
|
52
57
|
|
|
53
58
|
AttributesBaseModel = TranslationTransformersAttributes
|
|
54
59
|
TRANSLATION_TEXT_KEY = "translation_text"
|
|
60
|
+
UIProperties = TranslationTransformersUIProperties
|
|
55
61
|
|
|
56
62
|
def __init__(self, attributes: TemplateAttributeType) -> None:
|
|
57
63
|
super().__init__(attributes)
|
|
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
|