1import torch
2from diffusers import DiffusionPipeline, EulerAncestralDiscreteScheduler
3from diffusers.models import PixArtTransformer2DModel
4model_id = "toilaluan/SigmaJourney"
5negative_prompt = "malformed, disgusting, overexposed, washed-out"
6pipeline = DiffusionPipeline.from_pretrained("PixArt-alpha/PixArt-Sigma-XL-2-1024-MS", torch_dtype=torch.float16)
7pipeline.transformer = PixArtTransformer2DModel.from_pretrained(model_id, subfolder="transformer", torch_dtype=torch.float16)
8pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(pipeline.scheduler.config)
9pipeline.to('cuda' if torch.cuda.is_available() else 'cpu')
10
11prompt = "On the left, there is a red cube. On the right, there is a blue sphere. On top of the red cube is a dog. On top of the blue sphere is a cat"
12image = pipeline(
13 prompt=prompt,
14 negative_prompt='blurry, cropped, ugly',
15 num_inference_steps=30,
16 generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(1641421826),
17 width=1024,
18 height=1024,
19 guidance_scale=5.5,
20).images[0]
21image.save("output.png", format="JPEG")
PixArt-Σ consists of pure transformer blocks for latent diffusion:
It can directly generate 1024px, 2K and 4K images from text prompts within a single sampling process.
For research purposes, we recommend our
generative-models Github repository (
https://github.com/PixArt-alpha/PixArt-sigma),
which is more suitable for both training and inference and for which most advanced diffusion sampler like
SA-Solver will be added over time.
Hugging Face provides free PixArt-Σ inference.
1import torch
2from diffusers import Transformer2DModel, PixArtSigmaPipeline
3
4device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
5weight_dtype = torch.float16
6
7pipe = PixArtSigmaPipeline.from_pretrained(
8 "PixArt-alpha/PixArt-Sigma-XL-2-1024-MS",
9 torch_dtype=weight_dtype,
10 use_safetensors=True,
11)
12pipe.to(device)
13
14# Enable memory optimizations.
15# pipe.enable_model_cpu_offload()
16
17prompt = "A small cactus with a happy face in the Sahara desert."
18image = pipe(prompt).images[0]
19image.save("./catcus.png")
1- pipe.to("cuda")
2+ pipe.enable_model_cpu_offload()
For more information on how to use PixArt-Σ with
diffusers, please have a look at
the PixArt-Σ Docs.
The model is intended for research purposes only. Possible research areas and tasks include
-
Generation of artworks and use in design and other artistic processes.
-
Applications in educational or creative tools.
-
Research on generative models.
-
Safe deployment of models which have the potential to generate harmful content.
-
Probing and understanding the limitations and biases of generative models.
Excluded uses are described below.
The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.