RASHID778 commited on
Commit
5e0d158
·
verified ·
1 Parent(s): 9161b56

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +361 -14
README.md CHANGED
@@ -1,35 +1,382 @@
1
  ---
2
- license: openrail++
3
- base_model: stabilityai/stable-diffusion-xl-base-1.0
 
4
  library_name: diffusers
 
 
5
  tags:
6
- - text-to-image
7
  - stable-diffusion-xl
 
8
  - lora
9
- - diffusers
10
  - king2
11
- pipeline_tag: text-to-image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
- # ًں‘‘ KING2-IMAGE
 
 
15
 
16
- SDXL LoRA (rank 16) ظ…ط¯ط±ظ‘ط¨ ط¹ظ„ظ‰ ط¹ظٹظ‘ظ†ط© ظ…ظ† `jackyhate/text-to-image-2M` — ظ…ظˆط¯ظٹظ„ ط§ظ„طµظˆط± ط§ظ„ط®ط§طµ ط¨ظ…ظ†طµط© KING2.
 
 
 
17
 
18
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  ```python
21
  import torch
22
  from diffusers import DiffusionPipeline
23
 
 
24
  pipe = DiffusionPipeline.from_pretrained(
25
- "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  ).to("cuda")
 
27
  pipe.load_lora_weights("RASHID778/king2-image")
28
- image = pipe("a futuristic royal palace at sunset, highly detailed, 8k").images[0]
 
 
 
 
 
 
 
 
29
  ```
30
 
31
- ## Training
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- - Base: `stabilityai/stable-diffusion-xl-base-1.0` + `madebyollin/sdxl-vae-fp16-fix`
34
- - Data: 3000 طµظˆط±ط© ظ…ظ† `jackyhate/text-to-image-2M`
35
- - 1500 ط®ط·ظˆط©طŒ resolution 768طŒ rank 16طŒ lr 1e-4 cosineطŒ fp16
 
 
 
1
  ---
2
+ base_model:
3
+ - stabilityai/stable-diffusion-xl-base-1.0
4
+ - madebyollin/sdxl-vae-fp16-fix
5
  library_name: diffusers
6
+ pipeline_tag: text-to-image
7
+ license: openrail++
8
  tags:
9
+ - diffusers
10
  - stable-diffusion-xl
11
+ - sdxl
12
  - lora
13
+ - text-to-image
14
  - king2
