Linaqruf commited on
Commit
55f3eea
1 Parent(s): ad67023

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +211 -0
README.md ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: diffusers
3
+ license: openrail++
4
+ language:
5
+ - en
6
+ tags:
7
+ - text-to-image
8
+ - stable-diffusion
9
+ - lora
10
+ - safetensors
11
+ - stable-diffusion-xl
12
+ base_model: Linaqruf/animagine-xl-2.0
13
+ widget:
14
+ - text: face focus, cute, masterpiece, best quality, 1girl, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck
15
+ parameter:
16
+ negative_prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry
17
+ example_title: 1girl
18
+ - text: face focus, bishounen, masterpiece, best quality, 1boy, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck
19
+ parameter:
20
+ negative_prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry
21
+ example_title: 1boy
22
+ ---
23
+
24
+ <style>
25
+ .title-container {
26
+ display: flex;
27
+ flex-direction: column; /* Allow vertical stacking of title and subtitle */
28
+ justify-content: center;
29
+ align-items: center;
30
+ height: 100vh;
31
+ background-color: #f5f5f5;
32
+ }
33
+
34
+ .title {
35
+ font-size: 2em;
36
+ text-align: center;
37
+ color: #333;
38
+ font-family: 'Verdana', sans-serif;
39
+ text-transform: uppercase;
40
+ padding: 1em;
41
+ box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
42
+ }
43
+
44
+ .title span {
45
+ background: -webkit-linear-gradient(45deg, #ff9a9e, #fad0c4, #f6d365);
46
+ -webkit-background-clip: text;
47
+ -webkit-text-fill-color: transparent;
48
+ }
49
+
50
+ .gallery-container {
51
+ max-width: 600px;
52
+ margin: auto;
53
+ text-align: center;
54
+ position: relative;
55
+ }
56
+
57
+ .gallery-radio {
58
+ display: none;
59
+ }
60
+
61
+ .gallery-image {
62
+ display: none;
63
+ width: 100%;
64
+ margin: auto;
65
+ }
66
+
67
+ .gallery-image img {
68
+ width: 100%;
69
+ height: auto;
70
+ border-radius: 10px;
71
+ }
72
+
73
+ #radio1:checked ~ #image1,
74
+ #radio2:checked ~ #image2,
75
+ #radio3:checked ~ #image3 {
76
+ display: block;
77
+ }
78
+
79
+ .btn {
80
+ display: inline-block;
81
+ padding: 10px 20px;
82
+ margin: 10px;
83
+ background-color: #f0f0f0;
84
+ color: black;
85
+ border: none;
86
+ border-radius: 5px;
87
+ cursor: pointer;
88
+ text-decoration: none;
89
+ transition: background-color 0.3s;
90
+ }
91
+
92
+ .btn:hover {
93
+ background-color: #ddd;
94
+ }
95
+ </style>
96
+
97
+ <h1 class="title" style="text-align: center; font-family: Arial, sans-serif;">
98
+ <span>Anime Slider XL LoRA</span>
99
+ </h1>
100
+
101
+ <div class="gallery-container">
102
+ <input type="radio" name="gallery" id="radio1" class="gallery-radio">
103
+ <input type="radio" name="gallery" id="radio2" class="gallery-radio" checked>
104
+ <input type="radio" name="gallery" id="radio3" class="gallery-radio">
105
+
106
+ <label for="radio1" class="btn">Image 1</label>
107
+ <label for="radio2" class="btn">Image 2</label>
108
+ <label for="radio3" class="btn">Image 3</label>
109
+
110
+ <div id="image1" class="gallery-image">
111
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/RFtKV5Q6-8pWRzUA7AjOw.png" alt="sample1">
112
+ </div>
113
+ <div id="image2" class="gallery-image">
114
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/8_Z2IYeTOYJAMuFyJBRwX.png" alt="sample2">
115
+ </div>
116
+ <div id="image3" class="gallery-image">
117
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/0CyCkmFrWjPaBNLAwKMq8.png" alt="sample3">
118
+ </div>
119
+ </div>
120
+
121
+
122
+
123
+ ## Overview
124
+
125
+ **Anime Slider XL LoRA** is a cutting-edge LoRA adapter designed to work alongside Animagine XL 2.0. This unique model specializes in concept modulation, enabling users to adjust the level of detail in generated anime-style images. By manipulating a concept slider, users can create images ranging from highly detailed to more abstract representations.
126
+
127
+ <hr>
128
+
129
+ ## Model Details
130
+
131
+ - **Developed by:** [Linaqruf](https://github.com/Linaqruf)
132
+ - **Model type:** LoRA adapter for Stable Diffusion XL
133
+ - **Model Description:** This adapter is a concept slider, allowing users to control the level of detail in anime-themed images. The closer the slider is set to 2, the more detailed the result; closer to -2, the less detailed. It is a versatile tool for artists and creators seeking various artistic expressions within anime imagery.
134
+ - **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-2/blob/main/LICENSE-MODEL)
135
+ - **Finetuned from model:** [Animagine XL 2.0](https://huggingface.co/Linaqruf/animagine-xl-2.0)
136
+
137
+ <hr>
138
+
139
+ ## 🧨 Diffusers Installation
140
+
141
+ Ensure the installation of the latest `diffusers` library, along with other essential packages:
142
+
143
+ ```bash
144
+ pip install diffusers --upgrade
145
+ pip install transformers accelerate safetensors
146
+ ```
147
+
148
+ The following Python script demonstrates how to utilize the LoRA with Animagine XL 2.0. The default scheduler is EulerAncestralDiscreteScheduler, but it can be explicitly defined for clarity.
149
+
150
+ ```py
151
+ import torch
152
+ from diffusers import (
153
+ StableDiffusionXLPipeline,
154
+ EulerAncestralDiscreteScheduler,
155
+ AutoencoderKL
156
+ )
157
+
158
+ # Initialize LoRA model and weights
159
+ lora_model_id = "Linaqruf/anime-slider-xl-lora"
160
+ lora_filename = "anime-slider-xl.safetensors"
161
+ lora_scale_slider = 2 # -2 for less detailed result
162
+
163
+ # Load VAE component
164
+ vae = AutoencoderKL.from_pretrained(
165
+ "madebyollin/sdxl-vae-fp16-fix",
166
+ torch_dtype=torch.float16
167
+ )
168
+
169
+ # Configure the pipeline
170
+ pipe = StableDiffusionXLPipeline.from_pretrained(
171
+ "Linaqruf/animagine-xl-2.0",
172
+ vae=vae,
173
+ torch_dtype=torch.float16,
174
+ use_safetensors=True,
175
+ variant="fp16"
176
+ )
177
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
178
+ pipe.to('cuda')
179
+
180
+ # Load and fuse LoRA weights
181
+ pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)
182
+ pipe.fuse_lora(lora_scale=lora_scale_slider)
183
+
184
+ # Define prompts and generate image
185
+ prompt = "face focus, cute, masterpiece, best quality, 1girl, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck"
186
+ negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"
187
+
188
+ image = pipe(
189
+ prompt,
190
+ negative_prompt=negative_prompt,
191
+ width=1024,
192
+ height=1024,
193
+ guidance_scale=12,
194
+ num_inference_steps=50
195
+ ).images[0]
196
+
197
+ # Unfuse LoRA before saving the image
198
+ pipe.unfuse_lora()
199
+ image.save("anime_girl.png")
200
+
201
+ ```
202
+
203
+ ## Acknowledgements
204
+
205
+ Our project has been enriched by the following significant works:
206
+
207
+ - **[Erasing Concepts from Diffusion Models](https://github.com/rohitgandikota/erasing)** by Rohit Gandikota et al.
208
+ - **[LECO](https://github.com/p1atdev/LECO)** by p1atdev.
209
+ - **[AI Toolkit](https://github.com/ostris/ai-toolkit)** by Ostris.
210
+
211
+