File size: 3,355 Bytes
0892506 d703a88 8916f5e 0892506 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
---
tags:
- text-to-image
- lora
- diffusers
- template:sd-lora
- flux
- consumer-products
widget:
- text: >
Item name: alphonso mango milk shake tetra pack with labels
output:
url: images/mango.png
- text: >
Item Name: set of 6 different flavored lays pack
output:
url: images/lays.png
- text: >
Item Name: Bhuja Cracker Mix, 7-ounce Bags, vegan & vegetarian
output:
url: images/bhuja_mix.png
- text: >
Item Name: hotwheels car ratrod packed
output:
url: images/hotwheels.png
base_model: black-forest-labs/FLUX.1-dev
license: mit
datasets:
- SoumilB7/consumer-product-50
---
<Gallery />
# LoRA — Consumer Product Photography (FLUX)
Hello guys I fine-tuned **FLUX.1-dev LoRA** to generate **high-quality consumer product photography**.
Designed for:
* Product ideation
* Packaging & branding mocks
* CPG & D2C marketing visuals
* Studio-style commercial lighting
* Sharp labels, accurate materials, clean backgrounds
Optimized for **bottles, cans, tetra packs, cosmetics, beverages, food products**.
Purpose-built for **product shoots & concept ideation**, not general art.
---
## Usage
**Load & fuse LoRA into FLUX.1-dev (4-bit NF4)**
```python
from diffusers import FluxPipeline, AutoPipelineForText2Image, FluxTransformer2DModel, BitsAndBytesConfig
from transformers import T5EncoderModel
from transformers import BitsAndBytesConfig as TransformersBitsAndBytesConfig
import torch
import gc
ckpt_id = "black-forest-labs/FLUX.1-dev"
lora_path = "SoumilB7/consumer-product-flux"
fused_transformer_path = "fused_transformer"
bnb_4bit_compute_dtype = torch.float16
nf4_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=bnb_4bit_compute_dtype,
)
transformer = FluxTransformer2DModel.from_pretrained(
ckpt_id, subfolder="transformer",
quantization_config=nf4_config, torch_dtype=torch.float16
)
quant_config = TransformersBitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16)
text_encoder = T5EncoderModel.from_pretrained(
ckpt_id, subfolder="text_encoder_2", quantization_config=quant_config, torch_dtype=torch.float16,
)
pipeline = FluxPipeline.from_pretrained(
ckpt_id,
transformer=transformer,
text_encoder_2=text_encoder,
torch_dtype=bnb_4bit_compute_dtype,
)
pipeline.load_lora_weights(lora_path)
pipeline.fuse_lora()
pipeline.unload_lora_weights()
del text_encoder
del transformer
gc.collect()
torch.cuda.empty_cache()
pipeline.to("cuda")
```
### Generate image
```python
prompt = "alphonso mango milkshake tetra pack with label, studio softbox lighting, clean background"
image = pipeline(
prompt,
num_inference_steps=28,
guidance_scale=3.5,
height=768,
width=512,
generator=torch.manual_seed(0)
).images[0]
print(f"Pipeline memory usage: {torch.cuda.max_memory_reserved() / 1024**3:.3f} GB")
image.save("product_example.png")
image
```
---
## Notes
* Best for **studio product shots**, minimal environments
* Works extremely well with **simple, commercial descriptors**
* Ideal for **brands, founders, designers, packaging artists**
---
Would you like:
1. a **“Prompt Guide”** section like Flux Realism models?
2. a **Before → After grid** for the dataset vs model output?
3. a **Colab notebook** link block?
|