Generation
Components that generate texts, images, audio and videos from every input kind.
AudioToAudioGenerator(*, operation='separate', stem='vocals', voice=None, gap=0.0, output_format='object', output_dir=None, backend=None, batch_size=4, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Return one audio sample per audio sample: a separated stem, a denoised copy, another voice, or a joined list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['separate', 'enhance', 'convert_voice', 'concatenate']
|
|
'separate'
|
stem
|
Literal['vocals', 'accompaniment']
|
|
'vocals'
|
voice
|
VoiceSource | None
|
One recording or a list of recordings of the target voice. Required with |
None
|
gap
|
float
|
The seconds of silence between joined audio samples. |
0.0
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of audio samples submitted to the backend at once. |
4
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend | None
|
The resolved backend, or |
voice_ |
Audio | None
|
The joined reference audio of the target voice. |
Examples:
>>> import numpy as np
>>> from skai.generation import AudioToAudioGenerator
>>> song = (np.zeros(32000), 16000)
>>> AudioToAudioGenerator(operation='separate', backend='dummy').fit().predict([song])[0].duration
2.0
Source code in src/skai/generation/_audio.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
AudioToTextGenerator(*, operation='transcribe', instructions=None, language=None, max_vocabulary=50, max_length=None, k_shot=None, max_examples=8, adaptation='examples', use_y='auto', backend=None, batch_size=8, on_error='raise', random_state=None)
Bases: BaseTextGenerator
Return one text per audio sample, by transcribing the speech or by following instructions.
With operation='transcribe' (the default), fit(X, y) with reference transcripts as y learns a vocabulary of
the names, products and technical terms they contain, which the backend receives as context for spelling. With
operation='instruct', the audio is described, summarized or answered about by an audio-language model, as the
instructions ask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['transcribe', 'instruct']
|
|
'transcribe'
|
instructions
|
str | None
|
What to produce from every audio sample. Required with |
None
|
language
|
str | None
|
The language of the speech, such as |
None
|
max_vocabulary
|
int
|
The maximum number of terms in the vocabulary, the most frequent first. |
50
|
max_length
|
int | Literal['auto'] | None
|
The maximum number of words of every output. |
None
|
k_shot
|
int | ArrayLike | None
|
How many training samples are passed to the backend as examples with their references, with
|
None
|
max_examples
|
int | None
|
The maximum number of examples when |
8
|
adaptation
|
Literal['examples', 'finetune']
|
|
'examples'
|
use_y
|
Literal['auto'] | bool
|
|
'auto'
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of audio samples submitted to the backend at once. |
8
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the selection of examples and the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
vocabulary_ |
tuple
|
The domain terms learned from the reference transcripts. |
examples_ |
tuple
|
The pairs of a sample and its reference passed to the backend. |
max_length_ |
int | None
|
The maximum number of words of every output. |
Examples:
>>> import numpy as np
>>> from skai.generation import AudioToTextGenerator
>>> AudioToTextGenerator(backend='dummy').fit().predict([(np.zeros(16000), 16000)])[0]
'Speech of 1.00 seconds.'
Source code in src/skai/generation/_text.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
AudioToVideoGenerator(*, operation='talking_head', avatar=None, output_format='object', output_dir=None, backend=None, batch_size=2, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Make a portrait speak every audio sample, as a talking head.
fit prepares avatar_ from avatar: converted to RGB, center-cropped to a square, and resized to the input size
of the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['talking_head']
|
|
'talking_head'
|
avatar
|
str | bytes | Image | ndarray | PurePath | None
|
The portrait, as a path, URL, bytes, PIL image or array. |
None
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of audio samples submitted to the backend at once. |
2
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
avatar_ |
Image
|
The prepared portrait. |
Examples:
>>> import numpy as np
>>> from PIL import Image
>>> from skai.generation import AudioToVideoGenerator
>>> generator = AudioToVideoGenerator(avatar=Image.new('RGB', (640, 480)), backend='dummy').fit()
>>> generator.predict([(np.zeros(16000), 16000)])[0].duration
1.0
Source code in src/skai/generation/_video.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
ImageToImageGenerator(*, operation='edit', instructions=None, mask=None, scale=2, columns=None, tile=256, output_format='object', output_dir=None, backend=None, batch_size=4, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Return one image per image: edited, upscaled, without its background, or a collage of a list of images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['edit', 'upscale', 'remove_background', 'collage']
|
|
'edit'
|
instructions
|
str | None
|
The edit to apply. Required with |
None
|
mask
|
ImageSource | None
|
The region to edit, as a grayscale image where white marks the region. It is resized to every image. |
None
|
scale
|
int
|
The factor of upscaling. |
2
|
columns
|
int | None
|
The number of columns of a collage, chosen from the number of images when it is |
None
|
tile
|
int
|
The side of every tile of a collage in pixels. |
256
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of images submitted to the backend at once. |
4
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend | None
|
The resolved backend, or |
mask_ |
Image | None
|
The read mask. |
Examples:
>>> from PIL import Image
>>> from skai.generation import ImageToImageGenerator
>>> generator = ImageToImageGenerator(operation='upscale', scale=2, backend='dummy').fit()
>>> generator.predict([Image.new('RGB', (64, 48))])[0].size
(128, 96)
Source code in src/skai/generation/_image.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
ImageToTextGenerator(*, instructions=None, operation='instruct', format='text', max_length=None, k_shot=None, max_examples=8, adaptation='examples', use_y='auto', backend=None, batch_size=8, on_error='raise', random_state=None)
Bases: BaseTextGenerator
Return one text per image, by following instructions or by transcribing the text written in it.
With operation='instruct', the image is described, answered about or captioned as the instructions ask, and
fit(X, y) with reference texts as y passes example pairs to the backend. With operation='transcribe', the
text of the image is returned exactly, as plain text or as Markdown that keeps the page structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instructions
|
str | None
|
What to produce from every image, such as |
None
|
operation
|
Literal['instruct', 'transcribe']
|
|
'instruct'
|
format
|
Literal['text', 'markdown']
|
|
'text'
|
max_length
|
int | Literal['auto'] | None
|
The maximum number of words of every output. |
None
|
k_shot
|
int | ArrayLike | None
|
How many training images are passed to the backend as examples with their references. |
None
|
max_examples
|
int | None
|
The maximum number of examples when |
8
|
adaptation
|
Literal['examples', 'finetune']
|
|
'examples'
|
use_y
|
Literal['auto'] | bool
|
|
'auto'
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of images submitted to the backend at once. |
8
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the selection of examples and the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
examples_ |
tuple
|
The pairs of an image and its reference passed to the backend. |
max_length_ |
int | None
|
The maximum number of words of every output. |
model_ |
str
|
The id of the fine-tuned model. It is set only with |
Examples:
>>> from PIL import Image
>>> from skai.generation import ImageToTextGenerator
>>> generator = ImageToTextGenerator(instructions='Describe the image.', backend='dummy').fit()
>>> generator.predict([Image.new('RGB', (64, 48))])[0]
'A 64x48 image.'
Source code in src/skai/generation/_text.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
ImageToVideoGenerator(*, operation='animate', instructions=None, duration=2.0, fps=None, output_format='object', output_dir=None, backend=None, batch_size=1, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Turn every image into a short video that starts from it, with optional instructions for the motion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['animate']
|
|
'animate'
|
instructions
|
str | None
|
A description of the motion. |
None
|
duration
|
float
|
The length of every video in seconds. |
2.0
|
fps
|
int | None
|
The number of frames per second, or |
None
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of images submitted to the backend at once. |
1
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
Examples:
>>> from PIL import Image
>>> from skai.generation import ImageToVideoGenerator
>>> generator = ImageToVideoGenerator(duration=1, fps=8, backend='dummy').fit()
>>> generator.predict([Image.new('RGB', (64, 48))])[0].duration
1.0
Source code in src/skai/generation/_video.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
MultimodalToAudioGenerator(*, operation='mix', volumes=None, duck_under=None, duck_for=None, duck_level=0.25, language=None, output_format='object', output_dir=None, backend=None, batch_size=16, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Mix the named tracks of every multimodal sample, or speak its text in its own voice.
With operation='mix' (the default), a sample is a dict, or a DataFrame row, of named tracks, mixed locally into
one track as long as the longest. A track is audio, a video whose audio track is used, or a list of timed records
with start and media, such as segmenter regions, each placed at its start. With operation='speech', the
backend speaks the text of every sample in its voice, a voice name or reference audio of the voice to clone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['mix', 'speech']
|
|
'mix'
|
volumes
|
dict[str, float] | None
|
The gain of every track by name, one when it is missing. |
None
|
duck_under
|
list[str] | None
|
The names of the tracks to lower while |
None
|
duck_for
|
str | None
|
The name of the track whose sound lowers the others, such as |
None
|
duck_level
|
float
|
The gain of the lowered tracks while |
0.25
|
language
|
str | None
|
The language of the texts spoken with |
None
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of samples submitted to the backend at once. |
16
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend | None
|
The resolved backend, or |
Examples:
>>> import numpy as np
>>> from skai.generation import MultimodalToAudioGenerator
>>> sample = {'voice': (np.zeros(16000), 16000), 'music': (np.zeros(32000), 16000)}
>>> MultimodalToAudioGenerator(duck_under=['music'], duck_for='voice').fit().predict([sample])[0].duration
2.0
Source code in src/skai/generation/_audio.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
MultimodalToImageGenerator(*, operation='edit', output_format='object', output_dir=None, backend=None, batch_size=4, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Edit the image of every multimodal sample with the instructions of the same sample, inside its mask.
A sample is a dict, or a DataFrame row, with image and instructions, and an optional mask, a grayscale image
where white marks the region to edit. It lets every image get its own edit, such as the translated text of a
comic panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['edit']
|
|
'edit'
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of samples submitted to the backend at once. |
4
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
Examples:
>>> from PIL import Image
>>> from skai.generation import MultimodalToImageGenerator
>>> sample = {'image': Image.new('RGB', (64, 48)), 'instructions': 'Add snow.'}
>>> MultimodalToImageGenerator(backend='dummy').fit().predict([sample])[0].size
(64, 48)
Source code in src/skai/generation/_image.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
MultimodalToTextGenerator(*, instructions=None, operation='instruct', n_frames=8, max_length=None, k_shot=None, max_examples=4, adaptation='examples', use_y='auto', backend=None, batch_size=8, on_error='raise', random_state=None)
Bases: BaseTextGenerator
Return one text per multimodal sample by following instructions, with every named part in one request.
A sample is a dict, or a DataFrame row, of named texts, images, audio and videos. Strings are texts unless they are
URLs or paths of existing media files. fit(X, y) with reference texts as y passes example pairs to the
backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instructions
|
str | None
|
What to produce from every sample, such as |
None
|
operation
|
Literal['instruct']
|
|
'instruct'
|
n_frames
|
int
|
The number of frames sampled from every video part. |
8
|
max_length
|
int | Literal['auto'] | None
|
The maximum number of words of every output. |
None
|
k_shot
|
int | ArrayLike | None
|
How many training samples are passed to the backend as examples with their references. |
None
|
max_examples
|
int | None
|
The maximum number of examples when |
4
|
adaptation
|
Literal['examples', 'finetune']
|
|
'examples'
|
use_y
|
Literal['auto'] | bool
|
|
'auto'
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of samples submitted to the backend at once. |
8
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the selection of examples and the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
examples_ |
tuple
|
The pairs of a sample and its reference passed to the backend. |
max_length_ |
int | None
|
The maximum number of words of every output. |
Examples:
>>> from PIL import Image
>>> from skai.generation import MultimodalToTextGenerator
>>> generator = MultimodalToTextGenerator(instructions='Write a caption.', backend='dummy').fit()
>>> generator.predict([{'photo': Image.new('RGB', (8, 8)), 'notes': 'Crete'}])[0]
'photo: A 8x8 image. notes: Crete'
Source code in src/skai/generation/_text.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
MultimodalToVideoGenerator(*, operation='lip_sync', burn=True, output_format='object', output_dir=None, backend=None, batch_size=1, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Return one video per multimodal sample: lip-synced to new speech, with a new soundtrack, or subtitled.
A sample is a dict, or a DataFrame row, of named parts. 'lip_sync' makes video speak audio with the backend,
'mux' replaces the soundtrack of video with audio, and 'subtitle' shows transcript as subtitles, both
locally. A transcript is a string, or a list of timed records with start, end and text, such as the output
of AudioSegmenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['lip_sync', 'mux', 'subtitle']
|
|
'lip_sync'
|
burn
|
bool
|
Whether subtitles are drawn on the frames. Otherwise they are attached as |
True
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of samples submitted to the backend at once. |
1
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend | None
|
The resolved backend, or |
Examples:
>>> import numpy as np
>>> from skai.core import Video
>>> from skai.generation import MultimodalToVideoGenerator
>>> sample = {'video': Video(np.zeros((8, 8, 8, 3), dtype=np.uint8), fps=4), 'audio': (np.zeros(8000), 16000)}
>>> MultimodalToVideoGenerator(operation='mux').fit().predict([sample])[0].audio.duration
2.0
Source code in src/skai/generation/_video.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
TextToAudioGenerator(*, operation='speech', voice=None, language=None, duration=10.0, output_format='object', output_dir=None, backend=None, batch_size=16, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Return one audio sample per text: the text spoken, or music or a sound it describes.
With operation='speech', voice is a voice name of the backend, or one recording or a list of recordings of the
voice to clone, which fit joins into voice_.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['speech', 'music', 'sound']
|
|
'speech'
|
voice
|
VoiceSource | None
|
A voice name, or one recording or a list of recordings of the target voice. |
None
|
language
|
str | None
|
The language of the text. |
None
|
duration
|
float
|
The length of music and sounds in seconds. |
10.0
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of texts submitted to the backend at once. |
16
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
voice_ |
str | Audio | None
|
The voice name, or the joined reference audio of the voice to clone. |
Examples:
>>> from skai.generation import TextToAudioGenerator
>>> generator = TextToAudioGenerator(operation='music', duration=5, backend='dummy').fit()
>>> generator.predict(['calm piano'])[0].duration
5.0
Source code in src/skai/generation/_audio.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
TextToImageGenerator(*, operation='generate', size=(1024, 1024), style=None, style_images=None, negative_prompt=None, reference_images=None, reference_prompt=None, output_format='object', output_dir=None, backend=None, batch_size=4, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Create one image per prompt, in a style given or learned from reference images.
fit learns style_, a description of the shared style of style_images written by the backend's image
description, and applies it to every prompt unless style is given. reference_images show a subject that every
image keeps consistent, on backends that take reference images, and with reference_prompt instead, fit
generates one reference image of the subject and sends it with every request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['generate']
|
|
'generate'
|
size
|
tuple[int, int]
|
The width and height of every image in pixels. |
(1024, 1024)
|
style
|
str | None
|
A description of the visual style. It takes precedence over the learned style. |
None
|
style_images
|
list | None
|
Images whose shared style is learned in |
None
|
negative_prompt
|
str | None
|
A description of what the images must not show. |
None
|
reference_images
|
list | None
|
Images of a subject that every image must show consistently. |
None
|
reference_prompt
|
str | None
|
A description of the subject, from which |
None
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of prompts submitted to the backend at once. |
4
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
style_ |
str | None
|
The style learned from |
reference_images_ |
tuple
|
The read or generated reference images. |
Examples:
>>> from skai.generation import TextToImageGenerator
>>> generator = TextToImageGenerator(size=(64, 48), backend='dummy').fit()
>>> generator.predict(['a cat'])[0].size
(64, 48)
Source code in src/skai/generation/_image.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
TextToTextGenerator(*, instructions=None, operation='instruct', max_length=None, learn_terms=False, k_shot=None, max_examples=8, adaptation='examples', use_y='auto', backend=None, batch_size=16, on_error='raise', random_state=None)
Bases: BaseTextGenerator
Return one text per text by following instructions, such as a summary, a translation or an answer.
fit(X, y) with reference texts as y passes k_shot text and reference pairs to the backend as examples, learns
max_length_ with max_length='auto', and learns a glossary of consistently rendered terms with
learn_terms=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instructions
|
str | None
|
What to produce from every text, such as |
None
|
operation
|
Literal['instruct']
|
|
'instruct'
|
max_length
|
int | Literal['auto'] | None
|
The maximum number of words of every output. |
None
|
learn_terms
|
bool
|
Whether |
False
|
k_shot
|
int | ArrayLike | None
|
How many training texts are passed to the backend as examples with their references. |
None
|
max_examples
|
int | None
|
The maximum number of examples when |
8
|
adaptation
|
Literal['examples', 'finetune']
|
|
'examples'
|
use_y
|
Literal['auto'] | bool
|
|
'auto'
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of texts submitted to the backend at once. |
16
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the selection of examples and the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
examples_ |
tuple
|
The pairs of a text and its reference passed to the backend. |
max_length_ |
int | None
|
The maximum number of words of every output. |
glossary_ |
tuple
|
Pairs of a term and its required rendering. |
model_ |
str
|
The id of the fine-tuned model. It is set only with |
Examples:
>>> from skai.generation import TextToTextGenerator
>>> generator = TextToTextGenerator(instructions='Summarize the text.', max_length=3, backend='dummy').fit()
>>> generator.predict(['One two three four five.']).tolist()
['One two three']
Source code in src/skai/generation/_text.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
TextToVideoGenerator(*, operation='generate', duration=4.0, size=(1280, 720), fps=None, style=None, negative_prompt=None, output_format='object', output_dir=None, backend=None, batch_size=1, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Create one video per prompt, of a duration and size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['generate']
|
|
'generate'
|
duration
|
float
|
The length of every video in seconds. |
4.0
|
size
|
tuple[int, int]
|
The width and height of every video in pixels. |
(1280, 720)
|
fps
|
int | None
|
The number of frames per second, or |
None
|
style
|
str | None
|
A description of the visual style. |
None
|
negative_prompt
|
str | None
|
A description of what the videos must not show. |
None
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of prompts submitted to the backend at once. |
1
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
Examples:
>>> from skai.generation import TextToVideoGenerator
>>> generator = TextToVideoGenerator(duration=2, size=(320, 240), fps=8, backend='dummy').fit()
>>> generator.predict(['a boat at sea'])[0].duration
2.0
Source code in src/skai/generation/_video.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
VideoToAudioGenerator(*, operation='extract', output_format='object', output_dir=None, on_error='raise')
Bases: BaseMediaGenerator
Return the mono audio track of every video, or silence as long as a video without one, locally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['extract']
|
|
'extract'
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
None
|
Always |
Examples:
>>> import numpy as np
>>> from skai.core import Video
>>> from skai.generation import VideoToAudioGenerator
>>> video = Video(np.zeros((8, 8, 8, 3), dtype=np.uint8), fps=4)
>>> VideoToAudioGenerator().fit().predict([video])[0].duration
2.0
Source code in src/skai/generation/_audio.py
342 343 344 345 346 347 348 349 350 351 352 353 | |
VideoToImageGenerator(*, operation='thumbnail', n_frames=8, at=0.0, output_format='object', output_dir=None, backend=None, batch_size=4, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Return one image per video: the thumbnail chosen by the backend, or the frame at a time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['thumbnail', 'frame']
|
|
'thumbnail'
|
n_frames
|
int
|
The number of candidate frames of a thumbnail. |
8
|
at
|
float
|
The time of the frame in seconds, clamped to the video. |
0.0
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of videos submitted to the backend at once. |
4
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend | None
|
The resolved backend, or |
Examples:
>>> import numpy as np
>>> from skai.core import Video
>>> from skai.generation import VideoToImageGenerator
>>> video = Video(np.zeros((8, 48, 64, 3), dtype=np.uint8), fps=4)
>>> VideoToImageGenerator(operation='frame', at=1.0).fit().predict([video])[0].size
(64, 48)
Source code in src/skai/generation/_image.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
VideoToTextGenerator(*, instructions=None, operation='instruct', n_frames=8, language=None, max_vocabulary=50, max_length=None, k_shot=None, max_examples=4, adaptation='examples', use_y='auto', backend=None, batch_size=4, on_error='raise', random_state=None)
Bases: BaseTextGenerator
Return one text per video, by following instructions or by transcribing its speech.
With operation='instruct' (the default), the model sees frames sampled evenly over every video, and the audio
track on backends that accept audio, and produces what the instructions ask. With operation='transcribe', the
speech of the audio track is transcribed, learning a vocabulary from reference transcripts as
AudioToTextGenerator does, and a video without an audio track gives an empty transcript.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instructions
|
str | None
|
What to produce from every video. Required with |
None
|
operation
|
Literal['instruct', 'transcribe']
|
|
'instruct'
|
n_frames
|
int
|
The number of frames sampled from every video. |
8
|
language
|
str | None
|
The language of the speech. It is detected when it is |
None
|
max_vocabulary
|
int
|
The maximum number of terms in the vocabulary, the most frequent first. |
50
|
max_length
|
int | Literal['auto'] | None
|
The maximum number of words of every output. |
None
|
k_shot
|
int | ArrayLike | None
|
How many training videos are passed to the backend as examples with their references, with
|
None
|
max_examples
|
int | None
|
The maximum number of examples when |
4
|
adaptation
|
Literal['examples', 'finetune']
|
|
'examples'
|
use_y
|
Literal['auto'] | bool
|
|
'auto'
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of videos submitted to the backend at once. |
4
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the selection of examples and the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend
|
The resolved backend. |
vocabulary_ |
tuple
|
The domain terms learned from the reference transcripts. |
examples_ |
tuple
|
The pairs of a video and its reference passed to the backend. |
max_length_ |
int | None
|
The maximum number of words of every output. |
Examples:
>>> import numpy as np
>>> from skai.core import Video
>>> from skai.generation import VideoToTextGenerator
>>> video = Video(np.zeros((8, 8, 8, 3), dtype=np.uint8), fps=4)
>>> VideoToTextGenerator(operation='transcribe', backend='dummy').fit().predict([video])[0]
''
Source code in src/skai/generation/_text.py
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
VideoToVideoGenerator(*, operation='reframe', aspect_ratio=9 / 16, subject='person', n_frames=8, output_format='object', output_dir=None, backend=None, batch_size=2, on_error='raise', random_state=None)
Bases: BaseMediaGenerator
Return one video per video, reframed to an aspect ratio following its main subject, or a joined list of clips.
Reframing detects subject in n_frames sampled frames with the backend and crops every frame around the
detected centers, interpolated over time. Concatenation joins a list of clips locally, at the size and frame rate
of the first clip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['reframe', 'concatenate']
|
|
'reframe'
|
aspect_ratio
|
float
|
The width divided by the height of reframed videos, such as |
9 / 16
|
subject
|
str
|
The kind of subject that reframing follows. |
'person'
|
n_frames
|
int
|
The number of frames in which reframing detects the subject. |
8
|
output_format
|
Literal['object', 'bytes', 'path']
|
|
'object'
|
output_dir
|
str | PathLike | None
|
The directory of |
None
|
backend
|
str | Backend | None
|
The backend, as |
None
|
batch_size
|
int
|
The number of videos submitted to the backend at once. |
2
|
on_error
|
Literal['raise', 'ignore']
|
|
'raise'
|
random_state
|
int | None
|
Controls the seeds sent to the backend. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
backend_ |
Backend | None
|
The resolved backend, or |
Examples:
>>> import numpy as np
>>> from skai.core import Video
>>> from skai.generation import VideoToVideoGenerator
>>> clip = Video(np.zeros((4, 8, 8, 3), dtype=np.uint8), fps=4)
>>> VideoToVideoGenerator(operation='concatenate').fit().predict([[clip, clip, clip]])[0].duration
3.0
Source code in src/skai/generation/_video.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |