Presets
Return components configured for common tasks.
Every preset is a function that returns an ordinary component with its instructions and operation set, and passes
extra keyword arguments, such as backend, to the component. INSTRUCTIONS holds the instructions of the presets
that are text generators, extractors or classifiers.
Examples:
>>> from skai import presets
>>> summarizer = presets.summarizer(max_length=50, backend='dummy')
>>> type(summarizer).__name__, summarizer.max_length
('TextToTextGenerator', 50)
animator(instructions=None, duration=2.0, **kwargs)
Return a generator that turns images into short videos.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instructions
|
str | None
|
A description of the motion. |
None
|
duration
|
float
|
The length of the videos in seconds. |
2.0
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
ImageToVideoGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
background_remover(**kwargs)
Return a generator that removes the background of images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
ImageToImageGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
320 321 322 323 324 325 326 327 328 329 330 | |
describer(kind='image', **kwargs)
Return a text generator that describes images, audio, videos or multimodal samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
Kind
|
The input kind. |
'image'
|
**kwargs
|
Any
|
Other parameters of the generator. |
{}
|
Returns:
| Type | Description |
|---|---|
BaseSupervisedGenerator
|
The configured |
Source code in src/skai/presets/_presets.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
diarizer(**kwargs)
Return a segmenter that splits audio into speaker turns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
AudioSegmenter
|
The configured segmenter. |
Source code in src/skai/presets/_presets.py
278 279 280 281 282 283 284 285 286 287 288 | |
document_parser(**kwargs)
Return a text generator that transcribes page images as Markdown that keeps their structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
ImageToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
265 266 267 268 269 270 271 272 273 274 275 | |
lip_syncer(**kwargs)
Return a generator that makes the video of every sample speak its audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
MultimodalToVideoGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
397 398 399 400 401 402 403 404 405 406 407 | |
moderator(labels=None, kind='multimodal', **kwargs)
Return a classifier that labels samples as safe or unsafe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
list[str] | None
|
The labels, |
None
|
kind
|
Kind
|
The input kind. |
'multimodal'
|
**kwargs
|
Any
|
Other parameters of the classifier. |
{}
|
Returns:
| Type | Description |
|---|---|
BaseClassifier
|
The configured |
Source code in src/skai/presets/_presets.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
music_generator(duration=10.0, **kwargs)
Return a generator that creates music from descriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration
|
float
|
The length of the music in seconds. |
10.0
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextToAudioGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
object_detector(labels, **kwargs)
Return a segmenter that finds the boxes of objects in images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
list[str]
|
The kinds of objects to find. |
required |
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
ImageSegmenter
|
The configured segmenter. |
Source code in src/skai/presets/_presets.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
ocr(**kwargs)
Return a text generator that transcribes the text of images as plain text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
ImageToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
252 253 254 255 256 257 258 259 260 261 262 | |
prompt_writer(target='image', **kwargs)
Return a text generator that writes a generation prompt from every text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Literal['image', 'video', 'music']
|
The kind of generation model the prompt is for. |
'image'
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
question_answerer(question, kind='text', **kwargs)
Return a text generator that answers one question about every sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
question
|
str
|
The question. |
required |
kind
|
Kind
|
The input kind. |
'text'
|
**kwargs
|
Any
|
Other parameters of the generator. |
{}
|
Returns:
| Type | Description |
|---|---|
BaseSupervisedGenerator
|
The configured |
Source code in src/skai/presets/_presets.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
quiz_writer(n_questions=5, **kwargs)
Return a text generator that writes a multiple-choice quiz from every text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_questions
|
int
|
The number of questions. |
5
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
rewriter(style='clear and concise', **kwargs)
Return a text generator that rewrites texts in a style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
str
|
The style of the rewritten texts. |
'clear and concise'
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
script_writer(format='video narration', length='one-minute', **kwargs)
Return a text generator that writes a spoken script from every text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
The kind of script, such as |
'video narration'
|
length
|
str
|
The length of the script, in words a model understands, such as |
'one-minute'
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
separator(stem='vocals', **kwargs)
Return a generator that separates the vocals or the accompaniment of audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stem
|
Literal['vocals', 'accompaniment']
|
The stem to keep. |
'vocals'
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
AudioToAudioGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
shot_detector(**kwargs)
Return a segmenter that splits videos into shots locally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
VideoSegmenter
|
The configured segmenter. |
Source code in src/skai/presets/_presets.py
307 308 309 310 311 312 313 314 315 316 317 | |
storyboarder(n_scenes='a few', **kwargs)
Return an extractor that splits every text into scenes with narration and visuals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_scenes
|
int | str
|
The number of scenes, or words such as |
'a few'
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextExtractor
|
The configured extractor, whose only field |
Source code in src/skai/presets/_presets.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
summarizer(max_length='auto', **kwargs)
Return a text generator that summarizes texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_length
|
int | Literal['auto'] | None
|
The maximum number of words of every summary, or |
'auto'
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
talking_head(avatar, **kwargs)
Return a generator that makes a portrait speak audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
avatar
|
Any
|
The portrait. |
required |
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
AudioToVideoGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
translator(target_language, *, learn_terms=True, **kwargs)
Return a text generator that translates texts and learns a glossary from reference translations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_language
|
str
|
The language of the translations. |
required |
learn_terms
|
bool
|
Whether |
True
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
TextToTextGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
upscaler(scale=2, **kwargs)
Return a generator that upscales images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
int
|
The factor of upscaling. |
2
|
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
ImageToImageGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
voice_converter(voice, **kwargs)
Return a generator that says the speech of audio in another voice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
voice
|
Any
|
One recording or a list of recordings of the target voice. |
required |
**kwargs
|
Any
|
Other parameters of |
{}
|
Returns:
| Type | Description |
|---|---|
AudioToAudioGenerator
|
The configured generator. |
Source code in src/skai/presets/_presets.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |