SoumilB7 commited on
Commit
0892506
·
verified ·
1 Parent(s): 2849f89

model card

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