Views
No views yet

1import torch
2from diffusers import Transformer2DModel, PixArtSigmaPipeline
3
4device = "cpu"
5weight_dtype = torch.float32
6
7transformer = Transformer2DModel.from_pretrained(
8 "alfredplpl/CommonArt-PoC",
9 torch_dtype=weight_dtype,
10 use_safetensors=True,
11)
12
13pipe = PixArtSigmaPipeline.from_pretrained(
14 "PixArt-alpha/pixart_sigma_sdxlvae_T5_diffusers",
15 transformer=transformer,
16 torch_dtype=weight_dtype,
17 use_safetensors=True,
18)
19
20pipe.to(device)
21
22prompt = " A picturesque photograph of a serene coastline, capturing the tranquility of a sunrise over the ocean. The image shows a wide expanse of gently rolling sandy beach, with clear, turquoise water stretching into the horizon. Seashells and pebbles are scattered along the shore, and the sun's rays create a golden hue on the water's surface. The distant outline of a lighthouse can be seen, adding to the quaint charm of the scene. The sky is painted with soft pastel colors of dawn, gradually transitioning from pink to blue, creating a sense of peacefulness and beauty."
23image = pipe(prompt,guidance_scale=4.5,max_squence_length=512).images[0]
24image.save("beach.png")1_base_ = ['../PixArt_xl2_internal.py']
2data_root = "/mnt/my_raid/pixart"
3image_list_json = ['data_info.json']
4
5data = dict(
6 type='InternalDataSigma', root='InternData', image_list_json=image_list_json, transform='default_train',
7 load_vae_feat=False, load_t5_feat=False,
8)
9image_size = 256
10
11# model setting
12model = 'PixArt_XL_2'
13mixed_precision = 'fp16' # ['fp16', 'fp32', 'bf16']
14fp32_attention = True
15#load_from = "/mnt/my_raid/pixart/working/checkpoints/epoch_1_step_17500.pth" # https://huggingface.co/PixArt-alpha/PixArt-Sigma
16#resume_from = dict(checkpoint="/mnt/my_raid/pixart/working/checkpoints/epoch_37_step_62039.pth", load_ema=False, resume_optimizer=True, resume_lr_scheduler=True)
17vae_pretrained = "output/pretrained_models/pixart_sigma_sdxlvae_T5_diffusers/vae" # sdxl vae
18multi_scale = False # if use multiscale dataset model training
19pe_interpolation = 0.5
20
21# training setting
22num_workers = 10
23train_batch_size = 64 # 64 as default
24num_epochs = 200 # 3
25gradient_accumulation_steps = 1
26grad_checkpointing = True
27gradient_clip = 0.2
28optimizer = dict(type='CAMEWrapper', lr=2e-5, weight_decay=0.0, betas=(0.9, 0.999, 0.9999), eps=(1e-30, 1e-16))
29lr_schedule_args = dict(num_warmup_steps=1000)
30
31#visualize=True
32#train_sampling_steps = 3
33#eval_sampling_steps = 3
34log_interval = 20
35save_model_epochs = 1
36#save_model_steps = 2500
37work_dir = 'output/debug'
38
39# pixart-sigma
40scale_factor = 0.13025
41real_prompt_ratio = 0.5
42model_max_length = 512
43class_dropout_prob = 0.1
44