Views
No views yet
export MODEL_NAME="diffusers/FLUX.2-dev-bnb-4bit"
export INSTANCE_DIR="/pvol/marvel_zombies_style"
export OUTPUT_DIR="/pvol/marvel_zombies_style_lora_flux2_nf4"
export Q_DIR="/pvol/quantization_config.json"
accelerate config default
accelerate launch train_dreambooth_lora_flux2.py \
--pretrained_model_name_or_path=$MODEL_NAME \
--mixed_precision="bf16" \
--dataset_name=$INSTANCE_DIR \
--output_dir=$OUTPUT_DIR \
--bnb_quantization_config_path=$Q_DIR \
--gradient_checkpointing \
--cache_latents \
--instance_prompt="Marvel Zombies style" \
--caption_column="text" \
--aspect_ratio_buckets="720,1728" \
--center_crop \
--train_batch_size=1 \
--guidance_scale=1 \
--use_8bit_adam \
--offload \
--checkpointing_steps=100 \
--gradient_accumulation_steps=4 \
--optimizer="adamW" \
--learning_rate=1e-4 \
--lr_scheduler="constant" \
--lr_warmup_steps=100 \
--max_train_steps=1500 \
--rank=4 \
--seed="0" 1import torch
2from transformers import Mistral3ForConditionalGeneration
3
4from diffusers import Flux2Pipeline, Flux2Transformer2DModel
5
6repo_id = "diffusers/FLUX.2-dev-bnb-4bit"
7device = "cuda:0"
8torch_dtype = torch.float32 #only supports float32 when using train_dreambooth_lora_flux2.py
9
10transformer = Flux2Transformer2DModel.from_pretrained(
11 repo_id, subfolder="transformer", torch_dtype=torch_dtype, device_map="cuda:0"
12)
13text_encoder = Mistral3ForConditionalGeneration.from_pretrained(
14 repo_id, subfolder="text_encoder", dtype=torch_dtype, device_map="cuda:0"
15)
16
17pipe = Flux2Pipeline.from_pretrained(
18 repo_id, transformer=transformer, text_encoder=text_encoder, torch_dtype=torch_dtype
19)
20pipe.load_lora_weights("je-suis-tm/marvel_zombies_style_lora_flux2_nf4",
21 weight_name='pytorch_lora_weights.safetensors')
22pipe.enable_model_cpu_offload()
23
24prompt = "Marvel Zombies Style, an Aztec god with a skull face, depicted in a full-body view. He stands firmly, gazing intensely and pointing directly at the viewer, conveying a powerful sense of anger. The god wears an intricately designed headdress made of vibrant feathers and jewels, featuring ancient symbols. His elaborate armor, decorated with traditional Aztec motifs, covers his entire body, showcasing intricate details. His eyes glow a menacing red, enhancing his intimidating presence. The background is a deep, shadowy darkness, emphasizing the eerie atmosphere, with subtle glimpses of ancient ruins barely visible in the dim light. The textures of his skin and the shine of the jewels contribute an extra layer of realism, while the full-body composition emphasizes his power and stature"
25
26image = pipe(
27 prompt=prompt,
28 generator=torch.Generator(device=device).manual_seed(42),
29 num_inference_steps=50, # 28 is a good trade-off
30 guidance_scale=4,
31 height=800,
32 width=1920, #the movie was in a weird resolution 800*1920, the resolution needs to be divided by 16
33).images[0]
34
35image.save("marvel_zombies_style.png")Marvel Zombies Style to trigger the image generation.