Views
No views yet
1import random
2from diffusers import FluxPipeline
3import torch
4
5MAX_SEED=42
6PRE_TRAINED_MODEL = "black-forest-labs/FLUX.1-dev"
7FINE_TUNED_MODEL = "tryonlabs/FLUX.1-dev-LoRA-Lehenga-Generator"
8
9# Load Flux.1-dev
10pipe = FluxPipeline.from_pretrained(PRE_TRAINED_MODEL, torch_dtype=torch.float16).to("cuda")
11
12# Load fine-tuned model
13pipe.load_lora_weights(FINE_TUNED_MODEL, adapter_name="default", weight_name="lehenga-generator.safetensors")
14
15seed = random.randint(0, MAX_SEED)
16generator = torch.Generator().manual_seed(seed)
17prompt = "A flat lay image of a lehenga with a pink solid pattern and traditional style is elegantly fitted, showcasing a floor-length hemline that flows beautifully. Crafted from luxurious silk, this garment features a stretchy fabric that ensures comfort and a flattering fit. The lehenga is sleeveless, allowing for unrestricted movement, and it is adorned with a sweetheart neckline that adds a touch of femininity. The fitted waistline accentuates the wearer's silhouette, making it a stunning choice for special occasions."
18image = pipe(prompt, height=1024, width=1024, num_images_per_prompt=1, generator=generator, guidance_scale=4.5, num_inference_steps=40).images[0]
19
20image.save("gen_image.jpg")