|
23 | 23 | is_transformers_available, |
24 | 24 | ) |
25 | 25 |
|
26 | | - |
27 | 26 | # Lazy Import based on |
28 | 27 | # https://github.com/huggingface/transformers/blob/main/src/transformers/__init__.py |
29 | 28 |
|
|
60 | 59 | } |
61 | 60 |
|
62 | 61 | try: |
63 | | - if not is_torch_available() and not is_accelerate_available() and not is_bitsandbytes_available(): |
| 62 | + if ( |
| 63 | + not is_torch_available() |
| 64 | + and not is_accelerate_available() |
| 65 | + and not is_bitsandbytes_available() |
| 66 | + ): |
64 | 67 | raise OptionalDependencyNotAvailable() |
65 | 68 | except OptionalDependencyNotAvailable: |
66 | 69 | from .utils import dummy_bitsandbytes_objects |
|
72 | 75 | _import_structure["quantizers.quantization_config"].append("BitsAndBytesConfig") |
73 | 76 |
|
74 | 77 | try: |
75 | | - if not is_torch_available() and not is_accelerate_available() and not is_gguf_available(): |
| 78 | + if ( |
| 79 | + not is_torch_available() |
| 80 | + and not is_accelerate_available() |
| 81 | + and not is_gguf_available() |
| 82 | + ): |
76 | 83 | raise OptionalDependencyNotAvailable() |
77 | 84 | except OptionalDependencyNotAvailable: |
78 | 85 | from .utils import dummy_gguf_objects |
|
84 | 91 | _import_structure["quantizers.quantization_config"].append("GGUFQuantizationConfig") |
85 | 92 |
|
86 | 93 | try: |
87 | | - if not is_torch_available() and not is_accelerate_available() and not is_torchao_available(): |
| 94 | + if ( |
| 95 | + not is_torch_available() |
| 96 | + and not is_accelerate_available() |
| 97 | + and not is_torchao_available() |
| 98 | + ): |
88 | 99 | raise OptionalDependencyNotAvailable() |
89 | 100 | except OptionalDependencyNotAvailable: |
90 | 101 | from .utils import dummy_torchao_objects |
|
96 | 107 | _import_structure["quantizers.quantization_config"].append("TorchAoConfig") |
97 | 108 |
|
98 | 109 | try: |
99 | | - if not is_torch_available() and not is_accelerate_available() and not is_optimum_quanto_available(): |
| 110 | + if ( |
| 111 | + not is_torch_available() |
| 112 | + and not is_accelerate_available() |
| 113 | + and not is_optimum_quanto_available() |
| 114 | + ): |
100 | 115 | raise OptionalDependencyNotAvailable() |
101 | 116 | except OptionalDependencyNotAvailable: |
102 | 117 | from .utils import dummy_optimum_quanto_objects |
|
126 | 141 | except OptionalDependencyNotAvailable: |
127 | 142 | from .utils import dummy_pt_objects # noqa F403 |
128 | 143 |
|
129 | | - _import_structure["utils.dummy_pt_objects"] = [name for name in dir(dummy_pt_objects) if not name.startswith("_")] |
| 144 | + _import_structure["utils.dummy_pt_objects"] = [ |
| 145 | + name for name in dir(dummy_pt_objects) if not name.startswith("_") |
| 146 | + ] |
130 | 147 |
|
131 | 148 | else: |
132 | 149 | _import_structure["hooks"].extend( |
|
187 | 204 | "OmniGenTransformer2DModel", |
188 | 205 | "PixArtTransformer2DModel", |
189 | 206 | "PriorTransformer", |
| 207 | + "SanaControlNetModel", |
190 | 208 | "SanaTransformer2DModel", |
191 | 209 | "SD3ControlNetModel", |
192 | 210 | "SD3MultiControlNetModel", |
|
303 | 321 | from .utils import dummy_torch_and_torchsde_objects # noqa F403 |
304 | 322 |
|
305 | 323 | _import_structure["utils.dummy_torch_and_torchsde_objects"] = [ |
306 | | - name for name in dir(dummy_torch_and_torchsde_objects) if not name.startswith("_") |
| 324 | + name |
| 325 | + for name in dir(dummy_torch_and_torchsde_objects) |
| 326 | + if not name.startswith("_") |
307 | 327 | ] |
308 | 328 |
|
309 | 329 | else: |
310 | | - _import_structure["schedulers"].extend(["CosineDPMSolverMultistepScheduler", "DPMSolverSDEScheduler"]) |
| 330 | + _import_structure["schedulers"].extend( |
| 331 | + ["CosineDPMSolverMultistepScheduler", "DPMSolverSDEScheduler"] |
| 332 | + ) |
311 | 333 |
|
312 | 334 | try: |
313 | 335 | if not (is_torch_available() and is_transformers_available()): |
|
316 | 338 | from .utils import dummy_torch_and_transformers_objects # noqa F403 |
317 | 339 |
|
318 | 340 | _import_structure["utils.dummy_torch_and_transformers_objects"] = [ |
319 | | - name for name in dir(dummy_torch_and_transformers_objects) if not name.startswith("_") |
| 341 | + name |
| 342 | + for name in dir(dummy_torch_and_transformers_objects) |
| 343 | + if not name.startswith("_") |
320 | 344 | ] |
321 | 345 |
|
322 | 346 | else: |
|
424 | 448 | "PixArtSigmaPAGPipeline", |
425 | 449 | "PixArtSigmaPipeline", |
426 | 450 | "ReduxImageEncoder", |
| 451 | + "SanaControlNetPipeline", |
427 | 452 | "SanaPAGPipeline", |
428 | 453 | "SanaPipeline", |
429 | 454 | "SanaSprintPipeline", |
|
517 | 542 | ) |
518 | 543 |
|
519 | 544 | try: |
520 | | - if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()): |
| 545 | + if not ( |
| 546 | + is_torch_available() |
| 547 | + and is_transformers_available() |
| 548 | + and is_k_diffusion_available() |
| 549 | + ): |
521 | 550 | raise OptionalDependencyNotAvailable() |
522 | 551 | except OptionalDependencyNotAvailable: |
523 | 552 | from .utils import dummy_torch_and_transformers_and_k_diffusion_objects # noqa F403 |
524 | 553 |
|
525 | 554 | _import_structure["utils.dummy_torch_and_transformers_and_k_diffusion_objects"] = [ |
526 | | - name for name in dir(dummy_torch_and_transformers_and_k_diffusion_objects) if not name.startswith("_") |
| 555 | + name |
| 556 | + for name in dir(dummy_torch_and_transformers_and_k_diffusion_objects) |
| 557 | + if not name.startswith("_") |
527 | 558 | ] |
528 | 559 |
|
529 | 560 | else: |
530 | | - _import_structure["pipelines"].extend(["StableDiffusionKDiffusionPipeline", "StableDiffusionXLKDiffusionPipeline"]) |
| 561 | + _import_structure["pipelines"].extend( |
| 562 | + ["StableDiffusionKDiffusionPipeline", "StableDiffusionXLKDiffusionPipeline"] |
| 563 | + ) |
531 | 564 |
|
532 | 565 | try: |
533 | | - if not (is_torch_available() and is_transformers_available() and is_sentencepiece_available()): |
| 566 | + if not ( |
| 567 | + is_torch_available() |
| 568 | + and is_transformers_available() |
| 569 | + and is_sentencepiece_available() |
| 570 | + ): |
534 | 571 | raise OptionalDependencyNotAvailable() |
535 | 572 | except OptionalDependencyNotAvailable: |
536 | | - from .utils import dummy_torch_and_transformers_and_sentencepiece_objects # noqa F403 |
| 573 | + from .utils import ( # noqa F403 |
| 574 | + dummy_torch_and_transformers_and_sentencepiece_objects, |
| 575 | + ) |
537 | 576 |
|
538 | | - _import_structure["utils.dummy_torch_and_transformers_and_sentencepiece_objects"] = [ |
539 | | - name for name in dir(dummy_torch_and_transformers_and_sentencepiece_objects) if not name.startswith("_") |
| 577 | + _import_structure[ |
| 578 | + "utils.dummy_torch_and_transformers_and_sentencepiece_objects" |
| 579 | + ] = [ |
| 580 | + name |
| 581 | + for name in dir(dummy_torch_and_transformers_and_sentencepiece_objects) |
| 582 | + if not name.startswith("_") |
540 | 583 | ] |
541 | 584 |
|
542 | 585 | else: |
543 | | - _import_structure["pipelines"].extend(["KolorsImg2ImgPipeline", "KolorsPAGPipeline", "KolorsPipeline"]) |
| 586 | + _import_structure["pipelines"].extend( |
| 587 | + ["KolorsImg2ImgPipeline", "KolorsPAGPipeline", "KolorsPipeline"] |
| 588 | + ) |
544 | 589 |
|
545 | 590 | try: |
546 | | - if not (is_torch_available() and is_transformers_available() and is_onnx_available()): |
| 591 | + if not ( |
| 592 | + is_torch_available() and is_transformers_available() and is_onnx_available() |
| 593 | + ): |
547 | 594 | raise OptionalDependencyNotAvailable() |
548 | 595 | except OptionalDependencyNotAvailable: |
549 | 596 | from .utils import dummy_torch_and_transformers_and_onnx_objects # noqa F403 |
550 | 597 |
|
551 | 598 | _import_structure["utils.dummy_torch_and_transformers_and_onnx_objects"] = [ |
552 | | - name for name in dir(dummy_torch_and_transformers_and_onnx_objects) if not name.startswith("_") |
| 599 | + name |
| 600 | + for name in dir(dummy_torch_and_transformers_and_onnx_objects) |
| 601 | + if not name.startswith("_") |
553 | 602 | ] |
554 | 603 |
|
555 | 604 | else: |
|
571 | 620 | from .utils import dummy_torch_and_librosa_objects # noqa F403 |
572 | 621 |
|
573 | 622 | _import_structure["utils.dummy_torch_and_librosa_objects"] = [ |
574 | | - name for name in dir(dummy_torch_and_librosa_objects) if not name.startswith("_") |
| 623 | + name |
| 624 | + for name in dir(dummy_torch_and_librosa_objects) |
| 625 | + if not name.startswith("_") |
575 | 626 | ] |
576 | 627 |
|
577 | 628 | else: |
578 | 629 | _import_structure["pipelines"].extend(["AudioDiffusionPipeline", "Mel"]) |
579 | 630 |
|
580 | 631 | try: |
581 | | - if not (is_transformers_available() and is_torch_available() and is_note_seq_available()): |
| 632 | + if not ( |
| 633 | + is_transformers_available() and is_torch_available() and is_note_seq_available() |
| 634 | + ): |
582 | 635 | raise OptionalDependencyNotAvailable() |
583 | 636 | except OptionalDependencyNotAvailable: |
584 | 637 | from .utils import dummy_transformers_and_torch_and_note_seq_objects # noqa F403 |
585 | 638 |
|
586 | 639 | _import_structure["utils.dummy_transformers_and_torch_and_note_seq_objects"] = [ |
587 | | - name for name in dir(dummy_transformers_and_torch_and_note_seq_objects) if not name.startswith("_") |
| 640 | + name |
| 641 | + for name in dir(dummy_transformers_and_torch_and_note_seq_objects) |
| 642 | + if not name.startswith("_") |
588 | 643 | ] |
589 | 644 |
|
590 | 645 |
|
|
605 | 660 | else: |
606 | 661 | _import_structure["models.controlnets.controlnet_flax"] = ["FlaxControlNetModel"] |
607 | 662 | _import_structure["models.modeling_flax_utils"] = ["FlaxModelMixin"] |
608 | | - _import_structure["models.unets.unet_2d_condition_flax"] = ["FlaxUNet2DConditionModel"] |
| 663 | + _import_structure["models.unets.unet_2d_condition_flax"] = [ |
| 664 | + "FlaxUNet2DConditionModel" |
| 665 | + ] |
609 | 666 | _import_structure["models.vae_flax"] = ["FlaxAutoencoderKL"] |
610 | 667 | _import_structure["pipelines"].extend(["FlaxDiffusionPipeline"]) |
611 | 668 | _import_structure["schedulers"].extend( |
|
630 | 687 | from .utils import dummy_flax_and_transformers_objects # noqa F403 |
631 | 688 |
|
632 | 689 | _import_structure["utils.dummy_flax_and_transformers_objects"] = [ |
633 | | - name for name in dir(dummy_flax_and_transformers_objects) if not name.startswith("_") |
| 690 | + name |
| 691 | + for name in dir(dummy_flax_and_transformers_objects) |
| 692 | + if not name.startswith("_") |
634 | 693 | ] |
635 | 694 |
|
636 | 695 |
|
|
763 | 822 | OmniGenTransformer2DModel, |
764 | 823 | PixArtTransformer2DModel, |
765 | 824 | PriorTransformer, |
| 825 | + SanaControlNetModel, |
766 | 826 | SanaTransformer2DModel, |
767 | 827 | SD3ControlNetModel, |
768 | 828 | SD3MultiControlNetModel, |
|
979 | 1039 | PixArtSigmaPAGPipeline, |
980 | 1040 | PixArtSigmaPipeline, |
981 | 1041 | ReduxImageEncoder, |
| 1042 | + SanaControlNetPipeline, |
982 | 1043 | SanaPAGPipeline, |
983 | 1044 | SanaPipeline, |
984 | 1045 | SanaSprintPipeline, |
|
1070 | 1131 | ) |
1071 | 1132 |
|
1072 | 1133 | try: |
1073 | | - if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()): |
| 1134 | + if not ( |
| 1135 | + is_torch_available() |
| 1136 | + and is_transformers_available() |
| 1137 | + and is_k_diffusion_available() |
| 1138 | + ): |
1074 | 1139 | raise OptionalDependencyNotAvailable() |
1075 | 1140 | except OptionalDependencyNotAvailable: |
1076 | 1141 | from .utils.dummy_torch_and_transformers_and_k_diffusion_objects import * # noqa F403 |
1077 | 1142 | else: |
1078 | | - from .pipelines import StableDiffusionKDiffusionPipeline, StableDiffusionXLKDiffusionPipeline |
| 1143 | + from .pipelines import ( |
| 1144 | + StableDiffusionKDiffusionPipeline, |
| 1145 | + StableDiffusionXLKDiffusionPipeline, |
| 1146 | + ) |
1079 | 1147 |
|
1080 | 1148 | try: |
1081 | | - if not (is_torch_available() and is_transformers_available() and is_sentencepiece_available()): |
| 1149 | + if not ( |
| 1150 | + is_torch_available() |
| 1151 | + and is_transformers_available() |
| 1152 | + and is_sentencepiece_available() |
| 1153 | + ): |
1082 | 1154 | raise OptionalDependencyNotAvailable() |
1083 | 1155 | except OptionalDependencyNotAvailable: |
1084 | 1156 | from .utils.dummy_torch_and_transformers_and_sentencepiece_objects import * # noqa F403 |
1085 | 1157 | else: |
1086 | 1158 | from .pipelines import KolorsImg2ImgPipeline, KolorsPAGPipeline, KolorsPipeline |
1087 | 1159 | try: |
1088 | | - if not (is_torch_available() and is_transformers_available() and is_onnx_available()): |
| 1160 | + if not ( |
| 1161 | + is_torch_available() and is_transformers_available() and is_onnx_available() |
| 1162 | + ): |
1089 | 1163 | raise OptionalDependencyNotAvailable() |
1090 | 1164 | except OptionalDependencyNotAvailable: |
1091 | 1165 | from .utils.dummy_torch_and_transformers_and_onnx_objects import * # noqa F403 |
|
1108 | 1182 | from .pipelines import AudioDiffusionPipeline, Mel |
1109 | 1183 |
|
1110 | 1184 | try: |
1111 | | - if not (is_transformers_available() and is_torch_available() and is_note_seq_available()): |
| 1185 | + if not ( |
| 1186 | + is_transformers_available() |
| 1187 | + and is_torch_available() |
| 1188 | + and is_note_seq_available() |
| 1189 | + ): |
1112 | 1190 | raise OptionalDependencyNotAvailable() |
1113 | 1191 | except OptionalDependencyNotAvailable: |
1114 | 1192 | from .utils.dummy_transformers_and_torch_and_note_seq_objects import * # noqa F403 |
|
0 commit comments