Layousyn
Diffusers-style LayouSyn / Lay-Your-Scene conversion package.
ConditionType ¶
Bases: StrEnum
Canonical condition names used by layout generation interfaces.
Source code in lib/laygen/src/laygen/common/conditions.py
9 10 11 12 13 14 15 16 17 18 19 20 21 | |
LayoutGenerationOutput
dataclass
¶
Bases: BaseOutput
Layout-generation output for Diffusers pipelines.
Attributes:
| Name | Type | Description |
|---|---|---|
bbox |
Float[Tensor, 'batch elements 4']
|
Normalized center |
labels |
Int[Tensor, 'batch elements']
|
Dataset-local integer labels with shape |
mask |
Bool[Tensor, 'batch elements']
|
Boolean valid-element mask with shape |
id2label |
dict[int, str]
|
Mapping from integer label ids to display names. |
sequences |
object | None
|
Optional raw token sequences. |
scores |
object | None
|
Optional per-token or per-element scores. |
trajectory |
object | None
|
Optional sampling trajectory. |
intermediates |
object | None
|
Optional model-specific debug or auxiliary data. |
Examples:
>>> import torch
>>> output = LayoutGenerationOutput(
... bbox=torch.zeros(1, 1, 4),
... labels=torch.zeros(1, 1, dtype=torch.long),
... mask=torch.ones(1, 1, dtype=torch.bool),
... id2label={0: "text"},
... )
>>> output.to_tuple()[0].shape
torch.Size([1, 1, 4])
Source code in lib/laygen/src/laygen/pipelines/pipeline_output.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
LayouSynConfig ¶
Bases: ConfigMixin
Serializable LayouSyn configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Reference DiT architecture key. |
'DiT-S'
|
in_channels
|
int
|
Layout coordinate channels. |
4
|
concept_in_channels
|
int
|
Concept embedding width. |
768
|
y_in_channels
|
int | None
|
Caption embedding width. |
768
|
max_in_len
|
int
|
Maximum number of object slots. |
60
|
max_y_len
|
int | None
|
Maximum number of caption tokens. |
120
|
layout_type
|
LayoutType
|
Reference layout coordinate type. |
'xyxy'
|
t5_size
|
str | None
|
Reference T5 size suffix. |
'base'
|
scale
|
float
|
Default classifier-free guidance scale. |
2.0
|
noise_schedule
|
str
|
Reference diffusion beta schedule. |
'linear'
|
diffusion_steps
|
int
|
Number of diffusion training timesteps. |
100
|
hidden_size
|
int | None
|
Optional resolved hidden width override. |
None
|
depth
|
int | None
|
Optional resolved transformer depth override. |
None
|
num_heads
|
int | None
|
Optional resolved attention head override. |
None
|
license
|
str
|
Upstream checkpoint license identifier. |
'cc-by-nc-4.0'
|
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
__init__ ¶
__init__(
*,
model_name: str = "DiT-S",
in_channels: int = 4,
concept_in_channels: int = 768,
y_in_channels: int | None = 768,
max_in_len: int = 60,
max_y_len: int | None = 120,
layout_type: LayoutType = "xyxy",
t5_size: str | None = "base",
scale: float = 2.0,
noise_schedule: str = "linear",
diffusion_steps: int = 100,
hidden_size: int | None = None,
depth: int | None = None,
num_heads: int | None = None,
license: str = "cc-by-nc-4.0",
) -> None
Initialize configuration fields.
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
118 119 120 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 151 152 153 154 155 156 157 158 159 | |
from_reference_json
classmethod
¶
from_reference_json(path: str | Path) -> 'LayouSynConfig'
Load a reference JSON config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a Lay-Your-Scene JSON config. |
required |
Returns:
| Type | Description |
|---|---|
'LayouSynConfig'
|
Converted configuration object. |
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
to_reference_dict ¶
to_reference_dict() -> LayouSynReferenceConfig
Return the config keys expected by the original repository.
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
LayouSynDiTModel ¶
Bases: ModelMixin, ConfigMixin
Converted LayouSyn DiT denoiser.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
__init__ ¶
__init__(
*,
in_channels: int = 4,
max_in_len: int = 60,
concept_in_channels: int = 768,
y_in_channels: int | None = 768,
max_y_len: int | None = 120,
model_name: str = "DiT-S",
hidden_size: int | None = None,
depth: int | None = None,
num_heads: int | None = None,
mlp_ratio: float = 4.0,
class_dropout_prob: float = 0.1,
learn_sigma: bool = True,
is_unconditional: bool = False,
) -> None
Initialize the converted DiT model.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 452 453 454 455 | |
initialize_weights ¶
initialize_weights() -> None
Initialize weights with the reference policy.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
forward ¶
forward(
sample: Float[Tensor, "batch elements channels"],
timestep: Int[Tensor, "batch"],
*,
x_padding_mask: Bool[Tensor, "batch elements"],
aspect_ratio: Float[Tensor, "batch"],
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
],
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
]
| None = None,
caption_padding_mask: Bool[Tensor, "batch tokens"]
| None = None,
) -> Float[torch.Tensor, "batch seq channels"]
Predict epsilon and variance channels for one timestep.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
forward_with_cfg ¶
forward_with_cfg(
sample: Float[Tensor, "batch elements channels"],
timestep: Int[Tensor, "batch"],
*,
x_padding_mask: Bool[Tensor, "batch elements"],
aspect_ratio: Float[Tensor, "batch"],
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
],
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
],
caption_padding_mask: Bool[Tensor, "batch tokens"],
guidance_scale: float,
) -> Float[torch.Tensor, "batch seq channels"]
Run reference classifier-free guidance batching.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
LayouSynPipeline ¶
Bases: DiffusionPipeline
Generate open-vocabulary scene layouts with LayouSyn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
LayouSynDiTModel
|
Converted DiT denoiser. |
required |
scheduler
|
LayouSynScheduler
|
LayouSyn Gaussian/DDIM scheduler. |
required |
processor
|
LayouSynProcessor
|
Processor for prompt/concept inputs and postprocessing. |
required |
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 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 308 309 310 | |
components
property
¶
components: dict[
str,
LayouSynDiTModel
| LayouSynScheduler
| LayouSynProcessor,
]
Return serializable pipeline components.
__init__ ¶
__init__(
model: LayouSynDiTModel,
scheduler: LayouSynScheduler,
processor: LayouSynProcessor,
) -> None
Initialize the pipeline.
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
46 47 48 49 50 51 52 53 54 55 | |
save_pretrained ¶
save_pretrained(
save_directory: str | PathLike[str],
**kwargs: str | int | float | bool | None,
) -> None
Save pipeline components plus processor metadata.
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
80 81 82 83 84 85 86 87 | |
from_pretrained
classmethod
¶
from_pretrained(
pretrained_model_name_or_path: str | PathLike[str],
**kwargs: str | int | float | bool | None,
) -> LayouSynPipeline
Load pipeline and restore local processor metadata.
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
__call__ ¶
__call__(
*,
prompt: str | list[str] | None = None,
batch_size: int = 1,
seed: int | None = None,
generator: Generator | None = None,
condition_type: ConditionType
| str = ConditionType.text,
labels: Int[Tensor, "batch elements"]
| Int[ndarray, "batch elements"]
| list[str]
| list[list[str]]
| None = None,
id2label: dict[int, str] | None = None,
bbox: Float[Tensor, "batch elements 4"]
| Float[ndarray, "batch elements 4"]
| Sequence[ArrayLikeInput]
| None = None,
mask: Bool[Tensor, "batch elements"]
| Bool[ndarray, "batch elements"]
| Sequence[ArrayLikeInput]
| None = None,
num_elements: int
| list[int]
| Int[Tensor, "batch"]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
aspect_ratio: float
| list[float]
| Float[Tensor, "batch"] = 1.0,
num_inference_steps: int | None = None,
guidance_scale: float = 2.0,
sampling_type: Literal["ddim", "ddpm"] = "ddim",
output_type: Literal["dataclass", "dict"] = "dataclass",
return_intermediates: bool = False,
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
]
| None = None,
caption_padding_mask: Bool[Tensor, "batch tokens"]
| None = None,
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
]
| None = None,
) -> LayoutGenerationOutput | LayouSynOutputDict
Run LayouSyn denoising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str | list[str] | None
|
Caption text. |
None
|
batch_size
|
int
|
Number of generated layouts when labels are unbatched. |
1
|
seed
|
int | None
|
Convenience seed used only if |
None
|
generator
|
Generator | None
|
Exact reproducibility API. |
None
|
condition_type
|
ConditionType | str
|
Canonical condition name. First-class public mode is
|
text
|
labels
|
Int[Tensor, 'batch elements'] | Int[ndarray, 'batch elements'] | list[str] | list[list[str]] | None
|
String concepts or integer ids. |
None
|
id2label
|
dict[int, str] | None
|
Mapping for integer labels. |
None
|
bbox
|
Float[Tensor, 'batch elements 4'] | Float[ndarray, 'batch elements 4'] | Sequence[ArrayLikeInput] | None
|
Reserved for future initialization/refinement support. |
None
|
mask
|
Bool[Tensor, 'batch elements'] | Bool[ndarray, 'batch elements'] | Sequence[ArrayLikeInput] | None
|
Optional valid concept mask. |
None
|
num_elements
|
int | list[int] | Int[Tensor, 'batch'] | None
|
Optional expected element count. It is validated against labels when supplied. |
None
|
box_format
|
BoxFormat | str
|
Public input bbox format. |
xywh
|
normalized
|
bool
|
Whether input boxes are normalized. |
True
|
canvas_size
|
tuple[int, int] | None
|
Required for pixel boxes. |
None
|
aspect_ratio
|
float | list[float] | Float[Tensor, 'batch']
|
Scalar or per-example aspect ratio. |
1.0
|
num_inference_steps
|
int | None
|
Number of reverse diffusion steps. |
None
|
guidance_scale
|
float
|
Classifier-free guidance scale. |
2.0
|
sampling_type
|
Literal['ddim', 'ddpm']
|
|
'ddim'
|
output_type
|
Literal['dataclass', 'dict']
|
|
'dataclass'
|
return_intermediates
|
bool
|
Whether to return denoising trajectory. |
False
|
caption_embeds
|
Float[Tensor, 'batch tokens embedding_dim'] | None
|
Precomputed caption embeddings. |
None
|
caption_padding_mask
|
Bool[Tensor, 'batch tokens'] | None
|
Precomputed caption padding mask. |
None
|
concept_embeds
|
Float[Tensor, 'batch elements embedding_dim'] | None
|
Precomputed concept embeddings. |
None
|
Returns:
| Type | Description |
|---|---|
LayoutGenerationOutput | LayouSynOutputDict
|
Public layout output. |
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
109 110 111 112 113 114 115 116 117 118 119 120 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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
LayouSynProcessor ¶
Bases: ProcessorMixin
Encode prompts and open-vocabulary concepts for LayouSyn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout_type
|
Literal['xyxy', 'cxcywh']
|
Reference layout type used by generated coordinates. |
'xyxy'
|
max_in_len
|
int
|
Maximum number of concept slots. |
60
|
caption_model_name
|
str
|
Text encoder identifier used for captions. |
't5-v1_1-base'
|
concept_model_name
|
str
|
Sentence-transformers model id for concept labels. |
'sentence-transformers/sentence-t5-base'
|
id2label
|
dict[int, str] | None
|
Optional fixed vocabulary for integer labels. |
None
|
open_vocabulary
|
bool
|
Whether string labels are accepted per request. |
True
|
Source code in models/layousyn/src/layousyn/processing_layousyn.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 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 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
__init__ ¶
__init__(
*,
layout_type: Literal["xyxy", "cxcywh"] = "xyxy",
max_in_len: int = 60,
max_y_len: int = 120,
concept_in_channels: int = 768,
y_in_channels: int = 768,
caption_model_name: str = "t5-v1_1-base",
concept_model_name: str = "sentence-transformers/sentence-t5-base",
id2label: dict[int, str] | None = None,
open_vocabulary: bool = True,
) -> None
Initialize processor metadata.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
to_dict ¶
to_dict() -> dict[
str, str | int | bool | dict[int, str] | None
]
Serialize processor metadata.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
save_pretrained ¶
save_pretrained(
save_directory: str | Path,
push_to_hub: bool = False,
**kwargs: str | int | float | bool | None,
) -> tuple[str]
Save processor metadata.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
from_pretrained
classmethod
¶
from_pretrained(
pretrained_model_name_or_path: str | PathLike[str],
cache_dir: str | PathLike[str] | None = None,
force_download: bool = False,
local_files_only: bool = False,
token: str | bool | None = None,
revision: str = "main",
**kwargs: str | int | float | bool | None,
) -> LayouSynProcessor
Load processor metadata from a local directory.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
__call__ ¶
__call__(
*,
prompt: str | Sequence[str] | None = None,
labels: Sequence[str]
| Sequence[Sequence[str]]
| Int[Tensor, "batch elements"]
| Int[ndarray, "batch elements"]
| None = None,
id2label: dict[int, str] | None = None,
bbox: Float[Tensor, "batch elements 4"]
| Float[ndarray, "batch elements 4"]
| Sequence[ArrayLikeInput]
| None = None,
mask: Bool[Tensor, "batch elements"]
| Bool[ndarray, "batch elements"]
| Sequence[ArrayLikeInput]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
aspect_ratio: float
| Sequence[float]
| Float[Tensor, "batch"] = 1.0,
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
]
| None = None,
caption_padding_mask: Bool[Tensor, "batch tokens"]
| None = None,
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
]
| None = None,
) -> LayouSynBatch
Encode public text and concept inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str | Sequence[str] | None
|
Caption text or batch of captions. |
None
|
labels
|
Sequence[str] | Sequence[Sequence[str]] | Int[Tensor, 'batch elements'] | Int[ndarray, 'batch elements'] | None
|
String concepts or integer labels. |
None
|
id2label
|
dict[int, str] | None
|
Mapping required for integer labels when no fixed processor mapping exists. |
None
|
bbox
|
Float[Tensor, 'batch elements 4'] | Float[ndarray, 'batch elements 4'] | Sequence[ArrayLikeInput] | None
|
Optional conditioning boxes for future init/refinement paths. |
None
|
mask
|
Bool[Tensor, 'batch elements'] | Bool[ndarray, 'batch elements'] | Sequence[ArrayLikeInput] | None
|
Optional valid-element mask. |
None
|
box_format
|
BoxFormat | str
|
Public bbox format. |
xywh
|
normalized
|
bool
|
Whether bbox coordinates are normalized. |
True
|
canvas_size
|
tuple[int, int] | None
|
Required when |
None
|
aspect_ratio
|
float | Sequence[float] | Float[Tensor, 'batch']
|
Scalar or per-example aspect ratio. |
1.0
|
caption_embeds
|
Float[Tensor, 'batch tokens embedding_dim'] | None
|
Precomputed caption embeddings. |
None
|
caption_padding_mask
|
Bool[Tensor, 'batch tokens'] | None
|
Precomputed caption padding mask. |
None
|
concept_embeds
|
Float[Tensor, 'batch elements embedding_dim'] | None
|
Precomputed concept embeddings. |
None
|
Returns:
| Type | Description |
|---|---|
LayouSynBatch
|
Encoded processor batch. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required labels or embeddings are missing. |
Source code in models/layousyn/src/layousyn/processing_layousyn.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
postprocess ¶
postprocess(
sample: Float[Tensor, "batch elements 4"],
*,
labels: list[list[str]],
id2label: dict[int, str],
id2label_per_example: list[dict[int, str]]
| None = None,
output_type: Literal["dataclass", "dict"] = "dataclass",
return_intermediates: bool = False,
intermediates: LayouSynIntermediateValue | None = None,
) -> LayoutGenerationOutput | LayouSynOutputDict
Convert generated reference coordinates into the public schema.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 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 308 | |
LayouSynScheduler ¶
Bases: SchedulerMixin, ConfigMixin
OpenAI-style Gaussian scheduler for LayouSyn layout tensors.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
__init__ ¶
__init__(
*,
num_train_timesteps: int = 100,
beta_schedule: Literal[
"linear", "squaredcos_cap_v2"
] = "linear",
alpha_scale: float = 1.0,
prediction_type: Literal["epsilon"] = "epsilon",
variance_type: Literal[
"learned_range"
] = "learned_range",
sampling_type: Literal["ddim", "ddpm"] = "ddim",
) -> None
Initialize scheduler buffers.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
set_timesteps ¶
set_timesteps(
num_inference_steps: int | None = None,
device: device | str | None = None,
) -> None
Set descending denoising timesteps with reference respacing.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
initial_sample ¶
initial_sample(
batch_size: int,
seq_len: int,
channels: int,
*,
device: device,
generator: Generator | None = None,
) -> Float[torch.Tensor, "batch elements channels"]
Create initial Gaussian noise.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
add_noise ¶
add_noise(
original_samples: Float[
Tensor, "batch elements channels"
],
noise: Float[Tensor, "batch elements channels"],
timesteps: Int[Tensor, "batch"],
) -> Float[torch.Tensor, "batch elements channels"]
Add forward-process noise to clean samples.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
135 136 137 138 139 140 141 142 143 144 145 146 147 | |
step ¶
step(
model_output: Float[
Tensor, "batch model_elements channels"
],
timestep: Int[Tensor, "batch"],
sample: Float[Tensor, "batch elements channels"],
*,
generator: Generator | None = None,
eta: float = 0.0,
clip_denoised: bool = False,
sampling_type: Literal["ddim", "ddpm"] | None = None,
return_dict: bool = True,
) -> (
LayouSynSchedulerOutput
| tuple[Float[torch.Tensor, "batch elements channels"]]
)
Take one reverse diffusion step.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
configuration_layousyn ¶
Configuration helpers for converted LayouSyn checkpoints.
LayouSynModelShape ¶
Bases: TypedDict
Resolved DiT architecture shape.
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
16 17 18 19 20 21 | |
LayouSynReferenceConfig ¶
Bases: TypedDict
Reference repository JSON config payload.
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
LayouSynConfig ¶
Bases: ConfigMixin
Serializable LayouSyn configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Reference DiT architecture key. |
'DiT-S'
|
in_channels
|
int
|
Layout coordinate channels. |
4
|
concept_in_channels
|
int
|
Concept embedding width. |
768
|
y_in_channels
|
int | None
|
Caption embedding width. |
768
|
max_in_len
|
int
|
Maximum number of object slots. |
60
|
max_y_len
|
int | None
|
Maximum number of caption tokens. |
120
|
layout_type
|
LayoutType
|
Reference layout coordinate type. |
'xyxy'
|
t5_size
|
str | None
|
Reference T5 size suffix. |
'base'
|
scale
|
float
|
Default classifier-free guidance scale. |
2.0
|
noise_schedule
|
str
|
Reference diffusion beta schedule. |
'linear'
|
diffusion_steps
|
int
|
Number of diffusion training timesteps. |
100
|
hidden_size
|
int | None
|
Optional resolved hidden width override. |
None
|
depth
|
int | None
|
Optional resolved transformer depth override. |
None
|
num_heads
|
int | None
|
Optional resolved attention head override. |
None
|
license
|
str
|
Upstream checkpoint license identifier. |
'cc-by-nc-4.0'
|
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
__init__ ¶
__init__(
*,
model_name: str = "DiT-S",
in_channels: int = 4,
concept_in_channels: int = 768,
y_in_channels: int | None = 768,
max_in_len: int = 60,
max_y_len: int | None = 120,
layout_type: LayoutType = "xyxy",
t5_size: str | None = "base",
scale: float = 2.0,
noise_schedule: str = "linear",
diffusion_steps: int = 100,
hidden_size: int | None = None,
depth: int | None = None,
num_heads: int | None = None,
license: str = "cc-by-nc-4.0",
) -> None
Initialize configuration fields.
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
118 119 120 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 151 152 153 154 155 156 157 158 159 | |
from_reference_json
classmethod
¶
from_reference_json(path: str | Path) -> 'LayouSynConfig'
Load a reference JSON config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a Lay-Your-Scene JSON config. |
required |
Returns:
| Type | Description |
|---|---|
'LayouSynConfig'
|
Converted configuration object. |
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
to_reference_dict ¶
to_reference_dict() -> LayouSynReferenceConfig
Return the config keys expected by the original repository.
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
resolve_model_shape ¶
resolve_model_shape(
model_name: str,
*,
hidden_size: int | None = None,
depth: int | None = None,
num_heads: int | None = None,
) -> LayouSynModelShape
Resolve a reference DiT name to concrete architecture dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Reference model key such as |
required |
hidden_size
|
int | None
|
Optional explicit override. |
None
|
depth
|
int | None
|
Optional explicit override. |
None
|
num_heads
|
int | None
|
Optional explicit override. |
None
|
Returns:
| Type | Description |
|---|---|
LayouSynModelShape
|
Resolved architecture dimensions. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the model name is unsupported. |
Source code in models/layousyn/src/layousyn/configuration_layousyn.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
conversion ¶
Checkpoint conversion helpers for LayouSyn.
convert_checkpoint ¶
convert_checkpoint(
*,
checkpoint_path: str | Path,
config_path: str | Path,
output_dir: str | Path,
variant_name: str,
push_to_hub: bool = False,
hub_repo_id: str | None = None,
) -> LayouSynPipeline
Convert a vendor checkpoint into a local Diffusers pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path
|
str | Path
|
Vendor |
required |
config_path
|
str | Path
|
Vendor JSON config path. |
required |
output_dir
|
str | Path
|
Local output directory. |
required |
variant_name
|
str
|
Human-readable checkpoint variant metadata. |
required |
push_to_hub
|
bool
|
Reserved; ordinary implementation PRs must leave this false. |
False
|
hub_repo_id
|
str | None
|
Optional Hub repository id for future publishing. |
None
|
Returns:
| Type | Description |
|---|---|
LayouSynPipeline
|
Saved pipeline instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If Hub push is requested from this implementation helper. |
Source code in models/layousyn/src/layousyn/conversion.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
modeling_layousyn ¶
PyTorch modules for the converted LayouSyn DiT denoiser.
Mlp ¶
Bases: Module
Small MLP with timm-compatible fc1/fc2 parameter names.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
__init__ ¶
__init__(
in_features: int,
hidden_features: int,
out_features: int,
) -> None
Initialize the feed-forward projection.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
30 31 32 33 34 35 36 37 | |
forward ¶
forward(
x: Float[Tensor, "... in_features"],
) -> Float[torch.Tensor, "... out_features"]
Apply the MLP.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
39 40 41 42 43 | |
ScalarEmbedder ¶
Bases: Module
Reference sinusoidal scalar embedding plus MLP projection.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
__init__ ¶
__init__(
hidden_size: int, frequency_embedding_size: int = 256
) -> None
Initialize the embedder.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
49 50 51 52 53 54 55 56 57 | |
scalar_embedding
staticmethod
¶
scalar_embedding(
scalar: Float[Tensor, "batch"] | Int[Tensor, "batch"],
dim: int,
max_period: int = 10000,
) -> Float[torch.Tensor, "batch channels"]
Create sinusoidal embeddings for scalar values.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
forward ¶
forward(
scalar: Float[Tensor, "batch"] | Int[Tensor, "batch"],
) -> Float[torch.Tensor, "batch channels"]
Embed scalar values.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
80 81 82 83 84 | |
InputEmbedder ¶
Bases: Module
Linear layout-coordinate embedder.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
87 88 89 90 91 92 93 94 95 96 97 98 99 | |
__init__ ¶
__init__(input_dim: int, hidden_dim: int) -> None
Initialize projection.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
90 91 92 93 | |
forward ¶
forward(
x: Float[Tensor, "batch elements channels"],
) -> Float[torch.Tensor, "batch elements hidden"]
Project layout coordinates.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
95 96 97 98 99 | |
ConceptEmbedder ¶
Bases: Module
Project concept embeddings into the DiT hidden width.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
102 103 104 105 106 107 108 109 110 111 112 113 114 | |
__init__ ¶
__init__(in_channels: int, hidden_size: int) -> None
Initialize projection.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
105 106 107 108 | |
forward ¶
forward(
x: Float[Tensor, "batch elements channels"],
) -> Float[torch.Tensor, "batch elements hidden"]
Project concept embeddings.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
110 111 112 113 114 | |
CaptionEmbedderIdentity ¶
Bases: Module
No-op caption embedder for unconditional checkpoints.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
forward ¶
forward(
caption: Float[Tensor, "batch tokens embedding_dim"]
| None,
caption_padding_mask: Bool[Tensor, "batch tokens"]
| None,
train: bool,
force_drop_ids: Int[Tensor, "batch"]
| Bool[Tensor, "batch"]
| None = None,
) -> tuple[
Float[torch.Tensor, "batch tokens embedding_dim"]
| None,
Bool[torch.Tensor, "batch tokens"] | None,
]
Return caption inputs unchanged.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
CaptionEmbedder ¶
Bases: Module
Project caption embeddings and apply classifier-free label dropout.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
__init__ ¶
__init__(
in_channels: int,
hidden_size: int,
uncond_prob: float,
y_null_embedding: Float[Tensor, "tokens embedding_dim"],
y_null_embedding_mask: Bool[Tensor, "tokens"],
) -> None
Initialize caption projection and null caption buffers.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
token_drop ¶
token_drop(
caption: Float[Tensor, "batch tokens embedding_dim"],
caption_padding_mask: Bool[Tensor, "batch tokens"],
force_drop_ids: Int[Tensor, "batch"]
| Bool[Tensor, "batch"]
| None = None,
) -> tuple[
Float[torch.Tensor, "batch tokens embedding_dim"],
Bool[torch.Tensor, "batch tokens"],
]
Replace selected captions with the learned null caption.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
forward ¶
forward(
caption: Float[Tensor, "batch tokens embedding_dim"],
caption_padding_mask: Bool[Tensor, "batch tokens"],
train: bool,
force_drop_ids: Int[Tensor, "batch"]
| Bool[Tensor, "batch"]
| None = None,
) -> tuple[
Float[torch.Tensor, "batch tokens hidden"],
Bool[torch.Tensor, "batch tokens"],
]
Project caption embeddings.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
DiTBlock ¶
Bases: Module
LayouSyn conditional DiT block with concept and caption attention.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
__init__ ¶
__init__(
hidden_size: int, num_heads: int, mlp_ratio: float = 4.0
) -> None
Initialize one conditional block.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
forward ¶
forward(
x: Float[Tensor, "batch elements hidden"],
x_enc: Float[Tensor, "batch elements hidden"],
x_padding_mask: Bool[Tensor, "batch elements"],
c: Float[Tensor, "batch hidden"],
y: Float[Tensor, "batch tokens hidden"],
y_padding_mask: Bool[Tensor, "batch tokens"],
pos_embed: Float[Tensor, "1 elements hidden"],
) -> tuple[
Float[torch.Tensor, "batch elements hidden"],
Float[torch.Tensor, "batch elements hidden"],
]
Apply one conditional block.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
initialize_weights ¶
initialize_weights() -> None
Zero reference adaLN and cross-attention output projections.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
285 286 287 288 289 290 291 | |
DiTUCBlock ¶
Bases: Module
LayouSyn unconditional DiT block.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
294 295 296 297 298 299 300 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 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
__init__ ¶
__init__(
hidden_size: int, num_heads: int, mlp_ratio: float = 4.0
) -> None
Initialize one unconditional block.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
forward ¶
forward(
x: Float[Tensor, "batch elements hidden"],
x_padding_mask: Bool[Tensor, "batch elements"],
c: Float[Tensor, "batch hidden"],
**kwargs: str | int | float | bool | None,
) -> Float[torch.Tensor, "batch elements hidden"]
Apply one unconditional block.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
initialize_weights ¶
initialize_weights() -> None
Zero reference adaLN projection.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
339 340 341 342 343 | |
FinalLayer ¶
Bases: Module
Reference final adaLN projection.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
__init__ ¶
__init__(hidden_size: int, out_channels: int) -> None
Initialize final layer.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
349 350 351 352 353 354 355 356 | |
forward ¶
forward(
x: Float[Tensor, "batch elements hidden"],
c: Float[Tensor, "batch hidden"],
) -> Float[torch.Tensor, "batch elements channels"]
Project hidden states to epsilon and variance channels.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
358 359 360 361 362 363 364 365 | |
LayouSynDiTModel ¶
Bases: ModelMixin, ConfigMixin
Converted LayouSyn DiT denoiser.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
__init__ ¶
__init__(
*,
in_channels: int = 4,
max_in_len: int = 60,
concept_in_channels: int = 768,
y_in_channels: int | None = 768,
max_y_len: int | None = 120,
model_name: str = "DiT-S",
hidden_size: int | None = None,
depth: int | None = None,
num_heads: int | None = None,
mlp_ratio: float = 4.0,
class_dropout_prob: float = 0.1,
learn_sigma: bool = True,
is_unconditional: bool = False,
) -> None
Initialize the converted DiT model.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 452 453 454 455 | |
initialize_weights ¶
initialize_weights() -> None
Initialize weights with the reference policy.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
forward ¶
forward(
sample: Float[Tensor, "batch elements channels"],
timestep: Int[Tensor, "batch"],
*,
x_padding_mask: Bool[Tensor, "batch elements"],
aspect_ratio: Float[Tensor, "batch"],
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
],
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
]
| None = None,
caption_padding_mask: Bool[Tensor, "batch tokens"]
| None = None,
) -> Float[torch.Tensor, "batch seq channels"]
Predict epsilon and variance channels for one timestep.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
forward_with_cfg ¶
forward_with_cfg(
sample: Float[Tensor, "batch elements channels"],
timestep: Int[Tensor, "batch"],
*,
x_padding_mask: Bool[Tensor, "batch elements"],
aspect_ratio: Float[Tensor, "batch"],
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
],
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
],
caption_padding_mask: Bool[Tensor, "batch tokens"],
guidance_scale: float,
) -> Float[torch.Tensor, "batch seq channels"]
Run reference classifier-free guidance batching.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
modulate ¶
modulate(
x: Float[Tensor, "batch tokens channels"],
shift: Float[Tensor, "batch channels"],
scale: Float[Tensor, "batch channels"],
) -> Float[torch.Tensor, "batch tokens channels"]
Apply adaLN shift and scale.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
18 19 20 21 22 23 24 | |
get_1d_sincos_pos_embed ¶
get_1d_sincos_pos_embed(
embed_dim: int, max_len: int
) -> Float[np.ndarray, "positions embed_dim"]
Create reference sine/cosine positional embeddings.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
368 369 370 371 372 373 | |
get_1d_sincos_pos_embed_from_grid ¶
get_1d_sincos_pos_embed_from_grid(
embed_dim: int, pos: Float[ndarray, "positions"]
) -> Float[np.ndarray, "positions embed_dim"]
Create reference sine/cosine positional embeddings from positions.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
376 377 378 379 380 381 382 383 384 | |
convert_reference_state_dict ¶
convert_reference_state_dict(
state_dict: dict[str, Shaped[Tensor, "..."]],
) -> dict[str, Shaped[torch.Tensor, "..."]]
Convert a reference DiT state dict to the wrapped model key space.
Source code in models/layousyn/src/layousyn/modeling_layousyn.py
560 561 562 563 564 | |
pipeline_layousyn ¶
Diffusers pipeline for converted LayouSyn text-to-layout generation.
LayouSynPipeline ¶
Bases: DiffusionPipeline
Generate open-vocabulary scene layouts with LayouSyn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
LayouSynDiTModel
|
Converted DiT denoiser. |
required |
scheduler
|
LayouSynScheduler
|
LayouSyn Gaussian/DDIM scheduler. |
required |
processor
|
LayouSynProcessor
|
Processor for prompt/concept inputs and postprocessing. |
required |
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 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 308 309 310 | |
components
property
¶
components: dict[
str,
LayouSynDiTModel
| LayouSynScheduler
| LayouSynProcessor,
]
Return serializable pipeline components.
__init__ ¶
__init__(
model: LayouSynDiTModel,
scheduler: LayouSynScheduler,
processor: LayouSynProcessor,
) -> None
Initialize the pipeline.
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
46 47 48 49 50 51 52 53 54 55 | |
save_pretrained ¶
save_pretrained(
save_directory: str | PathLike[str],
**kwargs: str | int | float | bool | None,
) -> None
Save pipeline components plus processor metadata.
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
80 81 82 83 84 85 86 87 | |
from_pretrained
classmethod
¶
from_pretrained(
pretrained_model_name_or_path: str | PathLike[str],
**kwargs: str | int | float | bool | None,
) -> LayouSynPipeline
Load pipeline and restore local processor metadata.
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
__call__ ¶
__call__(
*,
prompt: str | list[str] | None = None,
batch_size: int = 1,
seed: int | None = None,
generator: Generator | None = None,
condition_type: ConditionType
| str = ConditionType.text,
labels: Int[Tensor, "batch elements"]
| Int[ndarray, "batch elements"]
| list[str]
| list[list[str]]
| None = None,
id2label: dict[int, str] | None = None,
bbox: Float[Tensor, "batch elements 4"]
| Float[ndarray, "batch elements 4"]
| Sequence[ArrayLikeInput]
| None = None,
mask: Bool[Tensor, "batch elements"]
| Bool[ndarray, "batch elements"]
| Sequence[ArrayLikeInput]
| None = None,
num_elements: int
| list[int]
| Int[Tensor, "batch"]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
aspect_ratio: float
| list[float]
| Float[Tensor, "batch"] = 1.0,
num_inference_steps: int | None = None,
guidance_scale: float = 2.0,
sampling_type: Literal["ddim", "ddpm"] = "ddim",
output_type: Literal["dataclass", "dict"] = "dataclass",
return_intermediates: bool = False,
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
]
| None = None,
caption_padding_mask: Bool[Tensor, "batch tokens"]
| None = None,
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
]
| None = None,
) -> LayoutGenerationOutput | LayouSynOutputDict
Run LayouSyn denoising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str | list[str] | None
|
Caption text. |
None
|
batch_size
|
int
|
Number of generated layouts when labels are unbatched. |
1
|
seed
|
int | None
|
Convenience seed used only if |
None
|
generator
|
Generator | None
|
Exact reproducibility API. |
None
|
condition_type
|
ConditionType | str
|
Canonical condition name. First-class public mode is
|
text
|
labels
|
Int[Tensor, 'batch elements'] | Int[ndarray, 'batch elements'] | list[str] | list[list[str]] | None
|
String concepts or integer ids. |
None
|
id2label
|
dict[int, str] | None
|
Mapping for integer labels. |
None
|
bbox
|
Float[Tensor, 'batch elements 4'] | Float[ndarray, 'batch elements 4'] | Sequence[ArrayLikeInput] | None
|
Reserved for future initialization/refinement support. |
None
|
mask
|
Bool[Tensor, 'batch elements'] | Bool[ndarray, 'batch elements'] | Sequence[ArrayLikeInput] | None
|
Optional valid concept mask. |
None
|
num_elements
|
int | list[int] | Int[Tensor, 'batch'] | None
|
Optional expected element count. It is validated against labels when supplied. |
None
|
box_format
|
BoxFormat | str
|
Public input bbox format. |
xywh
|
normalized
|
bool
|
Whether input boxes are normalized. |
True
|
canvas_size
|
tuple[int, int] | None
|
Required for pixel boxes. |
None
|
aspect_ratio
|
float | list[float] | Float[Tensor, 'batch']
|
Scalar or per-example aspect ratio. |
1.0
|
num_inference_steps
|
int | None
|
Number of reverse diffusion steps. |
None
|
guidance_scale
|
float
|
Classifier-free guidance scale. |
2.0
|
sampling_type
|
Literal['ddim', 'ddpm']
|
|
'ddim'
|
output_type
|
Literal['dataclass', 'dict']
|
|
'dataclass'
|
return_intermediates
|
bool
|
Whether to return denoising trajectory. |
False
|
caption_embeds
|
Float[Tensor, 'batch tokens embedding_dim'] | None
|
Precomputed caption embeddings. |
None
|
caption_padding_mask
|
Bool[Tensor, 'batch tokens'] | None
|
Precomputed caption padding mask. |
None
|
concept_embeds
|
Float[Tensor, 'batch elements embedding_dim'] | None
|
Precomputed concept embeddings. |
None
|
Returns:
| Type | Description |
|---|---|
LayoutGenerationOutput | LayouSynOutputDict
|
Public layout output. |
Source code in models/layousyn/src/layousyn/pipeline_layousyn.py
109 110 111 112 113 114 115 116 117 118 119 120 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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
processing_layousyn ¶
Processor for LayouSyn text/concept-conditioned layout tensors.
LayouSynBatch ¶
Bases: TypedDict
Encoded LayouSyn processor batch.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
36 37 38 39 40 41 42 43 44 45 46 | |
LayouSynIntermediateValue ¶
Bases: TypedDict
Optional auxiliary payload passed into post-processing.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
49 50 51 52 53 | |
LayouSynOutputIntermediates ¶
Bases: TypedDict
LayouSyn auxiliary output metadata.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
56 57 58 59 60 61 62 | |
LayouSynOutputDict ¶
Bases: TypedDict
Dictionary form of LayouSyn public output.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
65 66 67 68 69 70 71 72 | |
LayouSynProcessor ¶
Bases: ProcessorMixin
Encode prompts and open-vocabulary concepts for LayouSyn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout_type
|
Literal['xyxy', 'cxcywh']
|
Reference layout type used by generated coordinates. |
'xyxy'
|
max_in_len
|
int
|
Maximum number of concept slots. |
60
|
caption_model_name
|
str
|
Text encoder identifier used for captions. |
't5-v1_1-base'
|
concept_model_name
|
str
|
Sentence-transformers model id for concept labels. |
'sentence-transformers/sentence-t5-base'
|
id2label
|
dict[int, str] | None
|
Optional fixed vocabulary for integer labels. |
None
|
open_vocabulary
|
bool
|
Whether string labels are accepted per request. |
True
|
Source code in models/layousyn/src/layousyn/processing_layousyn.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 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 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 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 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
__init__ ¶
__init__(
*,
layout_type: Literal["xyxy", "cxcywh"] = "xyxy",
max_in_len: int = 60,
max_y_len: int = 120,
concept_in_channels: int = 768,
y_in_channels: int = 768,
caption_model_name: str = "t5-v1_1-base",
concept_model_name: str = "sentence-transformers/sentence-t5-base",
id2label: dict[int, str] | None = None,
open_vocabulary: bool = True,
) -> None
Initialize processor metadata.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
to_dict ¶
to_dict() -> dict[
str, str | int | bool | dict[int, str] | None
]
Serialize processor metadata.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
save_pretrained ¶
save_pretrained(
save_directory: str | Path,
push_to_hub: bool = False,
**kwargs: str | int | float | bool | None,
) -> tuple[str]
Save processor metadata.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
from_pretrained
classmethod
¶
from_pretrained(
pretrained_model_name_or_path: str | PathLike[str],
cache_dir: str | PathLike[str] | None = None,
force_download: bool = False,
local_files_only: bool = False,
token: str | bool | None = None,
revision: str = "main",
**kwargs: str | int | float | bool | None,
) -> LayouSynProcessor
Load processor metadata from a local directory.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
__call__ ¶
__call__(
*,
prompt: str | Sequence[str] | None = None,
labels: Sequence[str]
| Sequence[Sequence[str]]
| Int[Tensor, "batch elements"]
| Int[ndarray, "batch elements"]
| None = None,
id2label: dict[int, str] | None = None,
bbox: Float[Tensor, "batch elements 4"]
| Float[ndarray, "batch elements 4"]
| Sequence[ArrayLikeInput]
| None = None,
mask: Bool[Tensor, "batch elements"]
| Bool[ndarray, "batch elements"]
| Sequence[ArrayLikeInput]
| None = None,
box_format: BoxFormat | str = BoxFormat.xywh,
normalized: bool = True,
canvas_size: tuple[int, int] | None = None,
aspect_ratio: float
| Sequence[float]
| Float[Tensor, "batch"] = 1.0,
caption_embeds: Float[
Tensor, "batch tokens embedding_dim"
]
| None = None,
caption_padding_mask: Bool[Tensor, "batch tokens"]
| None = None,
concept_embeds: Float[
Tensor, "batch elements embedding_dim"
]
| None = None,
) -> LayouSynBatch
Encode public text and concept inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str | Sequence[str] | None
|
Caption text or batch of captions. |
None
|
labels
|
Sequence[str] | Sequence[Sequence[str]] | Int[Tensor, 'batch elements'] | Int[ndarray, 'batch elements'] | None
|
String concepts or integer labels. |
None
|
id2label
|
dict[int, str] | None
|
Mapping required for integer labels when no fixed processor mapping exists. |
None
|
bbox
|
Float[Tensor, 'batch elements 4'] | Float[ndarray, 'batch elements 4'] | Sequence[ArrayLikeInput] | None
|
Optional conditioning boxes for future init/refinement paths. |
None
|
mask
|
Bool[Tensor, 'batch elements'] | Bool[ndarray, 'batch elements'] | Sequence[ArrayLikeInput] | None
|
Optional valid-element mask. |
None
|
box_format
|
BoxFormat | str
|
Public bbox format. |
xywh
|
normalized
|
bool
|
Whether bbox coordinates are normalized. |
True
|
canvas_size
|
tuple[int, int] | None
|
Required when |
None
|
aspect_ratio
|
float | Sequence[float] | Float[Tensor, 'batch']
|
Scalar or per-example aspect ratio. |
1.0
|
caption_embeds
|
Float[Tensor, 'batch tokens embedding_dim'] | None
|
Precomputed caption embeddings. |
None
|
caption_padding_mask
|
Bool[Tensor, 'batch tokens'] | None
|
Precomputed caption padding mask. |
None
|
concept_embeds
|
Float[Tensor, 'batch elements embedding_dim'] | None
|
Precomputed concept embeddings. |
None
|
Returns:
| Type | Description |
|---|---|
LayouSynBatch
|
Encoded processor batch. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required labels or embeddings are missing. |
Source code in models/layousyn/src/layousyn/processing_layousyn.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
postprocess ¶
postprocess(
sample: Float[Tensor, "batch elements 4"],
*,
labels: list[list[str]],
id2label: dict[int, str],
id2label_per_example: list[dict[int, str]]
| None = None,
output_type: Literal["dataclass", "dict"] = "dataclass",
return_intermediates: bool = False,
intermediates: LayouSynIntermediateValue | None = None,
) -> LayoutGenerationOutput | LayouSynOutputDict
Convert generated reference coordinates into the public schema.
Source code in models/layousyn/src/layousyn/processing_layousyn.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 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 308 | |
scheduling_layousyn ¶
Scheduler preserving LayouSyn's OpenAI Gaussian/DDIM diffusion math.
LayouSynSchedulerOutput
dataclass
¶
Bases: BaseOutput
Output returned by a LayouSyn scheduler step.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
18 19 20 21 22 23 | |
LayouSynScheduler ¶
Bases: SchedulerMixin, ConfigMixin
OpenAI-style Gaussian scheduler for LayouSyn layout tensors.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
__init__ ¶
__init__(
*,
num_train_timesteps: int = 100,
beta_schedule: Literal[
"linear", "squaredcos_cap_v2"
] = "linear",
alpha_scale: float = 1.0,
prediction_type: Literal["epsilon"] = "epsilon",
variance_type: Literal[
"learned_range"
] = "learned_range",
sampling_type: Literal["ddim", "ddpm"] = "ddim",
) -> None
Initialize scheduler buffers.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
set_timesteps ¶
set_timesteps(
num_inference_steps: int | None = None,
device: device | str | None = None,
) -> None
Set descending denoising timesteps with reference respacing.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
initial_sample ¶
initial_sample(
batch_size: int,
seq_len: int,
channels: int,
*,
device: device,
generator: Generator | None = None,
) -> Float[torch.Tensor, "batch elements channels"]
Create initial Gaussian noise.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
add_noise ¶
add_noise(
original_samples: Float[
Tensor, "batch elements channels"
],
noise: Float[Tensor, "batch elements channels"],
timesteps: Int[Tensor, "batch"],
) -> Float[torch.Tensor, "batch elements channels"]
Add forward-process noise to clean samples.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
135 136 137 138 139 140 141 142 143 144 145 146 147 | |
step ¶
step(
model_output: Float[
Tensor, "batch model_elements channels"
],
timestep: Int[Tensor, "batch"],
sample: Float[Tensor, "batch elements channels"],
*,
generator: Generator | None = None,
eta: float = 0.0,
clip_denoised: bool = False,
sampling_type: Literal["ddim", "ddpm"] | None = None,
return_dict: bool = True,
) -> (
LayouSynSchedulerOutput
| tuple[Float[torch.Tensor, "batch elements channels"]]
)
Take one reverse diffusion step.
Source code in models/layousyn/src/layousyn/scheduling_layousyn.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |