svjack commited on
Commit
ce8359f
1 Parent(s): 307a40f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +261 -0
README.md ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <div style="display: flex; flex-direction: column; align-items: center;">
126
+ <div style="margin-bottom: 10px;">
127
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/3IkZz7uXW9kc-lTnKdQN8.png" width="768" height="768">
128
+ <p style="text-align: center;">钟离</p>
129
+ </div>
130
+ </div>
131
+
132
+ ### Using Canny ControlNet to Restore 2D Images from 3D Toy Photos
133
+
134
+ Here's an example of how to use Canny ControlNet to restore 2D images from 3D toy photos:
135
+
136
+ #### Genshin Impact 3D Toys
137
+
138
+ <div style="display: flex; flex-direction: column; align-items: center;">
139
+ <div style="margin-bottom: 10px;">
140
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/YNG9vRqZGvUSxb_UUrLE5.jpeg" width="512" height="768">
141
+ <p style="text-align: center;">钟离</p>
142
+ </div>
143
+ <div style="margin-bottom: 10px;">
144
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/1JfhfFi9qogHwB4M2S54m.jpeg" width="512" height="768">
145
+ <p style="text-align: center;">派蒙</p>
146
+ </div>
147
+ </div>
148
+
149
+ ```python
150
+ from diffusers import AutoPipelineForText2Image, ControlNetModel
151
+ from diffusers.utils import load_image
152
+ import torch
153
+ from PIL import Image
154
+ from controlnet_aux import CannyDetector
155
+
156
+ controlnet = ControlNetModel.from_pretrained(
157
+ "diffusers/controlnet-canny-sdxl-1.0", torch_dtype=torch.float16
158
+ )
159
+
160
+ pipeline = AutoPipelineForText2Image.from_pretrained(
161
+ "svjack/GenshinImpact_XL_Base",
162
+ controlnet=controlnet,
163
+ torch_dtype=torch.float16
164
+ ).to("cuda")
165
+ #pipeline.enable_model_cpu_offload()
166
+
167
+ canny = CannyDetector()
168
+ canny(Image.open("zhongli-cb.jpg")).save("zhongli-cb-canny.jpg")
169
+ canny_image = load_image(
170
+ "zhongli-cb-canny.jpg"
171
+ )
172
+
173
+ controlnet_conditioning_scale = 0.5
174
+ generator = torch.Generator(device="cpu").manual_seed(1)
175
+ images = pipeline(
176
+ prompt="solo,ZHONGLI\(genshin impact\),1boy,portrait,highres",
177
+ controlnet_conditioning_scale=controlnet_conditioning_scale,
178
+ image=canny_image,
179
+ num_inference_steps=50,
180
+ guidance_scale=7.0,
181
+ generator=generator,
182
+ ).images
183
+ images[0]
184
+ images[0].save("zhongli_trans.png")
185
+
186
+ canny = CannyDetector()
187
+ canny(Image.open("paimon-cb-crop.jpg")).save("paimon-cb-canny.jpg")
188
+ canny_image = load_image(
189
+ "paimon-cb-canny.jpg"
190
+ )
191
+
192
+ controlnet_conditioning_scale = 0.7
193
+ generator = torch.Generator(device="cpu").manual_seed(3)
194
+ images = pipeline(
195
+ prompt="solo,PAIMON\(genshin impact\),1girl,portrait,highres, bright, shiny, high detail, anime",
196
+ controlnet_conditioning_scale=controlnet_conditioning_scale,
197
+ image=canny_image,
198
+ num_inference_steps=50,
199
+ guidance_scale=8.0,
200
+ generator=generator,
201
+ ).images
202
+ images[0]
203
+ images[0].save("paimon_trans.png")
204
+ ```
205
+
206
+ ### Creating a Grid Image
207
+
208
+ You can also create a grid image from a list of PIL Image objects:
209
+
210
+ ```python
211
+ from PIL import Image
212
+
213
+ def create_grid_image(image_list, rows, cols, cell_width, cell_height):
214
+ """
215
+ Create a grid image from a list of PIL Image objects.
216
+
217
+ :param image_list: A list of PIL Image objects
218
+ :param rows: Number of rows in the grid
219
+ :param cols: Number of columns in the grid
220
+ :param cell_width: Width of each cell in the grid
221
+ :param cell_height: Height of each cell in the grid
222
+ :return: The resulting grid image
223
+ """
224
+ total_width = cols * cell_width
225
+ total_height = rows * cell_height
226
+
227
+ grid_image = Image.new('RGB', (total_width, total_height))
228
+
229
+ for i, img in enumerate(image_list):
230
+ row = i // cols
231
+ col = i % cols
232
+
233
+ img = img.resize((cell_width, cell_height))
234
+
235
+ x_offset = col * cell_width
236
+ y_offset = row * cell_height
237
+
238
+ grid_image.paste(img, (x_offset, y_offset))
239
+
240
+ return grid_image
241
+
242
+ create_grid_image([Image.open("zhongli-cb.jpg") ,Image.open("zhongli-cb-canny.jpg"), Image.open("zhongli_trans.png")], 1, 3, 512, 768)
243
+
244
+ create_grid_image([Image.open("paimon-cb-crop.jpg") ,Image.open("paimon-cb-canny.jpg"), Image.open("paimon_trans.png")], 1, 3, 512, 768)
245
+ ```
246
+
247
+ This will create a grid image showing the original, Canny edge detection, and transformed images side by side.
248
+
249
+ <div>
250
+ <b><h3 style="text-align: center;">Below image list in : (Genshin Impact Toy/ Canny Image / Gemshin Impact Restore 2D Image)</h3></b>
251
+ <div style="display: flex; flex-direction: column; align-items: center;">
252
+ <div style="margin-bottom: 10px;">
253
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/ckrKqytF5MhanjIc_Vn1q.png" width="1536" height="768">
254
+ <p style="text-align: center;">钟离</p>
255
+ </div>
256
+ <div style="margin-bottom: 10px;">
257
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/634dffc49b777beec3bc6448/vfffGerUQV9W1MHxc_rN_.png" width="1536" height="768">
258
+ <p style="text-align: center;">派蒙</p>
259
+ </div>
260
+ </div>
261
+ </div>