15
+ - arabic
16
+ - art
17
+ - image-generation
18
+ - fal-ai
19
+ inference:
20
+ parameters:
21
+ guidance_scale: 7.5
22
+ negative_prompt: blurry, low quality, distorted, ugly, bad anatomy, watermark, text, signature
23
+ widget:
24
+ - text: a futuristic royal palace at sunset, highly detailed, 8k, golden hour, epic composition
25
+ output:
26
+ url: https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_01.png
27
+ - text: majestic arabian knight on horseback, desert landscape, cinematic lighting, photorealistic, 4k
28
+ output:
29
+ url: https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_02.png
30
+ - text: ancient library with floating books, mystical atmosphere, volumetric lighting, detailed illustration
31
+ output:
32
+ url: https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_03.png
33
+ - text: cosmic king on a throne of stars, nebula background, majestic, epic fantasy, concept art
34
+ output:
35
+ url: https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_04.png
36
+ datasets:
37
+ - jackyhate/text-to-image-2M
38
+ language:
39
+ - en
40
+ - ar
41
+ thumbnail: https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_01.png
42
+ ---
43
+
44
+ <p align="center">
45
+ <img src="https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_01.png" alt="KING2 Image Banner" width="80%">
46
+ </p>
47
+
48
+ <h1 align="center">👑 KING2-IMAGE — SDXL LoRA</h1>
49
+
50
+ <p align="center">
51
+ <strong>A curated Stable Diffusion XL LoRA (rank 16) fine-tuned for majestic, high-quality text-to-image generation with a distinctive aesthetic.</strong>
52
+ </p>
53
+
54
+ <p align="center">
55
+ <a href="https://huggingface.co/RASHID778/king2-image"><img src="https://img.shields.io/badge/🤗%20Hugging%20Face-king2--image-FF6F00?style=flat-square" alt="Hugging Face"></a>
56
+ <a href="https://huggingface.co/spaces/RASHID778/king2-qwen2.5-3b"><img src="https://img.shields.io/badge/🚀%20Spaces-Demo-00BFFF?style=flat-square" alt="Spaces"></a>
57
+ <a href="https://huggingface.co/RASHID778/king2-image/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-OpenRAIL++-blue?style=flat-square" alt="License"></a>
58
+ <a href="https://huggingface.co/models?other=king2"><img src="https://img.shields.io/badge/🏷️%20KING2-Series-8A2BE2?style=flat-square" alt="KING2 Series"></a>
59
+ </p>
60
+
61
+ ---
62
+
63
+ ## 📋 Overview
64
+
65
+ **KING2-IMAGE** is a **Stable Diffusion XL LoRA adapter** (rank 16) trained on a curated 3,000-image subset of the [jackyhate/text-to-image-2M](https://huggingface.co/datasets/jackyhate/text-to-image-2M) dataset. It is designed to produce visually striking, detailed, and aesthetically refined images — from majestic royal scenes and cinematic landscapes to fantasy art and photorealistic portraits.
66
+
67
+ Built as part of the **KING2 AI ecosystem**, this model inherits the "royal" essence of the KING2 brand, excelling at generating images with grandeur, rich color palettes, and epic compositions.
68
+
69
+ | Property | Value |
70
+ |----------|-------|
71
+ | **Base Model** | [`stabilityai/stable-diffusion-xl-base-1.0`](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) |
72
+ | **VAE** | [`madebyollin/sdxl-vae-fp16-fix`](https://huggingface.co/madebyollin/sdxl-vae-fp16-fix) |
73
+ | **LoRA Rank** | 16 |
74
+ | **Resolution** | 768×768 |
75
+ | **Training Steps** | 1,500 |
76
+ | **Precision** | fp16 |
77
+ | **Library** | [🧨 Diffusers](https://github.com/huggingface/diffusers) |
78
+ | **License** | [OpenRAIL++](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md) |
79
+
80
+ ---
81
+
82
+ ## ✨ Features
83
+
84
+ - **🎨 Curated Aesthetic** — Fine-tuned on a hand-picked subset that emphasizes quality, composition, and visual appeal.
85
+ - **👑 Royal & Majestic Style** — Excels at grand, epic, and regal image generation — palaces, knights, kings, fantasy worlds.
86
+ - **🌍 Bilingual Prompt Support** — Works with both English and Arabic prompts (Arabic prompts may require transliteration or English for best results).
87
+ - **⚡ Lightweight Adapter** — Only ~93 MB LoRA weights; combines with the base SDXL model for a total footprint manageable on consumer GPUs.
88
+ - **🔥 Inference Provider Ready** — Deployable instantly via [fal-ai](https://fal.ai) (live) with zero setup.
89
+ - **🔄 Diffusers Native** — Drop-in compatible with the Hugging Face Diffusers ecosystem; easy to integrate into existing pipelines.
90
+
91
+ ---
92
+
93
+ ## 🏋️ Training Details
94
+
95
+ ### Dataset
96
+
97
+ | Property | Detail |
98
+ |----------|--------|
99
+ | **Source** | [`jackyhate/text-to-image-2M`](https://huggingface.co/datasets/jackyhate/text-to-image-2M) |
100
+ | **Subset Size** | 3,000 images (curated, high-quality) |
101
+ | **Resolution** | 768×768 |
102
+ | **Format** | Image-Text pairs |
103
+
104
+ The training used a carefully curated subset of 3,000 image-text pairs from the larger text-to-image-2M dataset, selected to emphasize high visual quality, diverse scenes (nature, architecture, fantasy, portraits, landscapes), and compositional richness.
105
+
106
+ ### Hyperparameters
107
+
108
+ | Parameter | Value |
109
+ |-----------|-------|
110
+ | **Base Model** | `stabilityai/stable-diffusion-xl-base-1.0` |
111
+ | **VAE** | `madebyollin/sdxl-vae-fp16-fix` |
112
+ | **LoRA Rank (r)** | 16 |
113
+ | **LoRA Alpha** | 16 |
114
+ | **Resolution** | 768 × 768 |
115
+ | **Optimizer** | AdamW (8-bit) |
116
+ | **Learning Rate** | 1e-4 |
117
+ | **LR Scheduler** | Cosine |
118
+ | **Training Steps** | 1,500 |
119
+ | **Batch Size** | 4 (per device) |
120
+ | **Gradient Accumulation** | 2 |
121
+ | **Mixed Precision** | fp16 |
122
+ | **Noise Offset** | 0.05 |
123
+ | **Checkpoints Saved** | Every 500 steps (checkpoint-500, checkpoint-1000, checkpoint-1500) |
124
+
125
+ ### Checkpoints
126
+
127
+ | Checkpoint | Steps | Description |
128
+ |------------|-------|-------------|
129
+ | `checkpoint-500` | 500 | Early snapshot — good for broad compositional styles |
130
+ | `checkpoint-1000` | 1,000 | Mid-training — balanced detail and coherence |
131
+ | `checkpoint-1500` | **1,500 (final)** | Fully trained — recommended for best results |
132
+
133
  ---
134
 
135
+ ## 📦 Installation
136
+
137
+ ### Requirements
138
 
139
+ - Python 3.10
140
+ - PyTorch ≥ 2.0.0
141
+ - CUDA-compatible GPU with ≥ 8 GB VRAM (recommended)
142
+ - Hugging Face Diffusers, Transformers, Accelerate
143
 
144
+ ### Setup
145
+
146
+ ```bash
147
+ # Create a virtual environment (recommended)
148
+ python -m venv venv
149
+ source venv/bin/activate # Linux/macOS
150
+ # .\venv\Scripts\activate # Windows
151
+
152
+ # Install dependencies
153
+ pip install -U diffusers transformers accelerate torch safetensors
154
+ ```
155
+
156
+ ---
157
+
158
+ ## 🚀 Usage
159
+
160
+ ### Basic Inference
161
 
162
  ```python
163
  import torch
164
  from diffusers import DiffusionPipeline
165
 
166
+ # Load the base SDXL pipeline
167
  pipe = DiffusionPipeline.from_pretrained(
168
+ "stabilityai/stable-diffusion-xl-base-1.0",
169
+ torch_dtype=torch.float16,
170
+ variant="fp16",
171
+ use_safetensors=True,
172
+ )
173
+ pipe.to("cuda")
174
+
175
+ # Load the KING2-IMAGE LoRA adapter
176
+ pipe.load_lora_weights("RASHID778/king2-image")
177
+
178
+ # Optional: Use the fp16 VAE for memory efficiency
179
+ pipe.vae = DiffusionPipeline.from_pretrained(
180
+ "madebyollin/sdxl-vae-fp16-fix",
181
+ torch_dtype=torch.float16,
182
+ ).vae
183
+
184
+ # Generate
185
+ prompt = "a futuristic royal palace at sunset, highly detailed, 8k, golden hour"
186
+ image = pipe(
187
+ prompt,
188
+ num_inference_steps=30,
189
+ guidance_scale=7.5,
190
+ negative_prompt="blurry, low quality, distorted, ugly, bad anatomy, watermark, text",
191
+ ).images[0]
192
+
193
+ image.save("king2_output.png")
194
+ ```
195
+
196
+ ### LoRA Weight Configuration
197
+
198
+ You can adjust the LoRA influence scale for finer control:
199
+
200
+ ```python
201
+ pipe.load_lora_weights("RASHID778/king2-image", adapter_name="king2")
202
+ pipe.set_adapters(["king2"], adapter_weights=[0.85]) # scale from 0.0 to 1.0
203
+ ```
204
+
205
+ ### Using with diffusers `StableDiffusionXLPipeline` Directly
206
+
207
+ ```python
208
+ from diffusers import StableDiffusionXLPipeline
209
+ import torch
210
+
211
+ pipe = StableDiffusionXLPipeline.from_pretrained(
212
+ "stabilityai/stable-diffusion-xl-base-1.0",
213
+ torch_dtype=torch.float16,
214
+ variant="fp16",
215
+ use_safetensors=True,
216
  ).to("cuda")
217
+
218
  pipe.load_lora_weights("RASHID778/king2-image")
219
+
220
+ prompt = "majestic arabian knight on horseback, desert dunes, cinematic lighting, photorealistic, 4k"
221
+ image = pipe(
222
+ prompt,
223
+ num_inference_steps=25,
224
+ guidance_scale=7.0,
225
+ ).images[0]
226
+
227
+ image.save("knight.png")
228
  ```
229
 
230
+ ### Inference Providers (Zero Setup)
231
+
232
+ You can use this model directly without any local setup via **fal-ai**:
233
+
234
+ ```python
235
+ # Using fal Python client (pip install fal)
236
+ import fal
237
+
238
+ result = fal.run(
239
+ "fal-ai/sdxl-lora",
240
+ arguments={
241
+ "model_name": "stabilityai/stable-diffusion-xl-base-1.0",
242
+ "lora_path": "https://huggingface.co/RASHID778/king2-image",
243
+ "prompt": "cosmic king on a throne of stars, nebula background, majestic, epic fantasy",
244
+ "negative_prompt": "blurry, low quality",
245
+ "num_images": 1,
246
+ "guidance_scale": 7.5,
247
+ "num_inference_steps": 30,
248
+ }
249
+ )
250
+ print(result["images"][0]["url"])
251
+ ```
252
+
253
+ ---
254
+
255
+ ## 🎯 Example Prompts
256
+
257
+ Here are some prompts that work exceptionally well with KING2-IMAGE:
258
+
259
+ ### Royal & Majestic
260
+
261
+ | Prompt | Style |
262
+ |--------|-------|
263
+ | `a futuristic royal palace at sunset, highly detailed, 8k, golden hour, epic composition` | Cinematic / Epic |
264
+ | `majestic arabian knight on horseback, desert landscape, cinematic lighting, photorealistic, 4k` | Photorealistic |
265
+ | `cosmic king on a throne of stars, nebula background, majestic, epic fantasy, concept art` | Fantasy Art |
266
+ | `ancient king with golden crown, ornate throne room, dramatic lighting, oil painting style` | Classical Art |
267
+
268
+ ### Fantasy & Mystical
269
+
270
+ | Prompt | Style |
271
+ |--------|-------|
272
+ | `ancient library with floating books, mystical atmosphere, volumetric lighting, detailed illustration` | Illustrative |
273
+ | `enchanted forest with glowing crystals, magical blue and purple hues, fantasy landscape, detailed` | Fantasy |
274
+ | `dragon coiled around a crystal tower, stormy sky, epic scale, cinematic, 8k` | Epic Fantasy |
275
+
276
+ ### Architecture & Scenery
277
+
278
+ | Prompt | Style |
279
+ |--------|-------|
280
+ | `grand mosque at night, illuminated, reflective pool, stars, ultra detailed, architectural photography` | Architectural |
281
+ | `oriental garden with water fountain, blooming flowers, warm sunlight, peaceful, highly detailed` | Scenic |
282
+ | `massive marble palace with golden domes, symmetrical composition, bright blue sky, majestic` | Symmetrical |
283
+
284
+ ### Arabic / Middle Eastern Themes
285
+
286
+ | Prompt | Style |
287
+ |--------|-------|
288
+ | `arabian fortress at dawn, sandstorm clearing, golden light, cinematic wide shot` | Cinematic |
289
+ | `traditional arabian market alley, lanterns, warm colors, detailed architecture, bustling` | Detailed |
290
+
291
+ ---
292
+
293
+ ## 🖼️ Example Images
294
+
295
+ > **Note:** Example images are placeholders. Replace the URLs below with actual generated outputs.
296
+
297
+ <p align="center">
298
+ <img src="https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_01.png" alt="Example 1" width="45%">
299
+ <img src="https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_02.png" alt="Example 2" width="45%">
300
+ </p>
301
+ <p align="center">
302
+ <img src="https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_03.png" alt="Example 3" width="45%">
303
+ <img src="https://huggingface.co/RASHID778/king2-image/resolve/main/examples/example_04.png" alt="Example 4" width="45%">
304
+ </p>
305
+
306
+ <p align="center"><em>Images generated with KING2-IMAGE using prompts from the table above.</em></p>
307
+
308
+ ---
309
+
310
+ ## ⚠️ Limitations
311
+
312
+ - **Resolution Constraint** — Trained at 768×768. Higher resolutions (>1024) may produce artifacts or quality degradation.
313
+ - **Domain Specificity** — Fine-tuned primarily for majestic, royal, and fantasy aesthetics. May not perform optimally on unrelated domains (e.g., modern tech, medical imagery, abstract minimalism).
314
+ - **Bias & Representation** — As with all generative models trained on web data, the model may reflect biases present in the training dataset. Use responsibly and critically evaluate outputs.
315
+ - **Arabic Prompts** — The model was trained primarily on English captions. Arabic prompts may produce less reliable results; transliteration to English is recommended.
316
+ - **Not a Checkpoint** — This is a LoRA adapter only. The base SDXL model must be loaded separately (requires ~12 GB VRAM for full pipeline).
317
+ - **Safety** — The model has not been fine-tuned for safety filtering. Always use appropriate NSFW/content filters in production deployments.
318
+
319
+ ---
320
+
321
+ ## 🔬 Technical Notes
322
+
323
+ - The adapter was trained using the Diffusers `train_text_to_image_lora_sdxl.py` script.
324
+ - All checkpoints use `.safetensors` format for secure and fast loading.
325
+ - Xet storage is used on Hugging Face for efficient large-file hosting.
326
+ - Available for live inference via the fal-ai Inference Provider on Hugging Face.
327
+
328
+ ---
329
+
330
+ ## 📜 License
331
+
332
+ This model is released under the **OpenRAIL++** license, which permits:
333
+
334
+ - ✅ **Use** — Free to use for both research and commercial purposes
335
+ - ✅ **Modification** — You may fine-tune, adapt, or modify the weights
336
+ - ✅ **Distribution** — You may share the weights and derivatives
337
+
338
+ **Conditions:**
339
+
340
+ - ❗ You must not use the model to generate illegal or harmful content
341
+ - ❗ You must include the same license when redistributing
342
+ - ❗ You must not use the model to violate any applicable laws
343
+
344
+ The base model `stabilityai/stable-diffusion-xl-base-1.0` is also released under [OpenRAIL++](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md).
345
+
346
+ ---
347
+
348
+ ## 🏛️ KING2 Ecosystem
349
+
350
+ KING2-IMAGE is part of the **KING2 AI Series**:
351
+
352
+ | Model | Type | Description |
353
+ |-------|------|-------------|
354
+ | [`king2-qwen2.5-3b`](https://huggingface.co/RASHID778/king2-qwen2.5-3b) | LLM (LoRA) | Arabic conversational AI assistant with royal persona |
355
+ | [`king2-image`](https://huggingface.co/RASHID778/king2-image) | SDXL LoRA | Text-to-image generation with majestic aesthetic |
356
+ | [KING2 Space](https://huggingface.co/spaces/RASHID778/king2-qwen2.5-3b) | Demo | Try the KING2 experience live |
357
+
358
+ ---
359
+
360
+ ## 🙏 Acknowledgements
361
+
362
+ - [Stability AI](https://stability.ai/) for the SDXL base model
363
+ - [@jackyhate](https://huggingface.co/jackyhate) for the text-to-image-2M dataset
364
+ - [@madebyollin](https://huggingface.co/madebyollin) for the fp16 VAE fix
365
+ - [Hugging Face](https://huggingface.co) for the Diffusers library and model hosting
366
+ - [fal-ai](https://fal.ai) for the inference provider integration
367
+
368
+ ---
369
+
370
+ ## 📬 Contact & Community
371
+
372
+ - **Author:** [RASHID778](https://huggingface.co/RASHID778)
373
+ - **GitHub:** [MOT1209](https://github.com/MOT1209)
374
+ - **Report Issues:** [Community Tab](https://huggingface.co/RASHID778/king2-image/discussions)
375
+
376
+ ---
377
 
378
+ <p align="center">
379
+ Made with 👑 by <strong>RASHID778</strong>
380
+ <br>
381
+ <sub>Part of the KING2 AI Series — Royal Intelligence</sub>
382
+ </p>