svjack commited on
Commit
15c5b3b
1 Parent(s): 3560ee7

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +277 -0
README.md ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # svjack/GenshinImpact_XL_Base
2
+
3
+ This model is derived from [CivitAI](https://civitai.com/models/386505).
4
+
5
+ ## Acknowledgments
6
+
7
+ Special thanks to [mobeimunan](https://civitai.com/user/mobeimunan) for their contributions to the development of this model.
8
+
9
+ ## Supported Characters
10
+
11
+ The model currently supports the following 73 characters from Genshin Impact:
12
+
13
+ ```python
14
+ name_dict = {
15
+ '旅行者女': 'lumine',
16
+ '旅行者男': 'aether',
17
+ '派蒙': 'PAIMON',
18
+ '迪奥娜': 'DIONA',
19
+ '菲米尼': 'FREMINET',
20
+ '甘雨': 'GANYU',
21
+ '凯亚': 'KAEYA',
22
+ '莱依拉': 'LAYLA',
23
+ '罗莎莉亚': 'ROSARIA',
24
+ '七七': 'QIQI',
25
+ '申鹤': 'SHENHE',
26
+ '神里绫华': 'KAMISATO AYAKA',
27
+ '优菈': 'EULA',
28
+ '重云': 'CHONGYUN',
29
+ '夏洛蒂': 'charlotte',
30
+ '莱欧斯利': 'WRIOTHESLEY',
31
+ '艾尔海森': 'ALHAITHAM',
32
+ '柯莱': 'COLLEI',
33
+ '纳西妲': 'NAHIDA',
34
+ '绮良良': 'KIRARA',
35
+ '提纳里': 'TIGHNARI',
36
+ '瑶瑶': 'YAOYAO',
37
+ '珐露珊': 'FARUZAN',
38
+ '枫原万叶': 'KAEDEHARA KAZUHA',
39
+ '琳妮特': 'LYNETTE',
40
+ '流浪者 散兵': 'scaramouche',
41
+ '鹿野院平藏': 'SHIKANOIN HEIZOU',
42
+ '琴': 'JEAN',
43
+ '砂糖': 'SUCROSE',
44
+ '温迪': 'VENTI',
45
+ '魈': 'XIAO',
46
+ '早柚': 'SAYU',
47
+ '安柏': 'AMBER',
48
+ '班尼特': 'BENNETT',
49
+ '迪卢克': 'DILUC',
50
+ '迪西娅': 'DEHYA',
51
+ '胡桃': 'HU TAO',
52
+ '可莉': 'KLEE',
53
+ '林尼': 'LYNEY',
54
+ '托马': 'THOMA',
55
+ '香菱': 'XIANG LING',
56
+ '宵宫': 'YOIMIYA',
57
+ '辛焱': 'XINYAN',
58
+ '烟绯': 'YANFEI',
59
+ '八重神子': 'YAE MIKO',
60
+ '北斗': 'BEIDOU',
61
+ '菲谢尔': 'FISCHL',
62
+ '九条裟罗': 'KUJO SARA',
63
+ '久岐忍': 'KUKI SHINOBU',
64
+ '刻晴': 'KEQING',
65
+ '雷电将军': 'RAIDEN SHOGUN',
66
+ '雷泽': 'RAZOR',
67
+ '丽莎': 'LISA',
68
+ '赛诺': 'CYNO',
69
+ '芙宁娜': 'FURINA',
70
+ '芭芭拉': 'BARBARA',
71
+ '公子 达达利亚': 'TARTAGLIA',
72
+ '坎蒂丝': 'CANDACE',
73
+ '莫娜': 'MONA',
74
+ '妮露': 'NILOU',
75
+ '珊瑚宫心海': 'SANGONOMIYA KOKOMI',
76
+ '神里绫人': 'KAMISATO AYATO',
77
+ '行秋': 'XINGQIU',
78
+ '夜兰': 'YELAN',
79
+ '那维莱特': 'NEUVILLETTE',
80
+ '娜维娅': 'NAVIA',
81
+ '阿贝多': 'ALBEDO',
82
+ '荒泷一斗': 'ARATAKI ITTO',
83
+ '凝光': 'NING GUANG',
84
+ '诺艾尔': 'NOELLE',
85
+ '五郎': 'GOROU',
86
+ '云堇': 'YUN JIN',
87
+ '钟离': 'ZHONGLI'
88
+ }
89
+ ```
90
+
91
+ ## Installation
92
+
93
+ To use this model, you need to install the following dependencies:
94
+
95
+ ```bash
96
+ pip install -U diffusers transformers sentencepiece peft controlnet-aux
97
+ ```
98
+
99
+ ## Example Usage
100
+
101
+ ### Generating an Image of Zhongli
102
+
103
+ Here's an example of how to generate an image of Zhongli using this model:
104
+
105
+ ```python
106
+ from diffusers import StableDiffusionXLPipeline
107
+ import torch
108
+
109
+ pipeline = StableDiffusionXLPipeline.from_pretrained(
110
+ "svjack/GenshinImpact_XL_Base",
111
+ torch_dtype=torch.float16
112
+ ).to("cuda")
113
+
114
+ prompt = "solo,ZHONGLI\(genshin impact\),1boy,portrait,upper_body,highres,"
115
+ negative_prompt = "nsfw,lowres,(bad),text,error,fewer,extra,missing,worst quality,jpeg artifacts,low quality,watermark,unfinished,displeasing,oldest,early,chromatic aberration,signature,extra digits,artistic error,username,scan,[abstract],"
116
+ image = pipeline(
117
+ prompt=prompt,
118
+ negative_prompt=negative_prompt,
119
+ generator=torch.manual_seed(0),
120
+ ).images[0]
121
+ image
122
+ image.save("zhongli_1024x1024.png")
123
+ ```
124
+
125
+ <!--
126
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/3IkZz7uXW9kc-lTnKdQN8.png)
127
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/3IkZz7uXW9kc-lTnKdQN8.png" width="768" height="768">
128
+ -->
129
+
130
+ <div style="display: flex; flex-direction: column; align-items: center;">
131
+ <div style="margin-bottom: 10px;">
132
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/3IkZz7uXW9kc-lTnKdQN8.png" width="768" height="768">
133
+ <p style="text-align: center;">钟离</p>
134
+ </div>
135
+ </div>
136
+
137
+ ### Using Canny ControlNet to Restore 2D Images from 3D Toy Photos
138
+
139
+ Here's an example of how to use Canny ControlNet to restore 2D images from 3D toy photos:
140
+
141
+ #### Genshin Impact 3D Toys
142
+
143
+ <!--
144
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/YNG9vRqZGvUSxb_UUrLE5.jpeg)
145
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/1JfhfFi9qogHwB4M2S54m.jpeg)
146
+ -->
147
+
148
+ <div style="display: flex; flex-direction: column; align-items: center;">
149
+ <div style="margin-bottom: 10px;">
150
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/YNG9vRqZGvUSxb_UUrLE5.jpeg" width="512" height="768">
151
+ <p style="text-align: center;">钟离</p>
152
+ </div>
153
+ <div style="margin-bottom: 10px;">
154
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/1JfhfFi9qogHwB4M2S54m.jpeg" width="512" height="768">
155
+ <p style="text-align: center;">派蒙</p>
156
+ </div>
157
+ </div>
158
+
159
+ ```python
160
+ from diffusers import AutoPipelineForText2Image, ControlNetModel
161
+ from diffusers.utils import load_image
162
+ import torch
163
+ from PIL import Image
164
+ from controlnet_aux import CannyDetector
165
+
166
+ controlnet = ControlNetModel.from_pretrained(
167
+ "diffusers/controlnet-canny-sdxl-1.0", torch_dtype=torch.float16
168
+ )
169
+
170
+ pipeline = AutoPipelineForText2Image.from_pretrained(
171
+ "svjack/GenshinImpact_XL_Base",
172
+ controlnet=controlnet,
173
+ torch_dtype=torch.float16
174
+ ).to("cuda")
175
+ #pipeline.enable_model_cpu_offload()
176
+
177
+ canny = CannyDetector()
178
+ canny(Image.open("zhongli-cb.jpg")).save("zhongli-cb-canny.jpg")
179
+ canny_image = load_image(
180
+ "zhongli-cb-canny.jpg"
181
+ )
182
+
183
+ controlnet_conditioning_scale = 0.5
184
+ generator = torch.Generator(device="cpu").manual_seed(1)
185
+ images = pipeline(
186
+ prompt="solo,ZHONGLI\(genshin impact\),1boy,portrait,highres",
187
+ controlnet_conditioning_scale=controlnet_conditioning_scale,
188
+ image=canny_image,
189
+ num_inference_steps=50,
190
+ guidance_scale=7.0,
191
+ generator=generator,
192
+ ).images
193
+ images[0]
194
+ images[0].save("zhongli_trans.png")
195
+
196
+ canny = CannyDetector()
197
+ canny(Image.open("paimon-cb-crop.jpg")).save("paimon-cb-canny.jpg")
198
+ canny_image = load_image(
199
+ "paimon-cb-canny.jpg"
200
+ )
201
+
202
+ controlnet_conditioning_scale = 0.7
203
+ generator = torch.Generator(device="cpu").manual_seed(3)
204
+ images = pipeline(
205
+ prompt="solo,PAIMON\(genshin impact\),1girl,portrait,highres, bright, shiny, high detail, anime",
206
+ controlnet_conditioning_scale=controlnet_conditioning_scale,
207
+ image=canny_image,
208
+ num_inference_steps=50,
209
+ guidance_scale=8.0,
210
+ generator=generator,
211
+ ).images
212
+ images[0]
213
+ images[0].save("paimon_trans.png")
214
+ ```
215
+
216
+ ### Creating a Grid Image
217
+
218
+ You can also create a grid image from a list of PIL Image objects:
219
+
220
+ ```python
221
+ from PIL import Image
222
+
223
+ def create_grid_image(image_list, rows, cols, cell_width, cell_height):
224
+ """
225
+ Create a grid image from a list of PIL Image objects.
226
+
227
+ :param image_list: A list of PIL Image objects
228
+ :param rows: Number of rows in the grid
229
+ :param cols: Number of columns in the grid
230
+ :param cell_width: Width of each cell in the grid
231
+ :param cell_height: Height of each cell in the grid
232
+ :return: The resulting grid image
233
+ """
234
+ total_width = cols * cell_width
235
+ total_height = rows * cell_height
236
+
237
+ grid_image = Image.new('RGB', (total_width, total_height))
238
+
239
+ for i, img in enumerate(image_list):
240
+ row = i // cols
241
+ col = i % cols
242
+
243
+ img = img.resize((cell_width, cell_height))
244
+
245
+ x_offset = col * cell_width
246
+ y_offset = row * cell_height
247
+
248
+ grid_image.paste(img, (x_offset, y_offset))
249
+
250
+ return grid_image
251
+
252
+ create_grid_image([Image.open("zhongli-cb.jpg") ,Image.open("zhongli-cb-canny.jpg"), Image.open("zhongli_trans.png")], 1, 3, 512, 768)
253
+
254
+ create_grid_image([Image.open("paimon-cb-crop.jpg") ,Image.open("paimon-cb-canny.jpg"), Image.open("paimon_trans.png")], 1, 3, 512, 768)
255
+ ```
256
+
257
+ This will create a grid image showing the original, Canny edge detection, and transformed images side by side.
258
+
259
+ <!--
260
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/vfffGerUQV9W1MHxc_rN_.png)
261
+
262
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/ckrKqytF5MhanjIc_Vn1q.png)
263
+ -->
264
+
265
+ <div>
266
+ <b><h3 style="text-align: center;">Below image list in : (Genshin Impact Toy/ Canny Image / Gemshin Impact Restore 2D Image)</h3></b>
267
+ <div style="display: flex; flex-direction: column; align-items: center;">
268
+ <div style="margin-bottom: 10px;">
269
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/ckrKqytF5MhanjIc_Vn1q.png" width="1536" height="768">
270
+ <p style="text-align: center;">钟离</p>
271
+ </div>
272
+ <div style="margin-bottom: 10px;">
273
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/vfffGerUQV9W1MHxc_rN_.png" width="1536" height="768">
274
+ <p style="text-align: center;">派蒙</p>
275
+ </div>
276
+ </div>
277
+ </div>