John6666 commited on
Commit
0dae5e8
1 Parent(s): b2ee1a5

Upload 23 files

Browse files
Files changed (10) hide show
  1. app.py +17 -8
  2. constants.py +453 -0
  3. dc.py +36 -17
  4. env.py +15 -18
  5. formatter.py +43 -0
  6. llmdolphin.py +55 -6
  7. lora_dict.json +315 -0
  8. modutils.py +257 -50
  9. requirements.txt +2 -2
  10. utils.py +421 -0
app.py CHANGED
@@ -3,11 +3,11 @@ import gradio as gr
3
  import numpy as np
4
 
5
  # DiffuseCraft
6
- from dc import (infer, _infer, pass_result, get_diffusers_model_list, get_samplers,
7
  get_vaes, enable_model_recom_prompt, enable_diffusers_model_detail, extract_exif_data, esrgan_upscale, UPSCALER_KEYS,
8
  preset_quality, preset_styles, process_style_prompt, get_all_lora_tupled_list, update_loras, apply_lora_prompt,
9
- download_my_lora, search_civitai_lora, update_civitai_selection, select_civitai_lora, search_civitai_lora_json)
10
- from modutils import get_t2i_model_info, get_civitai_tag, CIVITAI_SORT, CIVITAI_PERIOD, CIVITAI_BASEMODEL
11
  # Translator
12
  from llmdolphin import (dolphin_respond_auto, dolphin_parse_simple,
13
  get_llm_formats, get_dolphin_model_format, get_dolphin_models,
@@ -57,9 +57,16 @@ with gr.Blocks(fill_width=True, elem_id="container", css=css, delete_cache=(60,
57
  run_translate_button = gr.Button("Run with LLM Enhance", variant="secondary", scale=3)
58
  auto_trans = gr.Checkbox(label="Auto translate to English", value=False, scale=2)
59
 
60
- result = gr.Image(label="Result", elem_id="result", format="png", show_label=False, interactive=False,
61
- show_download_button=True, show_share_button=False, container=True)
62
-
 
 
 
 
 
 
 
63
  with gr.Accordion("Advanced Settings", open=False):
64
  with gr.Row():
65
  negative_prompt = gr.Text(label="Negative prompt", lines=1, max_lines=6, placeholder="Enter a negative prompt",
@@ -215,7 +222,7 @@ with gr.Blocks(fill_width=True, elem_id="container", css=css, delete_cache=(60,
215
  ).success(
216
  fn=dolphin_respond_auto,
217
  inputs=[prompt, chatbot],
218
- outputs=[chatbot],
219
  queue=True,
220
  show_progress="full",
221
  show_api=False,
@@ -238,6 +245,8 @@ with gr.Blocks(fill_width=True, elem_id="container", css=css, delete_cache=(60,
238
  ).success(lambda: None, None, chatbot, queue=False, show_api=False)\
239
  .success(pass_result, [result], [result], queue=False, show_api=False) # dummy fn for api
240
 
 
 
241
  gr.on(
242
  triggers=[lora1.change, lora1_wt.change, lora2.change, lora2_wt.change, lora3.change, lora3_wt.change,
243
  lora4.change, lora4_wt.change, lora5.change, lora5_wt.change],
@@ -425,4 +434,4 @@ with gr.Blocks(fill_width=True, elem_id="container", css=css, delete_cache=(60,
425
  gr.DuplicateButton(value="Duplicate Space for private use (This demo does not work on CPU. Requires GPU Space)")
426
 
427
  demo.queue()
428
- demo.launch()
 
3
  import numpy as np
4
 
5
  # DiffuseCraft
6
+ from dc import (infer, _infer, pass_result, get_diffusers_model_list, get_samplers, save_image_history,
7
  get_vaes, enable_model_recom_prompt, enable_diffusers_model_detail, extract_exif_data, esrgan_upscale, UPSCALER_KEYS,
8
  preset_quality, preset_styles, process_style_prompt, get_all_lora_tupled_list, update_loras, apply_lora_prompt,
9
+ download_my_lora, search_civitai_lora, update_civitai_selection, select_civitai_lora, search_civitai_lora_json,
10
+ get_t2i_model_info, get_civitai_tag, CIVITAI_SORT, CIVITAI_PERIOD, CIVITAI_BASEMODEL)
11
  # Translator
12
  from llmdolphin import (dolphin_respond_auto, dolphin_parse_simple,
13
  get_llm_formats, get_dolphin_model_format, get_dolphin_models,
 
57
  run_translate_button = gr.Button("Run with LLM Enhance", variant="secondary", scale=3)
58
  auto_trans = gr.Checkbox(label="Auto translate to English", value=False, scale=2)
59
 
60
+ with gr.Group():
61
+ result = gr.Image(label="Result", elem_id="result", format="png", show_label=False, interactive=False,
62
+ show_download_button=True, show_share_button=False, container=True)
63
+ with gr.Accordion("History", open=False):
64
+ history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", format="png", interactive=False, show_share_button=False,
65
+ show_download_button=True)
66
+ history_files = gr.Files(interactive=False, visible=False)
67
+ history_clear_button = gr.Button(value="Clear History", variant="secondary")
68
+ history_clear_button.click(lambda: ([], []), None, [history_gallery, history_files], queue=False, show_api=False)
69
+
70
  with gr.Accordion("Advanced Settings", open=False):
71
  with gr.Row():
72
  negative_prompt = gr.Text(label="Negative prompt", lines=1, max_lines=6, placeholder="Enter a negative prompt",
 
222
  ).success(
223
  fn=dolphin_respond_auto,
224
  inputs=[prompt, chatbot],
225
+ outputs=[chatbot, result],
226
  queue=True,
227
  show_progress="full",
228
  show_api=False,
 
245
  ).success(lambda: None, None, chatbot, queue=False, show_api=False)\
246
  .success(pass_result, [result], [result], queue=False, show_api=False) # dummy fn for api
247
 
248
+ result.change(save_image_history, [result, history_gallery, history_files, model_name], [history_gallery, history_files], queue=False, show_api=False)
249
+
250
  gr.on(
251
  triggers=[lora1.change, lora1_wt.change, lora2.change, lora2_wt.change, lora3.change, lora3_wt.change,
252
  lora4.change, lora4_wt.change, lora5.change, lora5_wt.change],
 
434
  gr.DuplicateButton(value="Duplicate Space for private use (This demo does not work on CPU. Requires GPU Space)")
435
 
436
  demo.queue()
437
+ demo.launch(show_error=True, debug=True)
constants.py ADDED
@@ -0,0 +1,453 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from stablepy.diffusers_vanilla.constants import FLUX_CN_UNION_MODES
3
+ from stablepy import (
4
+ scheduler_names,
5
+ SD15_TASKS,
6
+ SDXL_TASKS,
7
+ )
8
+
9
+ # - **Download Models**
10
+ DOWNLOAD_MODEL = "https://civitai.com/api/download/models/574369, https://huggingface.co/TechnoByte/MilkyWonderland/resolve/main/milkyWonderland_v40.safetensors"
11
+
12
+ # - **Download VAEs**
13
+ DOWNLOAD_VAE = "https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-c-1.1-b-0.5.safetensors?download=true, https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-blessed.safetensors?download=true, https://huggingface.co/digiplay/VAE/resolve/main/vividReal_v20.safetensors?download=true, https://huggingface.co/fp16-guy/anything_kl-f8-anime2_vae-ft-mse-840000-ema-pruned_blessed_clearvae_fp16_cleaned/resolve/main/vae-ft-mse-840000-ema-pruned_fp16.safetensors?download=true"
14
+
15
+ # - **Download LoRAs**
16
+ DOWNLOAD_LORA = "https://huggingface.co/Leopain/color/resolve/main/Coloring_book_-_LineArt.safetensors, https://civitai.com/api/download/models/135867, https://huggingface.co/Linaqruf/anime-detailer-xl-lora/resolve/main/anime-detailer-xl.safetensors?download=true, https://huggingface.co/Linaqruf/style-enhancer-xl-lora/resolve/main/style-enhancer-xl.safetensors?download=true, https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SD15-8steps-CFG-lora.safetensors?download=true, https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-8steps-CFG-lora.safetensors?download=true"
17
+
18
+ LOAD_DIFFUSERS_FORMAT_MODEL = [
19
+ 'stabilityai/stable-diffusion-xl-base-1.0',
20
+ 'black-forest-labs/FLUX.1-dev',
21
+ 'John6666/blue-pencil-flux1-v021-fp8-flux',
22
+ 'John6666/wai-ani-flux-v10forfp8-fp8-flux',
23
+ 'John6666/xe-anime-flux-v04-fp8-flux',
24
+ 'John6666/lyh-anime-flux-v2a1-fp8-flux',
25
+ 'John6666/carnival-unchained-v10-fp8-flux',
26
+ 'cagliostrolab/animagine-xl-3.1',
27
+ 'John6666/epicrealism-xl-v8kiss-sdxl',
28
+ 'misri/epicrealismXL_v7FinalDestination',
29
+ 'misri/juggernautXL_juggernautX',
30
+ 'misri/zavychromaxl_v80',
31
+ 'SG161222/RealVisXL_V4.0',
32
+ 'SG161222/RealVisXL_V5.0',
33
+ 'misri/newrealityxlAllInOne_Newreality40',
34
+ 'eienmojiki/Anything-XL',
35
+ 'eienmojiki/Starry-XL-v5.2',
36
+ 'gsdf/CounterfeitXL',
37
+ 'KBlueLeaf/Kohaku-XL-Zeta',
38
+ 'John6666/silvermoon-mix-01xl-v11-sdxl',
39
+ 'WhiteAiZ/autismmixSDXL_autismmixConfetti_diffusers',
40
+ 'kitty7779/ponyDiffusionV6XL',
41
+ 'GraydientPlatformAPI/aniverse-pony',
42
+ 'John6666/ras-real-anime-screencap-v1-sdxl',
43
+ 'John6666/duchaiten-pony-xl-no-score-v60-sdxl',
44
+ 'John6666/mistoon-anime-ponyalpha-sdxl',
45
+ 'John6666/3x3x3mixxl-v2-sdxl',
46
+ 'John6666/3x3x3mixxl-3dv01-sdxl',
47
+ 'John6666/ebara-mfcg-pony-mix-v12-sdxl',
48
+ 'John6666/t-ponynai3-v51-sdxl',
49
+ 'John6666/t-ponynai3-v65-sdxl',
50
+ 'John6666/prefect-pony-xl-v3-sdxl',
51
+ 'John6666/mala-anime-mix-nsfw-pony-xl-v5-sdxl',
52
+ 'John6666/wai-real-mix-v11-sdxl',
53
+ 'John6666/wai-c-v6-sdxl',
54
+ 'John6666/iniverse-mix-xl-sfwnsfw-pony-guofeng-v43-sdxl',
55
+ 'John6666/photo-realistic-pony-v5-sdxl',
56
+ 'John6666/pony-realism-v21main-sdxl',
57
+ 'John6666/pony-realism-v22main-sdxl',
58
+ 'John6666/cyberrealistic-pony-v63-sdxl',
59
+ 'John6666/cyberrealistic-pony-v64-sdxl',
60
+ 'John6666/cyberrealistic-pony-v65-sdxl',
61
+ 'GraydientPlatformAPI/realcartoon-pony-diffusion',
62
+ 'John6666/nova-anime-xl-pony-v5-sdxl',
63
+ 'John6666/autismmix-sdxl-autismmix-pony-sdxl',
64
+ 'John6666/aimz-dream-real-pony-mix-v3-sdxl',
65
+ 'John6666/duchaiten-pony-real-v11fix-sdxl',
66
+ 'John6666/duchaiten-pony-real-v20-sdxl',
67
+ 'yodayo-ai/kivotos-xl-2.0',
68
+ 'yodayo-ai/holodayo-xl-2.1',
69
+ 'yodayo-ai/clandestine-xl-1.0',
70
+ 'digiplay/majicMIX_sombre_v2',
71
+ 'digiplay/majicMIX_realistic_v6',
72
+ 'digiplay/majicMIX_realistic_v7',
73
+ 'digiplay/DreamShaper_8',
74
+ 'digiplay/BeautifulArt_v1',
75
+ 'digiplay/DarkSushi2.5D_v1',
76
+ 'digiplay/darkphoenix3D_v1.1',
77
+ 'digiplay/BeenYouLiteL11_diffusers',
78
+ 'Yntec/RevAnimatedV2Rebirth',
79
+ 'youknownothing/cyberrealistic_v50',
80
+ 'youknownothing/deliberate-v6',
81
+ 'GraydientPlatformAPI/deliberate-cyber3',
82
+ 'GraydientPlatformAPI/picx-real',
83
+ 'GraydientPlatformAPI/perfectworld6',
84
+ 'emilianJR/epiCRealism',
85
+ 'votepurchase/counterfeitV30_v30',
86
+ 'votepurchase/ChilloutMix',
87
+ 'Meina/MeinaMix_V11',
88
+ 'Meina/MeinaUnreal_V5',
89
+ 'Meina/MeinaPastel_V7',
90
+ 'GraydientPlatformAPI/realcartoon3d-17',
91
+ 'GraydientPlatformAPI/realcartoon-pixar11',
92
+ 'GraydientPlatformAPI/realcartoon-real17',
93
+ ]
94
+
95
+ DIFFUSERS_FORMAT_LORAS = [
96
+ "nerijs/animation2k-flux",
97
+ "XLabs-AI/flux-RealismLora",
98
+ ]
99
+
100
+ DOWNLOAD_EMBEDS = [
101
+ 'https://huggingface.co/datasets/Nerfgun3/bad_prompt/blob/main/bad_prompt_version2.pt',
102
+ 'https://huggingface.co/embed/negative/resolve/main/EasyNegativeV2.safetensors',
103
+ 'https://huggingface.co/embed/negative/resolve/main/bad-hands-5.pt',
104
+ ]
105
+
106
+ CIVITAI_API_KEY = os.environ.get("CIVITAI_API_KEY")
107
+ HF_TOKEN = os.environ.get("HF_READ_TOKEN")
108
+
109
+ DIRECTORY_MODELS = 'models'
110
+ DIRECTORY_LORAS = 'loras'
111
+ DIRECTORY_VAES = 'vaes'
112
+ DIRECTORY_EMBEDS = 'embedings'
113
+
114
+ PREPROCESSOR_CONTROLNET = {
115
+ "openpose": [
116
+ "Openpose",
117
+ "None",
118
+ ],
119
+ "scribble": [
120
+ "HED",
121
+ "PidiNet",
122
+ "None",
123
+ ],
124
+ "softedge": [
125
+ "PidiNet",
126
+ "HED",
127
+ "HED safe",
128
+ "PidiNet safe",
129
+ "None",
130
+ ],
131
+ "segmentation": [
132
+ "UPerNet",
133
+ "None",
134
+ ],
135
+ "depth": [
136
+ "DPT",
137
+ "Midas",
138
+ "None",
139
+ ],
140
+ "normalbae": [
141
+ "NormalBae",
142
+ "None",
143
+ ],
144
+ "lineart": [
145
+ "Lineart",
146
+ "Lineart coarse",
147
+ "Lineart (anime)",
148
+ "None",
149
+ "None (anime)",
150
+ ],
151
+ "lineart_anime": [
152
+ "Lineart",
153
+ "Lineart coarse",
154
+ "Lineart (anime)",
155
+ "None",
156
+ "None (anime)",
157
+ ],
158
+ "shuffle": [
159
+ "ContentShuffle",
160
+ "None",
161
+ ],
162
+ "canny": [
163
+ "Canny",
164
+ "None",
165
+ ],
166
+ "mlsd": [
167
+ "MLSD",
168
+ "None",
169
+ ],
170
+ "ip2p": [
171
+ "ip2p"
172
+ ],
173
+ "recolor": [
174
+ "Recolor luminance",
175
+ "Recolor intensity",
176
+ "None",
177
+ ],
178
+ "tile": [
179
+ "Mild Blur",
180
+ "Moderate Blur",
181
+ "Heavy Blur",
182
+ "None",
183
+ ],
184
+
185
+ }
186
+
187
+ TASK_STABLEPY = {
188
+ 'txt2img': 'txt2img',
189
+ 'img2img': 'img2img',
190
+ 'inpaint': 'inpaint',
191
+ # 'canny T2I Adapter': 'sdxl_canny_t2i', # NO HAVE STEP CALLBACK PARAMETERS SO NOT WORKS WITH DIFFUSERS 0.29.0
192
+ # 'sketch T2I Adapter': 'sdxl_sketch_t2i',
193
+ # 'lineart T2I Adapter': 'sdxl_lineart_t2i',
194
+ # 'depth-midas T2I Adapter': 'sdxl_depth-midas_t2i',
195
+ # 'openpose T2I Adapter': 'sdxl_openpose_t2i',
196
+ 'openpose ControlNet': 'openpose',
197
+ 'canny ControlNet': 'canny',
198
+ 'mlsd ControlNet': 'mlsd',
199
+ 'scribble ControlNet': 'scribble',
200
+ 'softedge ControlNet': 'softedge',
201
+ 'segmentation ControlNet': 'segmentation',
202
+ 'depth ControlNet': 'depth',
203
+ 'normalbae ControlNet': 'normalbae',
204
+ 'lineart ControlNet': 'lineart',
205
+ 'lineart_anime ControlNet': 'lineart_anime',
206
+ 'shuffle ControlNet': 'shuffle',
207
+ 'ip2p ControlNet': 'ip2p',
208
+ 'optical pattern ControlNet': 'pattern',
209
+ 'recolor ControlNet': 'recolor',
210
+ 'tile ControlNet': 'tile',
211
+ }
212
+
213
+ TASK_MODEL_LIST = list(TASK_STABLEPY.keys())
214
+
215
+ UPSCALER_DICT_GUI = {
216
+ None: None,
217
+ "Lanczos": "Lanczos",
218
+ "Nearest": "Nearest",
219
+ 'Latent': 'Latent',
220
+ 'Latent (antialiased)': 'Latent (antialiased)',
221
+ 'Latent (bicubic)': 'Latent (bicubic)',
222
+ 'Latent (bicubic antialiased)': 'Latent (bicubic antialiased)',
223
+ 'Latent (nearest)': 'Latent (nearest)',
224
+ 'Latent (nearest-exact)': 'Latent (nearest-exact)',
225
+ "RealESRGAN_x4plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
226
+ "RealESRNet_x4plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.1/RealESRNet_x4plus.pth",
227
+ "RealESRGAN_x4plus_anime_6B": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth",
228
+ "RealESRGAN_x2plus": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth",
229
+ "realesr-animevideov3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth",
230
+ "realesr-general-x4v3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth",
231
+ "realesr-general-wdn-x4v3": "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth",
232
+ "4x-UltraSharp": "https://huggingface.co/Shandypur/ESRGAN-4x-UltraSharp/resolve/main/4x-UltraSharp.pth",
233
+ "4x_foolhardy_Remacri": "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth",
234
+ "Remacri4xExtraSmoother": "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/Remacri%204x%20ExtraSmoother.pth",
235
+ "AnimeSharp4x": "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/AnimeSharp%204x.pth",
236
+ "lollypop": "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/lollypop.pth",
237
+ "RealisticRescaler4x": "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/RealisticRescaler%204x.pth",
238
+ "NickelbackFS4x": "https://huggingface.co/hollowstrawberry/upscalers-backup/resolve/main/ESRGAN/NickelbackFS%204x.pth"
239
+ }
240
+
241
+ UPSCALER_KEYS = list(UPSCALER_DICT_GUI.keys())
242
+
243
+ PROMPT_W_OPTIONS = [
244
+ ("Compel format: (word)weight", "Compel"),
245
+ ("Classic format: (word:weight)", "Classic"),
246
+ ("Classic-original format: (word:weight)", "Classic-original"),
247
+ ("Classic-no_norm format: (word:weight)", "Classic-no_norm"),
248
+ ("Classic-ignore", "Classic-ignore"),
249
+ ("None", "None"),
250
+ ]
251
+
252
+ WARNING_MSG_VAE = (
253
+ "Use the right VAE for your model to maintain image quality. The wrong"
254
+ " VAE can lead to poor results, like blurriness in the generated images."
255
+ )
256
+
257
+ SDXL_TASK = [k for k, v in TASK_STABLEPY.items() if v in SDXL_TASKS]
258
+ SD_TASK = [k for k, v in TASK_STABLEPY.items() if v in SD15_TASKS]
259
+ FLUX_TASK = list(TASK_STABLEPY.keys())[:3] + [k for k, v in TASK_STABLEPY.items() if v in FLUX_CN_UNION_MODES.keys()]
260
+
261
+ MODEL_TYPE_TASK = {
262
+ "SD 1.5": SD_TASK,
263
+ "SDXL": SDXL_TASK,
264
+ "FLUX": FLUX_TASK,
265
+ }
266
+
267
+ MODEL_TYPE_CLASS = {
268
+ "diffusers:StableDiffusionPipeline": "SD 1.5",
269
+ "diffusers:StableDiffusionXLPipeline": "SDXL",
270
+ "diffusers:FluxPipeline": "FLUX",
271
+ }
272
+
273
+ POST_PROCESSING_SAMPLER = ["Use same sampler"] + scheduler_names[:-2]
274
+
275
+ SUBTITLE_GUI = (
276
+ "### This demo uses [diffusers](https://github.com/huggingface/diffusers)"
277
+ " to perform different tasks in image generation."
278
+ )
279
+
280
+ HELP_GUI = (
281
+ """### Help:
282
+ - The current space runs on a ZERO GPU which is assigned for approximately 60 seconds; Therefore, if you submit expensive tasks, the operation may be canceled upon reaching the maximum allowed time with 'GPU TASK ABORTED'.
283
+ - Distorted or strange images often result from high prompt weights, so it's best to use low weights and scales, and consider using Classic variants like 'Classic-original'.
284
+ - For better results with Pony Diffusion, try using sampler DPM++ 1s or DPM2 with Compel or Classic prompt weights.
285
+ """
286
+ )
287
+
288
+ EXAMPLES_GUI_HELP = (
289
+ """### The following examples perform specific tasks:
290
+ 1. Generation with SDXL and upscale
291
+ 2. Generation with FLUX dev
292
+ 3. ControlNet Canny SDXL
293
+ 4. Optical pattern (Optical illusion) SDXL
294
+ 5. Convert an image to a coloring drawing
295
+ 6. ControlNet OpenPose SD 1.5 and Latent upscale
296
+
297
+ - Different tasks can be performed, such as img2img or using the IP adapter, to preserve a person's appearance or a specific style based on an image.
298
+ """
299
+ )
300
+
301
+ EXAMPLES_GUI = [
302
+ [
303
+ "1girl, souryuu asuka langley, neon genesis evangelion, rebuild of evangelion, lance of longinus, cat hat, plugsuit, pilot suit, red bodysuit, sitting, crossed legs, black eye patch, throne, looking down, from bottom, looking at viewer, outdoors, (masterpiece), (best quality), (ultra-detailed), very aesthetic, illustration, disheveled hair, perfect composition, moist skin, intricate details",
304
+ "nfsw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, unfinished, very displeasing, oldest, early, chromatic aberration, artistic error, scan, abstract",
305
+ 28,
306
+ 7.0,
307
+ -1,
308
+ "None",
309
+ 0.33,
310
+ "Euler a",
311
+ 1152,
312
+ 896,
313
+ "cagliostrolab/animagine-xl-3.1",
314
+ "txt2img",
315
+ "image.webp", # img conttol
316
+ 1024, # img resolution
317
+ 0.35, # strength
318
+ 1.0, # cn scale
319
+ 0.0, # cn start
320
+ 1.0, # cn end
321
+ "Classic",
322
+ "Nearest",
323
+ 45,
324
+ False,
325
+ ],
326
+ [
327
+ "a digital illustration of a movie poster titled 'Finding Emo', finding nemo parody poster, featuring a depressed cartoon clownfish with black emo hair, eyeliner, and piercings, bored expression, swimming in a dark underwater scene, in the background, movie title in a dripping, grungy font, moody blue and purple color palette",
328
+ "",
329
+ 24,
330
+ 3.5,
331
+ -1,
332
+ "None",
333
+ 0.33,
334
+ "Euler a",
335
+ 1152,
336
+ 896,
337
+ "black-forest-labs/FLUX.1-dev",
338
+ "txt2img",
339
+ None, # img conttol
340
+ 1024, # img resolution
341
+ 0.35, # strength
342
+ 1.0, # cn scale
343
+ 0.0, # cn start
344
+ 1.0, # cn end
345
+ "Classic",
346
+ None,
347
+ 70,
348
+ True,
349
+ ],
350
+ [
351
+ "((masterpiece)), best quality, blonde disco girl, detailed face, realistic face, realistic hair, dynamic pose, pink pvc, intergalactic disco background, pastel lights, dynamic contrast, airbrush, fine detail, 70s vibe, midriff",
352
+ "(worst quality:1.2), (bad quality:1.2), (poor quality:1.2), (missing fingers:1.2), bad-artist-anime, bad-artist, bad-picture-chill-75v",
353
+ 48,
354
+ 3.5,
355
+ -1,
356
+ "None",
357
+ 0.33,
358
+ "DPM++ 2M SDE Lu",
359
+ 1024,
360
+ 1024,
361
+ "misri/epicrealismXL_v7FinalDestination",
362
+ "canny ControlNet",
363
+ "image.webp", # img conttol
364
+ 1024, # img resolution
365
+ 0.35, # strength
366
+ 1.0, # cn scale
367
+ 0.0, # cn start
368
+ 1.0, # cn end
369
+ "Classic",
370
+ None,
371
+ 44,
372
+ False,
373
+ ],
374
+ [
375
+ "cinematic scenery old city ruins",
376
+ "(worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), (illustration, 3d, 2d, painting, cartoons, sketch, blurry, film grain, noise), (low quality, worst quality:1.2)",
377
+ 50,
378
+ 4.0,
379
+ -1,
380
+ "None",
381
+ 0.33,
382
+ "Euler a",
383
+ 1024,
384
+ 1024,
385
+ "misri/juggernautXL_juggernautX",
386
+ "optical pattern ControlNet",
387
+ "spiral_no_transparent.png", # img conttol
388
+ 1024, # img resolution
389
+ 0.35, # strength
390
+ 1.0, # cn scale
391
+ 0.05, # cn start
392
+ 0.75, # cn end
393
+ "Classic",
394
+ None,
395
+ 35,
396
+ False,
397
+ ],
398
+ [
399
+ "black and white, line art, coloring drawing, clean line art, black strokes, no background, white, black, free lines, black scribbles, on paper, A blend of comic book art and lineart full of black and white color, masterpiece, high-resolution, trending on Pixiv fan box, palette knife, brush strokes, two-dimensional, planar vector, T-shirt design, stickers, and T-shirt design, vector art, fantasy art, Adobe Illustrator, hand-painted, digital painting, low polygon, soft lighting, aerial view, isometric style, retro aesthetics, 8K resolution, black sketch lines, monochrome, invert color",
400
+ "color, red, green, yellow, colored, duplicate, blurry, abstract, disfigured, deformed, animated, toy, figure, framed, 3d, bad art, poorly drawn, extra limbs, close up, b&w, weird colors, blurry, watermark, blur haze, 2 heads, long neck, watermark, elongated body, cropped image, out of frame, draft, deformed hands, twisted fingers, double image, malformed hands, multiple heads, extra limb, ugly, poorly drawn hands, missing limb, cut-off, over satured, grain, lowères, bad anatomy, poorly drawn face, mutation, mutated, floating limbs, disconnected limbs, out of focus, long body, disgusting, extra fingers, groos proportions, missing arms, mutated hands, cloned face, missing legs, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, blurry, bad anatomy, blurred, watermark, grainy, signature, cut off, draft, deformed, blurry, bad anatomy, disfigured, poorly drawn face, mutation, bluelish, blue",
401
+ 20,
402
+ 4.0,
403
+ -1,
404
+ "loras/Coloring_book_-_LineArt.safetensors",
405
+ 1.0,
406
+ "DPM++ 2M SDE Karras",
407
+ 1024,
408
+ 1024,
409
+ "cagliostrolab/animagine-xl-3.1",
410
+ "lineart ControlNet",
411
+ "color_image.png", # img conttol
412
+ 896, # img resolution
413
+ 0.35, # strength
414
+ 1.0, # cn scale
415
+ 0.0, # cn start
416
+ 1.0, # cn end
417
+ "Compel",
418
+ None,
419
+ 35,
420
+ False,
421
+ ],
422
+ [
423
+ "1girl,face,curly hair,red hair,white background,",
424
+ "(worst quality:2),(low quality:2),(normal quality:2),lowres,watermark,",
425
+ 38,
426
+ 5.0,
427
+ -1,
428
+ "None",
429
+ 0.33,
430
+ "DPM++ 2M SDE Karras",
431
+ 512,
432
+ 512,
433
+ "digiplay/majicMIX_realistic_v7",
434
+ "openpose ControlNet",
435
+ "image.webp", # img conttol
436
+ 1024, # img resolution
437
+ 0.35, # strength
438
+ 1.0, # cn scale
439
+ 0.0, # cn start
440
+ 0.9, # cn end
441
+ "Compel",
442
+ "Latent (antialiased)",
443
+ 46,
444
+ False,
445
+ ],
446
+ ]
447
+
448
+ RESOURCES = (
449
+ """### Resources
450
+ - John6666's space has some great features you might find helpful [link](https://huggingface.co/spaces/John6666/DiffuseCraftMod).
451
+ - You can also try the image generator in Colab’s free tier, which provides free GPU [link](https://github.com/R3gm/SD_diffusers_interactive).
452
+ """
453
+ )
dc.py CHANGED
@@ -1,31 +1,49 @@
1
  import spaces
2
  import os
3
  from stablepy import Model_Diffusers
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  from stablepy.diffusers_vanilla.style_prompt_config import STYLE_NAMES
5
- from stablepy.diffusers_vanilla.constants import FLUX_CN_UNION_MODES
6
  import torch
7
  import re
8
- from huggingface_hub import HfApi
9
  from stablepy import (
10
- CONTROLNET_MODEL_IDS,
11
- VALID_TASKS,
12
- T2I_PREPROCESSOR_NAME,
13
- FLASH_LORA,
14
- SCHEDULER_CONFIG_MAP,
15
  scheduler_names,
16
- IP_ADAPTER_MODELS,
17
  IP_ADAPTERS_SD,
18
  IP_ADAPTERS_SDXL,
19
- REPO_IMAGE_ENCODER,
20
- ALL_PROMPT_WEIGHT_OPTIONS,
21
- SD15_TASKS,
22
- SDXL_TASKS,
23
  )
24
  import time
25
  from PIL import ImageFile
26
- #import urllib.parse
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  ImageFile.LOAD_TRUNCATED_IMAGES = True
 
29
  print(os.getenv("SPACES_ZERO_GPU"))
30
 
31
  import gradio as gr
@@ -38,7 +56,7 @@ warnings.filterwarnings(action="ignore", category=FutureWarning, module="diffuse
38
  warnings.filterwarnings(action="ignore", category=UserWarning, module="diffusers")
39
  warnings.filterwarnings(action="ignore", category=FutureWarning, module="transformers")
40
  from stablepy import logger
41
- logger.setLevel(logging.CRITICAL)
42
 
43
  from env import (
44
  HF_TOKEN, hf_read_token, # to use only for private repos
@@ -783,8 +801,9 @@ from PIL import Image
783
  import random, json
784
  from modutils import (safe_float, escape_lora_basename, to_lora_key, to_lora_path,
785
  get_local_model_list, get_private_lora_model_lists, get_valid_lora_name,
786
- get_valid_lora_path, get_valid_lora_wt, get_lora_info, CIVITAI_SORT, CIVITAI_PERIOD,
787
- normalize_prompt_list, get_civitai_info, search_lora_on_civitai, translate_to_en)
 
788
 
789
  sd_gen = GuiSD()
790
  #@spaces.GPU
@@ -958,7 +977,7 @@ except Exception:
958
  private_lora_model_list = get_private_lora_model_lists()
959
  loras_dict = {"None": ["", "", "", "", ""], "": ["", "", "", "", ""]} | private_lora_dict.copy()
960
  loras_url_to_path_dict = {} # {"URL to download": "local filepath", ...}
961
- civitai_lora_last_results = {} # {"URL to download": {search results}, ...}
962
  all_lora_list = []
963
 
964
 
 
1
  import spaces
2
  import os
3
  from stablepy import Model_Diffusers
4
+ from constants import (
5
+ PREPROCESSOR_CONTROLNET,
6
+ TASK_STABLEPY,
7
+ TASK_MODEL_LIST,
8
+ UPSCALER_DICT_GUI,
9
+ UPSCALER_KEYS,
10
+ PROMPT_W_OPTIONS,
11
+ WARNING_MSG_VAE,
12
+ SDXL_TASK,
13
+ MODEL_TYPE_TASK,
14
+ POST_PROCESSING_SAMPLER,
15
+
16
+ )
17
  from stablepy.diffusers_vanilla.style_prompt_config import STYLE_NAMES
 
18
  import torch
19
  import re
 
20
  from stablepy import (
 
 
 
 
 
21
  scheduler_names,
 
22
  IP_ADAPTERS_SD,
23
  IP_ADAPTERS_SDXL,
 
 
 
 
24
  )
25
  import time
26
  from PIL import ImageFile
27
+ from utils import (
28
+ get_model_list,
29
+ extract_parameters,
30
+ get_model_type,
31
+ extract_exif_data,
32
+ create_mask_now,
33
+ download_diffuser_repo,
34
+ progress_step_bar,
35
+ html_template_message,
36
+ )
37
+ from datetime import datetime
38
+ import gradio as gr
39
+ import logging
40
+ import diffusers
41
+ import warnings
42
+ from stablepy import logger
43
+ # import urllib.parse
44
 
45
  ImageFile.LOAD_TRUNCATED_IMAGES = True
46
+ # os.environ["PYTORCH_NO_CUDA_MEMORY_CACHING"] = "1"
47
  print(os.getenv("SPACES_ZERO_GPU"))
48
 
49
  import gradio as gr
 
56
  warnings.filterwarnings(action="ignore", category=UserWarning, module="diffusers")
57
  warnings.filterwarnings(action="ignore", category=FutureWarning, module="transformers")
58
  from stablepy import logger
59
+ logger.setLevel(logging.DEBUG)
60
 
61
  from env import (
62
  HF_TOKEN, hf_read_token, # to use only for private repos
 
801
  import random, json
802
  from modutils import (safe_float, escape_lora_basename, to_lora_key, to_lora_path,
803
  get_local_model_list, get_private_lora_model_lists, get_valid_lora_name,
804
+ get_valid_lora_path, get_valid_lora_wt, get_lora_info, CIVITAI_SORT, CIVITAI_PERIOD, CIVITAI_BASEMODEL,
805
+ normalize_prompt_list, get_civitai_info, search_lora_on_civitai, translate_to_en, get_t2i_model_info, get_civitai_tag, save_image_history)
806
+
807
 
808
  sd_gen = GuiSD()
809
  #@spaces.GPU
 
977
  private_lora_model_list = get_private_lora_model_lists()
978
  loras_dict = {"None": ["", "", "", "", ""], "": ["", "", "", "", ""]} | private_lora_dict.copy()
979
  loras_url_to_path_dict = {} # {"URL to download": "local filepath", ...}
980
+ civitai_last_results = {} # {"URL to download": {search results}, ...}
981
  all_lora_list = []
982
 
983
 
env.py CHANGED
@@ -2,10 +2,10 @@ import os
2
 
3
  CIVITAI_API_KEY = os.environ.get("CIVITAI_API_KEY")
4
  HF_TOKEN = os.environ.get("HF_TOKEN")
5
- hf_read_token = os.environ.get('HF_READ_TOKEN') # only use for private repo
6
 
7
  # - **List Models**
8
- load_diffusers_format_model = [
9
  'votepurchase/animagine-xl-3.1',
10
  'votepurchase/NSFW-GEN-ANIME-v2',
11
  'votepurchase/kivotos-xl-2.0',
@@ -138,11 +138,11 @@ HF_MODEL_USER_EX = ["John6666"] # sorted by a special rule
138
 
139
 
140
  # - **Download Models**
141
- download_model_list = [
142
  ]
143
 
144
  # - **Download VAEs**
145
- download_vae_list = [
146
  'https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl.vae.safetensors?download=true',
147
  'https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-c-1.1-b-0.5.safetensors?download=true',
148
  "https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/blob/main/sdxl_vae-fp16fix-blessed.safetensors",
@@ -151,29 +151,26 @@ download_vae_list = [
151
  ]
152
 
153
  # - **Download LoRAs**
154
- download_lora_list = [
155
  ]
156
 
157
  # Download Embeddings
158
- download_embeds = [
159
  'https://huggingface.co/datasets/Nerfgun3/bad_prompt/blob/main/bad_prompt_version2.pt',
160
  'https://huggingface.co/embed/negative/resolve/main/EasyNegativeV2.safetensors',
161
  'https://huggingface.co/embed/negative/resolve/main/bad-hands-5.pt',
162
  ]
163
 
164
- directory_models = 'models'
165
- os.makedirs(directory_models, exist_ok=True)
166
- directory_loras = 'loras'
167
- os.makedirs(directory_loras, exist_ok=True)
168
- directory_vaes = 'vaes'
169
- os.makedirs(directory_vaes, exist_ok=True)
170
- directory_embeds = 'embedings'
171
- os.makedirs(directory_embeds, exist_ok=True)
172
 
173
- directory_embeds_sdxl = 'embedings_xl'
174
- os.makedirs(directory_embeds_sdxl, exist_ok=True)
175
- directory_embeds_positive_sdxl = 'embedings_xl/positive'
176
- os.makedirs(directory_embeds_positive_sdxl, exist_ok=True)
177
 
178
  HF_LORA_PRIVATE_REPOS1 = ['John6666/loratest1', 'John6666/loratest3', 'John6666/loratest4', 'John6666/loratest6']
179
  HF_LORA_PRIVATE_REPOS2 = ['John6666/loratest10', 'John6666/loratest11','John6666/loratest'] # to be sorted as 1 repo
 
2
 
3
  CIVITAI_API_KEY = os.environ.get("CIVITAI_API_KEY")
4
  HF_TOKEN = os.environ.get("HF_TOKEN")
5
+ HF_READ_TOKEN = os.environ.get('HF_READ_TOKEN') # only use for private repo
6
 
7
  # - **List Models**
8
+ LOAD_DIFFUSERS_FORMAT_MODEL = [
9
  'votepurchase/animagine-xl-3.1',
10
  'votepurchase/NSFW-GEN-ANIME-v2',
11
  'votepurchase/kivotos-xl-2.0',
 
138
 
139
 
140
  # - **Download Models**
141
+ DOWNLOAD_MODEL_LIST = [
142
  ]
143
 
144
  # - **Download VAEs**
145
+ DOWNLOAD_VAE_LIST = [
146
  'https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl.vae.safetensors?download=true',
147
  'https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/resolve/main/sdxl_vae-fp16fix-c-1.1-b-0.5.safetensors?download=true',
148
  "https://huggingface.co/nubby/blessed-sdxl-vae-fp16-fix/blob/main/sdxl_vae-fp16fix-blessed.safetensors",
 
151
  ]
152
 
153
  # - **Download LoRAs**
154
+ DOWNLOAD_LORA_LIST = [
155
  ]
156
 
157
  # Download Embeddings
158
+ DOWNLOAD_EMBEDS = [
159
  'https://huggingface.co/datasets/Nerfgun3/bad_prompt/blob/main/bad_prompt_version2.pt',
160
  'https://huggingface.co/embed/negative/resolve/main/EasyNegativeV2.safetensors',
161
  'https://huggingface.co/embed/negative/resolve/main/bad-hands-5.pt',
162
  ]
163
 
164
+ DIRECTORY_MODELS = 'models'
165
+ DIRECTORY_LORAS = 'loras'
166
+ DIRECTORY_VAES = 'vaes'
167
+ DIRECTORY_EMBEDS = 'embedings'
168
+ DIRECTORY_EMBEDS_SDXL = 'embedings_xl'
169
+ DIRECTORY_EMBEDS_POSITIVE_SDXL = 'embedings_xl/positive'
 
 
170
 
171
+ directories = [DIRECTORY_MODELS, DIRECTORY_LORAS, DIRECTORY_VAES, DIRECTORY_EMBEDS, DIRECTORY_EMBEDS_SDXL, DIRECTORY_EMBEDS_POSITIVE_SDXL]
172
+ for directory in directories:
173
+ os.makedirs(directory, exist_ok=True)
 
174
 
175
  HF_LORA_PRIVATE_REPOS1 = ['John6666/loratest1', 'John6666/loratest3', 'John6666/loratest4', 'John6666/loratest6']
176
  HF_LORA_PRIVATE_REPOS2 = ['John6666/loratest10', 'John6666/loratest11','John6666/loratest'] # to be sorted as 1 repo
formatter.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_cpp_agent.messages_formatter import MessagesFormatter, PromptMarkers, Roles
2
+
3
+ mistral_v1_markers = {
4
+ Roles.system: PromptMarkers(""" [INST]""", """ [/INST] Understood.</s>"""),
5
+ Roles.user: PromptMarkers(""" [INST]""", """ [/INST]"""),
6
+ Roles.assistant: PromptMarkers(" ", "</s>"),
7
+ Roles.tool: PromptMarkers("", ""),
8
+ }
9
+
10
+ mistral_v1_formatter = MessagesFormatter(
11
+ pre_prompt="",
12
+ prompt_markers=mistral_v1_markers,
13
+ include_sys_prompt_in_first_user_message=False,
14
+ default_stop_sequences=["</s>"]
15
+ )
16
+
17
+ mistral_v2_markers = {
18
+ Roles.system: PromptMarkers("""[INST] """, """[/INST] Understood.</s>"""),
19
+ Roles.user: PromptMarkers("""[INST] """, """[/INST]"""),
20
+ Roles.assistant: PromptMarkers(" ", "</s>"),
21
+ Roles.tool: PromptMarkers("", ""),
22
+ }
23
+
24
+ mistral_v2_formatter = MessagesFormatter(
25
+ pre_prompt="",
26
+ prompt_markers=mistral_v2_markers,
27
+ include_sys_prompt_in_first_user_message=False,
28
+ default_stop_sequences=["</s>"]
29
+ )
30
+
31
+ mistral_v3_tekken_markers = {
32
+ Roles.system: PromptMarkers("""[INST]""", """[/INST]Understood.</s>"""),
33
+ Roles.user: PromptMarkers("""[INST]""", """[/INST]"""),
34
+ Roles.assistant: PromptMarkers("", "</s>"),
35
+ Roles.tool: PromptMarkers("", ""),
36
+ }
37
+
38
+ mistral_v3_tekken_formatter = MessagesFormatter(
39
+ pre_prompt="",
40
+ prompt_markers=mistral_v3_tekken_markers,
41
+ include_sys_prompt_in_first_user_message=False,
42
+ default_stop_sequences=["</s>"]
43
+ )
llmdolphin.py CHANGED
@@ -8,7 +8,8 @@ from llama_cpp_agent.chat_history.messages import Roles
8
  from ja_to_danbooru.ja_to_danbooru import jatags_to_danbooru_tags
9
  import wrapt_timeout_decorator
10
  from pathlib import Path
11
-
 
12
 
13
  llm_models_dir = "./llm_models"
14
  llm_models = {
@@ -18,8 +19,10 @@ llm_models = {
18
  #"": ["", MessagesFormatterType.OPEN_CHAT],
19
  #"": ["", MessagesFormatterType.CHATML],
20
  #"": ["", MessagesFormatterType.PHI_3],
 
21
  "mn-12b-lyra-v2a1-q5_k_m.gguf": ["HalleyStarbun/MN-12B-Lyra-v2a1-Q5_K_M-GGUF", MessagesFormatterType.CHATML],
22
  "L3-8B-Tamamo-v1.i1-Q5_K_M.gguf": ["mradermacher/L3-8B-Tamamo-v1-i1-GGUF", MessagesFormatterType.LLAMA_3],
 
23
  "Mahou-1.5-mistral-nemo-12B.i1-Q4_K_M.gguf": ["mradermacher/Mahou-1.5-mistral-nemo-12B-i1-GGUF", MessagesFormatterType.MISTRAL],
24
  "MN-12B-Mag-Mell-Q4_K_M.gguf": ["inflatebot/MN-12B-Mag-Mell-R1-GGUF", MessagesFormatterType.MISTRAL],
25
  "Qwen2.5-14B-Instruct-Q4_K_M.gguf": ["bartowski/Qwen2.5-14B-Instruct-GGUF", MessagesFormatterType.OPEN_CHAT],
@@ -59,12 +62,51 @@ llm_models = {
59
  "Qwen2.5-14B_Uncensored_Instruct.Q4_K_M.gguf": ["mradermacher/Qwen2.5-14B_Uncensored_Instruct-GGUF", MessagesFormatterType.OPEN_CHAT],
60
  "EVA-Qwen2.5-14B-v0.0.i1-IQ4_XS.gguf": ["mradermacher/EVA-Qwen2.5-14B-v0.0-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
61
  "MN-12B-Vespa-x1.i1-Q4_K_M.gguf": ["mradermacher/MN-12B-Vespa-x1-i1-GGUF", MessagesFormatterType.CHATML],
 
62
  "Mistral-Nemo-12B-ArliAI-RPMax-v1.1.i1-Q4_K_M.gguf": ["mradermacher/Mistral-Nemo-12B-ArliAI-RPMax-v1.1-i1-GGUF", MessagesFormatterType.MISTRAL],
63
  "Trinas_Nectar-8B-model_stock.i1-Q4_K_M.gguf": ["mradermacher/Trinas_Nectar-8B-model_stock-i1-GGUF", MessagesFormatterType.MISTRAL],
64
  "ChatWaifu_12B_v2.0.Q5_K_M.gguf": ["mradermacher/ChatWaifu_12B_v2.0-GGUF", MessagesFormatterType.MISTRAL],
65
  "ChatWaifu_22B_v2.0_preview.Q4_K_S.gguf": ["mradermacher/ChatWaifu_22B_v2.0_preview-GGUF", MessagesFormatterType.MISTRAL],
66
  "ChatWaifu_v1.4.Q5_K_M.gguf": ["mradermacher/ChatWaifu_v1.4-GGUF", MessagesFormatterType.MISTRAL],
67
  "ChatWaifu_v1.3.1.Q4_K_M.gguf": ["mradermacher/ChatWaifu_v1.3.1-GGUF", MessagesFormatterType.MISTRAL],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  "Aster-G2-9B-v1.Q4_K_S.gguf": ["mradermacher/Aster-G2-9B-v1-GGUF", MessagesFormatterType.ALPACA],
69
  "nemo-12b-rp-merge.Q4_K_S.gguf": ["mradermacher/nemo-12b-rp-merge-GGUF", MessagesFormatterType.MISTRAL],
70
  "SthenoMix3.3.Q5_K_M.gguf": ["mradermacher/SthenoMix3.3-GGUF", MessagesFormatterType.LLAMA_3],
@@ -792,8 +834,12 @@ llm_formats = {
792
  "PHI 3": MessagesFormatterType.PHI_3,
793
  "Autocoder": MessagesFormatterType.AUTOCODER,
794
  "DeepSeek Coder v2": MessagesFormatterType.DEEP_SEEK_CODER_2,
795
- "Gemma 2": MessagesFormatterType.ALPACA,
796
  "Qwen2": MessagesFormatterType.OPEN_CHAT,
 
 
 
 
797
  }
798
  # https://github.com/Maximilian-Winter/llama-cpp-agent
799
  llm_languages = ["English", "Japanese", "Chinese", "Korean", "Spanish", "Portuguese", "German", "French", "Finnish", "Russian"]
@@ -1213,7 +1259,8 @@ def dolphin_respond(
1213
  agent = LlamaCppAgent(
1214
  provider,
1215
  system_prompt=f"{system_message}",
1216
- predefined_messages_formatter_type=chat_template,
 
1217
  debug_output=False
1218
  )
1219
 
@@ -1307,7 +1354,8 @@ def dolphin_respond_auto(
1307
  agent = LlamaCppAgent(
1308
  provider,
1309
  system_prompt=f"{system_message}",
1310
- predefined_messages_formatter_type=chat_template,
 
1311
  debug_output=False
1312
  )
1313
 
@@ -1347,7 +1395,7 @@ def dolphin_respond_auto(
1347
  outputs = ""
1348
  for output in stream:
1349
  outputs += output
1350
- yield [(outputs, None)]
1351
 
1352
 
1353
  def dolphin_parse_simple(
@@ -1402,7 +1450,8 @@ def respond_playground(
1402
  agent = LlamaCppAgent(
1403
  provider,
1404
  system_prompt=f"{system_message}",
1405
- predefined_messages_formatter_type=chat_template,
 
1406
  debug_output=False
1407
  )
1408
 
 
8
  from ja_to_danbooru.ja_to_danbooru import jatags_to_danbooru_tags
9
  import wrapt_timeout_decorator
10
  from pathlib import Path
11
+ from llama_cpp_agent.messages_formatter import MessagesFormatter
12
+ from formatter import mistral_v1_formatter, mistral_v2_formatter, mistral_v3_tekken_formatter
13
 
14
  llm_models_dir = "./llm_models"
15
  llm_models = {
 
19
  #"": ["", MessagesFormatterType.OPEN_CHAT],
20
  #"": ["", MessagesFormatterType.CHATML],
21
  #"": ["", MessagesFormatterType.PHI_3],
22
+ #"": ["", MessagesFormatterType.GEMMA_2],
23
  "mn-12b-lyra-v2a1-q5_k_m.gguf": ["HalleyStarbun/MN-12B-Lyra-v2a1-Q5_K_M-GGUF", MessagesFormatterType.CHATML],
24
  "L3-8B-Tamamo-v1.i1-Q5_K_M.gguf": ["mradermacher/L3-8B-Tamamo-v1-i1-GGUF", MessagesFormatterType.LLAMA_3],
25
+ "MN-Chinofun-12B-2.i1-Q4_K_M.gguf": ["mradermacher/MN-Chinofun-12B-2-i1-GGUF", MessagesFormatterType.MISTRAL],
26
  "Mahou-1.5-mistral-nemo-12B.i1-Q4_K_M.gguf": ["mradermacher/Mahou-1.5-mistral-nemo-12B-i1-GGUF", MessagesFormatterType.MISTRAL],
27
  "MN-12B-Mag-Mell-Q4_K_M.gguf": ["inflatebot/MN-12B-Mag-Mell-R1-GGUF", MessagesFormatterType.MISTRAL],
28
  "Qwen2.5-14B-Instruct-Q4_K_M.gguf": ["bartowski/Qwen2.5-14B-Instruct-GGUF", MessagesFormatterType.OPEN_CHAT],
 
62
  "Qwen2.5-14B_Uncensored_Instruct.Q4_K_M.gguf": ["mradermacher/Qwen2.5-14B_Uncensored_Instruct-GGUF", MessagesFormatterType.OPEN_CHAT],
63
  "EVA-Qwen2.5-14B-v0.0.i1-IQ4_XS.gguf": ["mradermacher/EVA-Qwen2.5-14B-v0.0-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
64
  "MN-12B-Vespa-x1.i1-Q4_K_M.gguf": ["mradermacher/MN-12B-Vespa-x1-i1-GGUF", MessagesFormatterType.CHATML],
65
+ "Rocinante-12B-v2h-Q4_K_M.gguf": ["BeaverAI/Rocinante-12B-v2h-GGUF", MessagesFormatterType.MISTRAL],
66
  "Mistral-Nemo-12B-ArliAI-RPMax-v1.1.i1-Q4_K_M.gguf": ["mradermacher/Mistral-Nemo-12B-ArliAI-RPMax-v1.1-i1-GGUF", MessagesFormatterType.MISTRAL],
67
  "Trinas_Nectar-8B-model_stock.i1-Q4_K_M.gguf": ["mradermacher/Trinas_Nectar-8B-model_stock-i1-GGUF", MessagesFormatterType.MISTRAL],
68
  "ChatWaifu_12B_v2.0.Q5_K_M.gguf": ["mradermacher/ChatWaifu_12B_v2.0-GGUF", MessagesFormatterType.MISTRAL],
69
  "ChatWaifu_22B_v2.0_preview.Q4_K_S.gguf": ["mradermacher/ChatWaifu_22B_v2.0_preview-GGUF", MessagesFormatterType.MISTRAL],
70
  "ChatWaifu_v1.4.Q5_K_M.gguf": ["mradermacher/ChatWaifu_v1.4-GGUF", MessagesFormatterType.MISTRAL],
71
  "ChatWaifu_v1.3.1.Q4_K_M.gguf": ["mradermacher/ChatWaifu_v1.3.1-GGUF", MessagesFormatterType.MISTRAL],
72
+ "Magnum_Dark_Madness_12b.Q4_K_S.gguf": ["mradermacher/Magnum_Dark_Madness_12b-GGUF", MessagesFormatterType.MISTRAL],
73
+ "Magnum_Lyra_Darkness_12b.Q4_K_M.gguf": ["mradermacher/Magnum_Lyra_Darkness_12b-GGUF", MessagesFormatterType.MISTRAL],
74
+ "Heart_Stolen-8B-task.i1-Q4_K_M.gguf": ["mradermacher/Heart_Stolen-8B-task-i1-GGUF", MessagesFormatterType.LLAMA_3],
75
+ "Magnum_Backyard_Party_12b.Q4_K_M.gguf": ["mradermacher/Magnum_Backyard_Party_12b-GGUF", MessagesFormatterType.MISTRAL],
76
+ "Magnum_Madness-12b.Q4_K_M.gguf": ["mradermacher/Magnum_Madness-12b-GGUF", MessagesFormatterType.MISTRAL],
77
+ "L3.1-Moe-2x8B-v0.2.i1-Q4_K_M.gguf": ["mradermacher/L3.1-Moe-2x8B-v0.2-i1-GGUF", MessagesFormatterType.LLAMA_3],
78
+ "Qwen2.5-14B-Wernicke-DPO.i1-Q4_K_M.gguf": ["mradermacher/Qwen2.5-14B-Wernicke-DPO-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
79
+ "Gemma-2-Ataraxy-v4d-9B.i1-Q4_K_M.gguf": ["mradermacher/Gemma-2-Ataraxy-v4d-9B-i1-GGUF", MessagesFormatterType.GEMMA_2],
80
+ "qwen2.5-14b-megamerge-pt2-q5_k_m.gguf": ["CultriX/Qwen2.5-14B-MegaMerge-pt2-Q5_K_M-GGUF", MessagesFormatterType.OPEN_CHAT],
81
+ "quantqwen2-merged-16bit-q4_k_m.gguf": ["davidbzyk/QuantQwen2-merged-16bit-Q4_K_M-GGUF", MessagesFormatterType.OPEN_CHAT],
82
+ "Mistral-nemo-ja-rp-v0.2-Q4_K_S.gguf": ["ascktgcc/Mistral-nemo-ja-rp-v0.2-GGUF", MessagesFormatterType.MISTRAL],
83
+ "llama3.1-darkstorm-aspire-8b-q4_k_m.gguf": ["ZeroXClem/Llama3.1-DarkStorm-Aspire-8B-Q4_K_M-GGUF", MessagesFormatterType.LLAMA_3],
84
+ "llama-3-yggdrasil-astralspice-8b-q4_k_m.gguf": ["ZeroXClem/Llama-3-Yggdrasil-AstralSpice-8B-Q4_K_M-GGUF", MessagesFormatterType.LLAMA_3],
85
+ "hermes-llama3-roleplay-1000-v2.Q5_K_M.gguf": ["mradermacher/hermes-llama3-roleplay-1000-v2-GGUF", MessagesFormatterType.LLAMA_3],
86
+ "hermes-stheno-8B-v0.1.i1-Q5_K_M.gguf": ["mradermacher/hermes-stheno-8B-v0.1-i1-GGUF", MessagesFormatterType.LLAMA_3],
87
+ "qwen-carpmuscle-r-v0.3.Q4_K_M.gguf": ["mradermacher/qwen-carpmuscle-r-v0.3-GGUF", MessagesFormatterType.OPEN_CHAT],
88
+ "magnum-v4-12b.i1-Q4_K_M.gguf": ["mradermacher/magnum-v4-12b-i1-GGUF", MessagesFormatterType.MISTRAL],
89
+ "magnum-consolidatum-v1-12b.Q4_K_M.gguf": ["mradermacher/magnum-consolidatum-v1-12b-GGUF", MessagesFormatterType.MISTRAL],
90
+ "sillyrp-7b.i1-Q5_K_M.gguf": ["mradermacher/sillyrp-7b-i1-GGUF", MessagesFormatterType.CHATML],
91
+ "BlackSheep-Coder.i1-Q4_K_M.gguf": ["mradermacher/BlackSheep-Coder-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
92
+ "Gemmasutra-9B-v1.Q4_K_M.gguf": ["mradermacher/Gemmasutra-9B-v1-GGUF", MessagesFormatterType.ALPACA],
93
+ "Tiger-Gemma-9B-v3.Q4_K_M.gguf": ["mradermacher/Tiger-Gemma-9B-v3-GGUF", MessagesFormatterType.ALPACA],
94
+ "mt-merge-gemma-2-9b-q6_k.gguf": ["zelk12/MT-Merge-gemma-2-9B-Q6_K-GGUF", MessagesFormatterType.ALPACA],
95
+ "Qwen2.5-14B-Wernicke.i1-Q4_K_M.gguf": ["mradermacher/Qwen2.5-14B-Wernicke-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
96
+ "Llama-3SOME-8B-v2.Q5_K_M.gguf": ["mradermacher/Llama-3SOME-8B-v2-GGUF", MessagesFormatterType.LLAMA_3],
97
+ "Ministral-8B-Instruct-2410-Q5_K_M.gguf": ["bartowski/Ministral-8B-Instruct-2410-GGUF", MessagesFormatterType.MISTRAL],
98
+ "mahou-1.5-mistral-nemo-12b-lorablated.Q4_K_M.gguf": ["nbeerbower/Mahou-1.5-mistral-nemo-12B-lorablated-GGUF", MessagesFormatterType.MISTRAL],
99
+ "Gemma2-Eclipse-9B.i1-Q4_K_M.gguf": ["mradermacher/Gemma2-Eclipse-9B-i1-GGUF", MessagesFormatterType.ALPACA],
100
+ "ldm_soup_Llama-3.1-8B-Inst.Q5_K_M.gguf": ["mradermacher/ldm_soup_Llama-3.1-8B-Inst-GGUF", MessagesFormatterType.LLAMA_3],
101
+ "L3.1-ChubbyBase-10B.i1-Q4_K_M.gguf": ["mradermacher/L3.1-ChubbyBase-10B-i1-GGUF", MessagesFormatterType.LLAMA_3],
102
+ "MN-Tiramisu-12B.i1-Q4_K_M.gguf": ["mradermacher/MN-Tiramisu-12B-i1-GGUF", MessagesFormatterType.CHATML],
103
+ "llama-3.2-3b-instruct-uncensored-q6_k.gguf": ["nolynn/Llama-3.2-3B-Instruct-uncensored-Q6_K-GGUF", MessagesFormatterType.LLAMA_3],
104
+ "thea-3b-25r.i1-Q5_K_M.gguf": ["mradermacher/thea-3b-25r-i1-GGUF", MessagesFormatterType.LLAMA_3],
105
+ "Gemma-2-9B-It-SPPO-Iter3.i1-Q4_K_M.gguf": ["mradermacher/Gemma-2-9B-It-SPPO-Iter3-i1-GGUF", MessagesFormatterType.ALPACA],
106
+ "Qwenslerp3-14B.Q4_K_M.gguf": ["mradermacher/Qwenslerp3-14B-GGUF", MessagesFormatterType.OPEN_CHAT],
107
+ "magnum-v4-9b.Q4_K_M.gguf": ["mradermacher/magnum-v4-9b-GGUF", MessagesFormatterType.ALPACA],
108
+ "make_my_monster_grow-12b-model_stock-q4_k_m.gguf": ["DreadPoor/Make_My_Monster_Grow-12B-Model_Stock-Q4_K_M-GGUF", MessagesFormatterType.MISTRAL],
109
+ "emu_eggs-9b-model_stock-q4_k_m.gguf": ["DreadPoor/Emu_Eggs-9B-Model_Stock-Q4_K_M-GGUF", MessagesFormatterType.ALPACA],
110
  "Aster-G2-9B-v1.Q4_K_S.gguf": ["mradermacher/Aster-G2-9B-v1-GGUF", MessagesFormatterType.ALPACA],
111
  "nemo-12b-rp-merge.Q4_K_S.gguf": ["mradermacher/nemo-12b-rp-merge-GGUF", MessagesFormatterType.MISTRAL],
112
  "SthenoMix3.3.Q5_K_M.gguf": ["mradermacher/SthenoMix3.3-GGUF", MessagesFormatterType.LLAMA_3],
 
834
  "PHI 3": MessagesFormatterType.PHI_3,
835
  "Autocoder": MessagesFormatterType.AUTOCODER,
836
  "DeepSeek Coder v2": MessagesFormatterType.DEEP_SEEK_CODER_2,
837
+ "Gemma 2": MessagesFormatterType.GEMMA_2,
838
  "Qwen2": MessagesFormatterType.OPEN_CHAT,
839
+ "Open Interpreter": MessagesFormatterType.OPEN_INTERPRETER,
840
+ "Mistral Tokenizer V1": mistral_v1_formatter,
841
+ "Mistral Tokenizer V2": mistral_v2_formatter,
842
+ "Mistral Tokenizer V3 - Tekken": mistral_v3_tekken_formatter,
843
  }
844
  # https://github.com/Maximilian-Winter/llama-cpp-agent
845
  llm_languages = ["English", "Japanese", "Chinese", "Korean", "Spanish", "Portuguese", "German", "French", "Finnish", "Russian"]
 
1259
  agent = LlamaCppAgent(
1260
  provider,
1261
  system_prompt=f"{system_message}",
1262
+ predefined_messages_formatter_type=chat_template if not isinstance(chat_template, MessagesFormatter) else None,
1263
+ custom_messages_formatter=chat_template if isinstance(chat_template, MessagesFormatter) else None,
1264
  debug_output=False
1265
  )
1266
 
 
1354
  agent = LlamaCppAgent(
1355
  provider,
1356
  system_prompt=f"{system_message}",
1357
+ predefined_messages_formatter_type=chat_template if not isinstance(chat_template, MessagesFormatter) else None,
1358
+ custom_messages_formatter=chat_template if isinstance(chat_template, MessagesFormatter) else None,
1359
  debug_output=False
1360
  )
1361
 
 
1395
  outputs = ""
1396
  for output in stream:
1397
  outputs += output
1398
+ yield [(outputs, None)], gr.update()
1399
 
1400
 
1401
  def dolphin_parse_simple(
 
1450
  agent = LlamaCppAgent(
1451
  provider,
1452
  system_prompt=f"{system_message}",
1453
+ predefined_messages_formatter_type=chat_template if not isinstance(chat_template, MessagesFormatter) else None,
1454
+ custom_messages_formatter=chat_template if isinstance(chat_template, MessagesFormatter) else None,
1455
  debug_output=False
1456
  )
1457
 
lora_dict.json CHANGED
@@ -1490,6 +1490,13 @@
1490
  "https://civitai.com/models/844457",
1491
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/0740f561-8808-425c-a4e0-90575f887262/width=450/34033551.jpeg"
1492
  ],
 
 
 
 
 
 
 
1493
  "MS_PDXL_AfterSex_Lite": [
1494
  "after sex, cum, lying, cumdrip, ass, on stomach, on back, fucked silly, sweat, cum pool, bukkake, trembling",
1495
  "Pony",
@@ -2120,6 +2127,13 @@
2120
  "https://civitai.com/models/187744",
2121
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/96984154-3d8b-4b34-8cd6-3db03af93563/width=450/3359107.jpeg"
2122
  ],
 
 
 
 
 
 
 
2123
  "Side-by-Side_Cowgirl_position": [
2124
  "",
2125
  "Pony",
@@ -2176,6 +2190,13 @@
2176
  "https://civitai.com/models/595321",
2177
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/bc52e939-7385-4858-be93-dd370279d0ca/width=450/20952551.jpeg"
2178
  ],
 
 
 
 
 
 
 
2179
  "Squatting_PonyXL_v1": [
2180
  "squatting / legs together, from below,",
2181
  "Pony",
@@ -2967,6 +2988,13 @@
2967
  "https://civitai.com/models/526774",
2968
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b40d42c4-66df-4c6e-9351-2b0343007979/width=450/16455415.jpeg"
2969
  ],
 
 
 
 
 
 
 
2970
  "armp1tt1ckl3": [
2971
  "armp1tt1ckl3",
2972
  "Pony",
@@ -3975,6 +4003,20 @@
3975
  "https://civitai.com/models/628775",
3976
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/83566548-b845-4d8b-a0d0-be8cc8822a81/width=450/23142557.jpeg"
3977
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3978
  "dawa": [
3979
  "dawa",
3980
  "SDXL 1.0",
@@ -4381,6 +4423,13 @@
4381
  "https://civitai.com/models/577378",
4382
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/459bd20d-a9d6-4a0b-8947-7dcebc061c0f/width=450/19781986.jpeg"
4383
  ],
 
 
 
 
 
 
 
4384
  "genshin_v4": [
4385
  "hina_(genshin_impact) / sethos_(genshin_impact) / raiden_shogun_mitake",
4386
  "Pony",
@@ -4647,6 +4696,20 @@
4647
  "https://civitai.com/models/462635",
4648
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/8cac72e3-3107-44ba-b860-f0b0eed4d8a3/width=450/12869927.jpeg"
4649
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4650
  "haraboko_pony_V2_0": [
4651
  "stomach bulge",
4652
  "Pony",
@@ -4654,6 +4717,13 @@
4654
  "https://civitai.com/models/486122",
4655
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b6735506-c5c4-4a3a-8796-c1f86bcc7654/width=450/16987795.jpeg"
4656
  ],
 
 
 
 
 
 
 
4657
  "harmonicaSY": [
4658
  "harmonica",
4659
  "SDXL 1.0",
@@ -4689,6 +4759,20 @@
4689
  "https://civitai.com/models/412943",
4690
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e9a0d288-32fe-40a5-8576-3056d4562dfe/width=450/10426060.jpeg"
4691
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4692
  "hennnachoco_face_XL-v1": [
4693
  "looking at viewer,close-up,blurry background",
4694
  "SDXL 1.0",
@@ -4787,6 +4871,62 @@
4787
  "https://civitai.com/models/498731",
4788
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/06a0dc3a-42ba-42b5-9ea9-d6b6faa3543b/width=450/14812284.jpeg"
4789
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4790
  "hotpants_XL_V1_0": [
4791
  "hotpants",
4792
  "SDXL 1.0",
@@ -4843,6 +4983,20 @@
4843
  "https://civitai.com/models/363398",
4844
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e8f31f60-8949-42da-b740-c6541e0d6d9b/width=450/8398353.jpeg"
4845
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4846
  "implied_fellatio_v0_1-pony": [
4847
  "implied fellatio",
4848
  "Pony",
@@ -4948,6 +5102,20 @@
4948
  "https://civitai.com/models/445063",
4949
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/9555de99-1fba-4af8-9cb2-f03f7ae6e094/width=450/32416800.jpeg"
4950
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4951
  "jyojimizugi_Pony_V1_0": [
4952
  "jyojimizugi,bikini,frills",
4953
  "Pony",
@@ -4983,6 +5151,13 @@
4983
  "https://civitai.com/models/234887",
4984
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4d94a5a1-b7d2-40b7-b864-f112b26e09a7/width=450/4642510.jpeg"
4985
  ],
 
 
 
 
 
 
 
4986
  "kakigoori_pony_V1_0": [
4987
  "kakigoori / shaved ice / spoon",
4988
  "Pony",
@@ -5130,6 +5305,13 @@
5130
  "https://civitai.com/models/574993",
5131
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e6148d75-f33f-4f56-8203-4d88a48231e2/width=450/21439541.jpeg"
5132
  ],
 
 
 
 
 
 
 
5133
  "kuro_gyaru_pony_V1_0": [
5134
  "kuro gyaru / dark skin / blonde hair",
5135
  "Pony",
@@ -5480,6 +5662,13 @@
5480
  "https://civitai.com/models/549761",
5481
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/5059fb4e-8cb0-4870-babe-2e62d93ec592/width=450/18112025.jpeg"
5482
  ],
 
 
 
 
 
 
 
5483
  "matsubamuzushi_pony_V1_0": [
5484
  "matsubakuzushi, sex, leg lift, leg up, 1boy, 1girl,lying",
5485
  "Pony",
@@ -5788,6 +5977,13 @@
5788
  "https://civitai.com/models/551712",
5789
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b17f1a24-390b-4a5c-a4a1-bc479b627177/width=450/18108188.jpeg"
5790
  ],
 
 
 
 
 
 
 
5791
  "ojou-sama_pose__pony": [
5792
  "ojou-sama_pose ",
5793
  "Pony",
@@ -5865,6 +6061,20 @@
5865
  "https://civitai.com/models/503381",
5866
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d376245b-d55f-4635-8a68-c7317268f1e9/width=450/15093929.jpeg"
5867
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5868
  "onimai_pony": [
5869
  "onimai",
5870
  "Pony",
@@ -5963,6 +6173,13 @@
5963
  "https://civitai.com/models/454066",
5964
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d73c20b4-a1bb-4c9d-88ba-150be2e49cb9/width=450/14888108.jpeg"
5965
  ],
 
 
 
 
 
 
 
5966
  "panties_aside_XL_V1_0": [
5967
  "panties / panties aside / pussy / anal",
5968
  "SDXL 1.0",
@@ -6159,6 +6376,13 @@
6159
  "https://civitai.com/models/159333",
6160
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4b04073f-f9c0-446a-9a2b-b8a818cf96f8/width=450/9737393.jpeg"
6161
  ],
 
 
 
 
 
 
 
6162
  "pointing_a31-3": [
6163
  "pointing, chibi, fang, open mouth,",
6164
  "SDXL 1.0",
@@ -6551,6 +6775,13 @@
6551
  "https://civitai.com/models/473507",
6552
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e0e9a011-421e-4d30-afaa-eb113ed9653c/width=450/13448210.jpeg"
6553
  ],
 
 
 
 
 
 
 
6554
  "rei_no_pool_PONY_V1": [
6555
  "reinopool, pool, window, scenery, indoors, tiles, water, tile floor, pool ladder, plant",
6556
  "Pony",
@@ -6817,6 +7048,20 @@
6817
  "https://civitai.com/models/600296",
6818
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/3ac9e35e-3e3f-492e-a81f-9791ff6e6914/width=450/21281952.jpeg"
6819
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6820
  "sfw1": [
6821
  "",
6822
  "Pony",
@@ -6894,6 +7139,13 @@
6894
  "https://civitai.com/models/102603",
6895
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/ce030fc2-c6c8-4153-ae51-5fa6fbc51b8e/width=450/20563893.jpeg"
6896
  ],
 
 
 
 
 
 
 
6897
  "sidepositionxl16": [
6898
  "side,scenery,part of landscape",
6899
  "SDXL 1.0",
@@ -6992,6 +7244,13 @@
6992
  "https://civitai.com/models/552152",
6993
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/9ee78490-d6c5-45c1-a1a0-92cb965faa10/width=450/18135129.jpeg"
6994
  ],
 
 
 
 
 
 
 
6995
  "soccer_uniform_pony_V1_1": [
6996
  "soccer uniform / soccer",
6997
  "Pony",
@@ -7097,6 +7356,13 @@
7097
  "https://civitai.com/models/273357",
7098
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d529909d-2115-4e32-8226-28537d5b1763/width=450/8178754.jpeg"
7099
  ],
 
 
 
 
 
 
 
7100
  "ss_mss_pony-000005": [
7101
  "ss_mss, miniature_school_swimsuit, groin, highleg, partially visible vulva, wedgie, undersized clothes, nipples, cleavage",
7102
  "Pony",
@@ -7111,6 +7377,20 @@
7111
  "https://civitai.com/models/434763",
7112
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/1434e8b5-0aa1-46b4-a366-fc5271a922a3/width=450/12693104.jpeg"
7113
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7114
  "stradding_chair_XL": [
7115
  "",
7116
  "SDXL 1.0",
@@ -7202,6 +7482,13 @@
7202
  "https://civitai.com/models/461839",
7203
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/f1f48385-5230-4eab-ba2a-080c1bb2af1a/width=450/13712411.jpeg"
7204
  ],
 
 
 
 
 
 
 
7205
  "sukumizutan_XL_v1": [
7206
  "sukumizutan, tanlines, tan",
7207
  "SDXL 1.0",
@@ -7636,6 +7923,13 @@
7636
  "https://civitai.com/models/563723",
7637
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/1cdf9e3a-9412-4a37-aea6-01524c61f4ce/width=450/18879048.jpeg"
7638
  ],
 
 
 
 
 
 
 
7639
  "under_the_table_blowjob": [
7640
  "under_the_table_blowjob",
7641
  "Pony",
@@ -8091,6 +8385,27 @@
8091
  "https://civitai.com/models/454664",
8092
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e81c4662-b60a-4169-a30b-31753f93c7e7/width=450/15517389.jpeg"
8093
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8094
  "yukata_pony_V1_0": [
8095
  " jyojifuku, yukata, japanese clothes, floral print,hair ornament,sandals",
8096
  "Pony",
 
1490
  "https://civitai.com/models/844457",
1491
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/0740f561-8808-425c-a4e0-90575f887262/width=450/34033551.jpeg"
1492
  ],
1493
+ "MORTARHEADD_like_mecha_v1_2": [
1494
+ "MORTARHEADD / MH-POSE / MH-BUSTER / MH-KOG / MH-LED-MIRAGE / MH-Engage-SR1 / MH-the-BANG / MH-Neptune / MH-BTK",
1495
+ "SDXL 1.0",
1496
+ "FSS Mortar headd Like mecha <The Five Star Stories>",
1497
+ "https://civitai.com/models/844457",
1498
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/2c156011-ae37-476b-9c88-b7ee614b57c3/width=450/35788486.jpeg"
1499
+ ],
1500
  "MS_PDXL_AfterSex_Lite": [
1501
  "after sex, cum, lying, cumdrip, ass, on stomach, on back, fucked silly, sweat, cum pool, bukkake, trembling",
1502
  "Pony",
 
2127
  "https://civitai.com/models/187744",
2128
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/96984154-3d8b-4b34-8cd6-3db03af93563/width=450/3359107.jpeg"
2129
  ],
2130
+ "ShungikuTenUdon_Pony_V1": [
2131
+ "(shungikutenudon) , 1girl, solo, breasts, nipples, spread legs, spread pussy, erection clitoris, clitoris, clitoral foreskin, cute pussy, enlarged labia, developed inner labia, urethra,spread urethra, pussy juice, close-up pussy, gaping, cervix, / (close-up clitoris), (close-up layers),(Multiple layers), (multiple views), simple bacground, zoom layer, close-up layer,",
2132
+ "Pony",
2133
+ "Hentai Huge Clitoris Spread Pussy (shungiku tenudon) Pony XL | \u5de8\u5927\u30af\u30ea\u30c8\u30ea\u30b9 \u307e\u3093\u3053\u304f\u3071\u3041 (\u6625\u83ca\u5929\u3046\u3069\u3093)",
2134
+ "https://civitai.com/models/868507",
2135
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e4a41d92-8bae-404a-b8df-d12a2687b160/width=450/35391164.jpeg"
2136
+ ],
2137
  "Side-by-Side_Cowgirl_position": [
2138
  "",
2139
  "Pony",
 
2190
  "https://civitai.com/models/595321",
2191
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/bc52e939-7385-4858-be93-dd370279d0ca/width=450/20952551.jpeg"
2192
  ],
2193
+ "SpreadPussy_STU_Pony_V2": [
2194
+ "(dilation Vagina),(Put fingers in Vagina), (spread Vagina wide), (Perfect hands),cervix, Vagina,spread legs, erection clitoris, clitoris, clitoral foreskin, enlarged labia, developed inner labia, urethra,spread urethra, pussy juice, close-up pussy, cum in pussy, cum in anal, after sex, cum string, cum drip, cum pool, (close-up clitoris), (close-up layers:1.2),(Multiple layers:1.2), (multiple views:1.2), simple bacground, zoom layer, close-up layer,",
2195
+ "Pony",
2196
+ "Hentai Pussy inspection (Gaping Pussy Opened in Fingers) Pony XL | \u307e\u3093\u3053\u691c\u67fb\uff08\u5965\u307e\u3067\u6307\u3092\u5165\u308c\u3066\u304f\u3071\u3041\u2665\uff09",
2197
+ "https://civitai.com/models/870724",
2198
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/be0c3a9b-f287-47dd-9d27-8e1650add4df/width=450/35523008.jpeg"
2199
+ ],
2200
  "Squatting_PonyXL_v1": [
2201
  "squatting / legs together, from below,",
2202
  "Pony",
 
2988
  "https://civitai.com/models/526774",
2989
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b40d42c4-66df-4c6e-9351-2b0343007979/width=450/16455415.jpeg"
2990
  ],
2991
+ "armcannon_XL_v1": [
2992
+ "arm cannon",
2993
+ "SDXL 1.0",
2994
+ "arm cannon / \u30a2\u30fc\u30e0\u30ad\u30e3\u30ce\u30f3 / \u30ed\u30c3\u30af\u30d0\u30b9\u30bf\u30fc / \u30b5\u30a4\u30b3\u30ac\u30f3",
2995
+ "https://civitai.com/models/870619",
2996
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/6fd8ed3c-794d-4c56-a994-6fa45a5b09ca/width=450/35509987.jpeg"
2997
+ ],
2998
  "armp1tt1ckl3": [
2999
  "armp1tt1ckl3",
3000
  "Pony",
 
4003
  "https://civitai.com/models/628775",
4004
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/83566548-b845-4d8b-a0d0-be8cc8822a81/width=450/23142557.jpeg"
4005
  ],
4006
+ "danmen_illustrious_V1_0": [
4007
+ "danmen,penis,vaginal / uterus / x-ray / cross-section / internal cumshot",
4008
+ "Illustrious",
4009
+ "\u65ad\u9762\u56f3/uterus",
4010
+ "https://civitai.com/models/853101",
4011
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/441cbbf7-aa73-4991-b9aa-21432686b715/width=450/36094538.jpeg"
4012
+ ],
4013
+ "danmen_pony_V1_0": [
4014
+ " danmen, sex, vaginal / uterus / cross-section / x-ray",
4015
+ "Pony",
4016
+ "\u65ad\u9762\u56f3/uterus",
4017
+ "https://civitai.com/models/853101",
4018
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/9bbdb650-67f6-4b7a-b020-2f1b15363919/width=450/34507990.jpeg"
4019
+ ],
4020
  "dawa": [
4021
  "dawa",
4022
  "SDXL 1.0",
 
4423
  "https://civitai.com/models/577378",
4424
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/459bd20d-a9d6-4a0b-8947-7dcebc061c0f/width=450/19781986.jpeg"
4425
  ],
4426
+ "genbaneko_v4_illustrious_uo_1024-000040": [
4427
+ "genbaneko / cat, headwear, hat, grey headwear, baseball cap, / speech bubble, speech text,",
4428
+ "SDXL 1.0",
4429
+ "Shigotoneko(Genbaneko) Style - illustrious | \u4ed5\u4e8b\u732b\uff08\u73fe\u5834\u732b\uff09",
4430
+ "https://civitai.com/models/859355",
4431
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/0f145509-d867-418c-b545-0c0e49275f48/width=450/34849585.jpeg"
4432
+ ],
4433
  "genshin_v4": [
4434
  "hina_(genshin_impact) / sethos_(genshin_impact) / raiden_shogun_mitake",
4435
  "Pony",
 
4696
  "https://civitai.com/models/462635",
4697
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/8cac72e3-3107-44ba-b860-f0b0eed4d8a3/width=450/12869927.jpeg"
4698
  ],
4699
+ "haraboko_XL_V1_0": [
4700
+ "extrem insertion, stomach bulge",
4701
+ "SDXL 1.0",
4702
+ "\u8179\u307c\u3053/extrem insertion(XL,pony)",
4703
+ "https://civitai.com/models/486122",
4704
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b1388bbf-c16c-4165-b32f-b63ee7d7ed14/width=450/33120289.jpeg"
4705
+ ],
4706
+ "haraboko_XL_illustrious_V1_0": [
4707
+ " extrem insertion, stomach bulge",
4708
+ "Illustrious",
4709
+ "\u8179\u307c\u3053/extrem insertion(XL,pony)",
4710
+ "https://civitai.com/models/486122",
4711
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/031fb13c-3d5e-4ddf-b49f-1661b8db9c09/width=450/35521696.jpeg"
4712
+ ],
4713
  "haraboko_pony_V2_0": [
4714
  "stomach bulge",
4715
  "Pony",
 
4717
  "https://civitai.com/models/486122",
4718
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b6735506-c5c4-4a3a-8796-c1f86bcc7654/width=450/16987795.jpeg"
4719
  ],
4720
+ "haraboko_pony_V3_0": [
4721
+ "extrem insertion,stomach bulge",
4722
+ "Pony",
4723
+ "\u8179\u307c\u3053/extrem insertion(XL,pony)",
4724
+ "https://civitai.com/models/486122",
4725
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/50cfd157-5340-48d2-9189-d1332391a82a/width=450/33111898.jpeg"
4726
+ ],
4727
  "harmonicaSY": [
4728
  "harmonica",
4729
  "SDXL 1.0",
 
4759
  "https://civitai.com/models/412943",
4760
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e9a0d288-32fe-40a5-8576-3056d4562dfe/width=450/10426060.jpeg"
4761
  ],
4762
+ "heart_hands_XL_illustrious_V1_0": [
4763
+ "heart hands",
4764
+ "Illustrious",
4765
+ "\u624b\u30cf\u30fc\u30c8/heart hands",
4766
+ "https://civitai.com/models/870734",
4767
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/6e0665ea-3861-42f5-9f21-ad8d4aa7cb37/width=450/35520723.jpeg"
4768
+ ],
4769
+ "hekohakost2": [
4770
+ "koshi_heko_standing, hkhkstanding, (motion lines, sound effects:1.3) / koshi_heko_squatting, hkhksquatting, (motion lines, sound effects:1.3), squatting / koshi_heko_back, hkhkback, (motion lines, sound effects:1.3) / koshi_heko_lying, hkhklying, (motion lines, sound effects:1.3), lying",
4771
+ "Pony",
4772
+ "(CONCEPT) Hip thrust / \u8170\u30d8\u30b3\u30fb\u30c1\u30f3\u5a9a\u3073\u30c0\u30f3\u30b9",
4773
+ "https://civitai.com/models/869186",
4774
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/9a480935-7849-4ebd-8a71-a428cd5b14e1/width=450/35459697.jpeg"
4775
+ ],
4776
  "hennnachoco_face_XL-v1": [
4777
  "looking at viewer,close-up,blurry background",
4778
  "SDXL 1.0",
 
4871
  "https://civitai.com/models/498731",
4872
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/06a0dc3a-42ba-42b5-9ea9-d6b6faa3543b/width=450/14812284.jpeg"
4873
  ],
4874
+ "hotarueye_xl_tareme1_v10": [
4875
+ "",
4876
+ "Pony",
4877
+ "[SDXL] Tareme(\u30bf\u30ec\u76ee) set 1",
4878
+ "https://civitai.com/models/881360",
4879
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/5c1447f9-fd31-4907-833d-a2e21b4eb2fe/width=450/36138850.jpeg"
4880
+ ],
4881
+ "hotarueye_xl_tareme2_v10": [
4882
+ "",
4883
+ "Pony",
4884
+ "[SDXL] Tareme(\u30bf\u30ec\u76ee) set 1",
4885
+ "https://civitai.com/models/881360",
4886
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/c432f738-1d46-4a74-b8df-b1a2d5113c88/width=450/36138998.jpeg"
4887
+ ],
4888
+ "hotarueye_xl_tareme3_v10": [
4889
+ "",
4890
+ "Pony",
4891
+ "[SDXL] Tareme(\u30bf\u30ec\u76ee) set 1",
4892
+ "https://civitai.com/models/881360",
4893
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/8fb96219-49ba-42d0-a21e-064ab8795b76/width=450/36139352.jpeg"
4894
+ ],
4895
+ "hotarueye_xl_tareme4_v10": [
4896
+ "",
4897
+ "Pony",
4898
+ "[SDXL] Tareme(\u30bf\u30ec\u76ee) set 1",
4899
+ "https://civitai.com/models/881360",
4900
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/202efac0-15b4-4fa4-9b43-95bff83ab3d4/width=450/36139463.jpeg"
4901
+ ],
4902
+ "hotarueye_xl_tsurime1_v10": [
4903
+ "",
4904
+ "Pony",
4905
+ "[SDXL] Tsurime(\u540a\u308a\u76ee) set 1",
4906
+ "https://civitai.com/models/881323",
4907
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b071a8a7-5b3a-447b-ac3d-fb4ca00ef696/width=450/36137296.jpeg"
4908
+ ],
4909
+ "hotarueye_xl_tsurime2_v10": [
4910
+ "",
4911
+ "Pony",
4912
+ "[SDXL] Tsurime(\u540a\u308a\u76ee) set 1",
4913
+ "https://civitai.com/models/881323",
4914
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/597d6089-ceba-492a-bdf1-b99dfd50f6fb/width=450/36137387.jpeg"
4915
+ ],
4916
+ "hotarueye_xl_tsurime3_v10": [
4917
+ "",
4918
+ "Pony",
4919
+ "[SDXL] Tsurime(\u540a\u308a\u76ee) set 1",
4920
+ "https://civitai.com/models/881323",
4921
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/2881d878-991f-46b6-b622-c8e8f07614dc/width=450/36137559.jpeg"
4922
+ ],
4923
+ "hotarueye_xl_tsurime4_v10": [
4924
+ "",
4925
+ "Pony",
4926
+ "[SDXL] Tsurime(\u540a\u308a\u76ee) set 1",
4927
+ "https://civitai.com/models/881323",
4928
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/cd106f42-92fe-4b8b-92cb-918ed9dbfdd2/width=450/36137786.jpeg"
4929
+ ],
4930
  "hotpants_XL_V1_0": [
4931
  "hotpants",
4932
  "SDXL 1.0",
 
4983
  "https://civitai.com/models/363398",
4984
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e8f31f60-8949-42da-b740-c6541e0d6d9b/width=450/8398353.jpeg"
4985
  ],
4986
+ "imminent_penetration_illustrious_V1_0": [
4987
+ "imminent penetration, penis, blush, 1boy, erection,speead legs",
4988
+ "Illustrious",
4989
+ "\u633f\u5165\u524d/ imminent penetration",
4990
+ "https://civitai.com/models/856070",
4991
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/51e16b51-8225-41ab-a951-dd3e459def6b/width=450/36030387.jpeg"
4992
+ ],
4993
+ "imminent_penetration_pony_V1_0": [
4994
+ " imminent penetration,penis",
4995
+ "Pony",
4996
+ "\u633f\u5165\u524d/ imminent penetration",
4997
+ "https://civitai.com/models/856070",
4998
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/61c8e398-0d48-4dac-ae4d-d29c77b87457/width=450/34669225.jpeg"
4999
+ ],
5000
  "implied_fellatio_v0_1-pony": [
5001
  "implied fellatio",
5002
  "Pony",
 
5102
  "https://civitai.com/models/445063",
5103
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/9555de99-1fba-4af8-9cb2-f03f7ae6e094/width=450/32416800.jpeg"
5104
  ],
5105
+ "jyojifuku_XL_illustrious_V1_0": [
5106
+ " jyojifuku, print clothes, pastel color clothes,shirt, skirt, thighhighs,backpack",
5107
+ "Illustrious",
5108
+ "\u5973\u5150\u670d/girl's clothes(XL,Pony)",
5109
+ "https://civitai.com/models/445063",
5110
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/cc797a2d-28f4-467d-9021-7379616e1ea1/width=450/35071752.jpeg"
5111
+ ],
5112
+ "jyojifuku_pony_V2_1": [
5113
+ " jyojifuku, print clothes,pastel color clothes, shirt, skirt, thighhighs / panties / socks / backpack / shoes",
5114
+ "Pony",
5115
+ "\u5973\u5150\u670d/girl's clothes(XL,Pony)",
5116
+ "https://civitai.com/models/445063",
5117
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4d912b6a-5390-4451-b837-dac74009a0a5/width=450/32545900.jpeg"
5118
+ ],
5119
  "jyojimizugi_Pony_V1_0": [
5120
  "jyojimizugi,bikini,frills",
5121
  "Pony",
 
5151
  "https://civitai.com/models/234887",
5152
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4d94a5a1-b7d2-40b7-b864-f112b26e09a7/width=450/4642510.jpeg"
5153
  ],
5154
+ "kakefuton_pony_V1": [
5155
+ " futon, pillow, closed eyes, bed, sleeping, lying, under covers, blanket, ",
5156
+ "Pony",
5157
+ "\u639b\u3051\u5e03\u56e3 / comforter PONY",
5158
+ "https://civitai.com/models/884844",
5159
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e74e1575-7eb1-41a7-8e8e-0371361904f7/width=450/36347575.jpeg"
5160
+ ],
5161
  "kakigoori_pony_V1_0": [
5162
  "kakigoori / shaved ice / spoon",
5163
  "Pony",
 
5305
  "https://civitai.com/models/574993",
5306
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e6148d75-f33f-4f56-8203-4d88a48231e2/width=450/21439541.jpeg"
5307
  ],
5308
+ "kuro_gyaru_XL_illustrious_V1_0": [
5309
+ "kuro gyaru, dark skin, blonde hair",
5310
+ "Illustrious",
5311
+ "\u9ed2\u30ae\u30e3\u30eb/Black Gal(XL,pony)",
5312
+ "https://civitai.com/models/574993",
5313
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4cb23d9a-ae9b-4b4a-9066-c94c23f7180c/width=450/35412051.jpeg"
5314
+ ],
5315
  "kuro_gyaru_pony_V1_0": [
5316
  "kuro gyaru / dark skin / blonde hair",
5317
  "Pony",
 
5662
  "https://civitai.com/models/549761",
5663
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/5059fb4e-8cb0-4870-babe-2e62d93ec592/width=450/18112025.jpeg"
5664
  ],
5665
+ "mating_press_illustrious_V1_0": [
5666
+ "mating press, penis, sex, 1boy, ass, vaginal, testicles,anus, lying,cum",
5667
+ "Illustrious",
5668
+ "\u7a2e\u4ed8\u3051\u30d7\u30ec\u30b9/mating press",
5669
+ "https://civitai.com/models/866324",
5670
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/5295fcb9-8f85-4ce7-af66-c14357e55014/width=450/36296038.jpeg"
5671
+ ],
5672
  "matsubamuzushi_pony_V1_0": [
5673
  "matsubakuzushi, sex, leg lift, leg up, 1boy, 1girl,lying",
5674
  "Pony",
 
5977
  "https://civitai.com/models/551712",
5978
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/b17f1a24-390b-4a5c-a4a1-bc479b627177/width=450/18108188.jpeg"
5979
  ],
5980
+ "ohogao_XL_illustrious_V1_0": [
5981
+ "ohogao",
5982
+ "Illustrious",
5983
+ "\u304a\u307b\u9854/ohogao",
5984
+ "https://civitai.com/models/870999",
5985
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/62037f5d-ec33-4cd7-a4e7-d731df042c13/width=450/35536765.jpeg"
5986
+ ],
5987
  "ojou-sama_pose__pony": [
5988
  "ojou-sama_pose ",
5989
  "Pony",
 
6061
  "https://civitai.com/models/503381",
6062
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d376245b-d55f-4635-8a68-c7317268f1e9/width=450/15093929.jpeg"
6063
  ],
6064
+ "onedari_illustrious_V1_0": [
6065
+ "onedari,spread ass",
6066
+ "Illustrious",
6067
+ "\u304a\u306d\u3060\u308a\u306e\u30dd\u30fc\u30b9/spread ass",
6068
+ "https://civitai.com/models/823132",
6069
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e30a145a-6408-4fbc-a4e3-b44a2f2b55cc/width=450/36044323.jpeg"
6070
+ ],
6071
+ "onedari_pony_V1_0": [
6072
+ " onedari, ass,spread ass",
6073
+ "Pony",
6074
+ "\u304a\u306d\u3060\u308a\u306e\u30dd\u30fc\u30b9/spread ass",
6075
+ "https://civitai.com/models/823132",
6076
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d9a4f767-9a70-4828-a418-0eeabe52d378/width=450/32736802.jpeg"
6077
+ ],
6078
  "onimai_pony": [
6079
  "onimai",
6080
  "Pony",
 
6173
  "https://civitai.com/models/454066",
6174
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d73c20b4-a1bb-4c9d-88ba-150be2e49cb9/width=450/14888108.jpeg"
6175
  ],
6176
+ "paleface_xl_v10": [
6177
+ "",
6178
+ "Pony",
6179
+ "[SDXL] Paled face / \u9752\u3056\u3081\u305f\u9854",
6180
+ "https://civitai.com/models/884477",
6181
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/1c789f11-fade-4f80-a282-0d29ebdbc271/width=450/36325889.jpeg"
6182
+ ],
6183
  "panties_aside_XL_V1_0": [
6184
  "panties / panties aside / pussy / anal",
6185
  "SDXL 1.0",
 
6376
  "https://civitai.com/models/159333",
6377
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4b04073f-f9c0-446a-9a2b-b8a818cf96f8/width=450/9737393.jpeg"
6378
  ],
6379
+ "playing_with_own_hair_XL_illustrious_V1_0": [
6380
+ " playing with own hair",
6381
+ "Illustrious",
6382
+ "\u9aea\u3044\u3058\u308a/playing with own hair",
6383
+ "https://civitai.com/models/869504",
6384
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/7deb7e3b-7fbe-4616-b973-87b58cdb562e/width=450/35502284.jpeg"
6385
+ ],
6386
  "pointing_a31-3": [
6387
  "pointing, chibi, fang, open mouth,",
6388
  "SDXL 1.0",
 
6775
  "https://civitai.com/models/473507",
6776
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e0e9a011-421e-4d30-afaa-eb113ed9653c/width=450/13448210.jpeg"
6777
  ],
6778
+ "rei_no_kabe_pony_V2": [
6779
+ "reinokabe, checkered wall, checkered background, english text, blue theme, meme,",
6780
+ "Pony",
6781
+ "\u4f8b\u306e\u58c1 rei no kabe PONY",
6782
+ "https://civitai.com/models/473507",
6783
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/ef4388c1-c6a1-49b5-8e12-230fd963ec6c/width=450/35420263.jpeg"
6784
+ ],
6785
  "rei_no_pool_PONY_V1": [
6786
  "reinopool, pool, window, scenery, indoors, tiles, water, tile floor, pool ladder, plant",
6787
  "Pony",
 
7048
  "https://civitai.com/models/600296",
7049
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/3ac9e35e-3e3f-492e-a81f-9791ff6e6914/width=450/21281952.jpeg"
7050
  ],
7051
+ "sex_from_behind_XL_illustrious_V1_0": [
7052
+ " sex from behind, 1boy, vaginal, penis",
7053
+ "Illustrious",
7054
+ "\u30d0\u30c3\u30af\u30bb\u30c3\u30af\u30b9/sex from behind(XL,pony)",
7055
+ "https://civitai.com/models/868502",
7056
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/bae209c8-bf57-4c55-b0b1-46c046040b7a/width=450/35562464.jpeg"
7057
+ ],
7058
+ "sex_from_behind_pony_V1_0": [
7059
+ "sex from behind",
7060
+ "Pony",
7061
+ "\u30d0\u30c3\u30af\u30bb\u30c3\u30af\u30b9/sex from behind(XL,pony)",
7062
+ "https://civitai.com/models/868502",
7063
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a1f8b538-c071-44fb-b54b-6094de0999cf/width=450/35389190.jpeg"
7064
+ ],
7065
  "sfw1": [
7066
  "",
7067
  "Pony",
 
7139
  "https://civitai.com/models/102603",
7140
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/ce030fc2-c6c8-4153-ae51-5fa6fbc51b8e/width=450/20563893.jpeg"
7141
  ],
7142
+ "side_ponytail_pony_V1_0": [
7143
+ "side ponytail",
7144
+ "Pony",
7145
+ "\u30b5\u30a4\u30c9\u30dd\u30cb\u30fc\u30c6\u30a4\u30eb/side ponytail",
7146
+ "https://civitai.com/models/867848",
7147
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/c6588028-00de-47e4-96cf-bd4c562af36c/width=450/35345790.jpeg"
7148
+ ],
7149
  "sidepositionxl16": [
7150
  "side,scenery,part of landscape",
7151
  "SDXL 1.0",
 
7244
  "https://civitai.com/models/552152",
7245
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/9ee78490-d6c5-45c1-a1a0-92cb965faa10/width=450/18135129.jpeg"
7246
  ],
7247
+ "sob_XL_illustrious_V1_0": [
7248
+ "sob,tears,hands on eyes",
7249
+ "Illustrious",
7250
+ "\u6ce3\u304d\u3058\u3083\u304f\u308b/sob",
7251
+ "https://civitai.com/models/871126",
7252
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/70ff31df-699e-4e9a-821e-d50b962a3a93/width=450/35544209.jpeg"
7253
+ ],
7254
  "soccer_uniform_pony_V1_1": [
7255
  "soccer uniform / soccer",
7256
  "Pony",
 
7356
  "https://civitai.com/models/273357",
7357
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d529909d-2115-4e32-8226-28537d5b1763/width=450/8178754.jpeg"
7358
  ],
7359
+ "ss_mss_illustrious": [
7360
+ "ss_mss, miniature_school_swimsuit, groin, highleg, partially visible vulva, wedgie, undersized clothes, nipples, cleavage,",
7361
+ "Illustrious",
7362
+ "Miniature School Swimsuit",
7363
+ "https://civitai.com/models/575540",
7364
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/0552741b-1fca-4960-a483-75dacc8404d7/width=450/35919632.jpeg"
7365
+ ],
7366
  "ss_mss_pony-000005": [
7367
  "ss_mss, miniature_school_swimsuit, groin, highleg, partially visible vulva, wedgie, undersized clothes, nipples, cleavage",
7368
  "Pony",
 
7377
  "https://civitai.com/models/434763",
7378
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/1434e8b5-0aa1-46b4-a366-fc5271a922a3/width=450/12693104.jpeg"
7379
  ],
7380
+ "stirring_Pony_v1": [
7381
+ "stirring",
7382
+ "Pony",
7383
+ "[SDXL&Pony] stirring / \u934b\u304b\u304d\u6df7\u305c",
7384
+ "https://civitai.com/models/863366",
7385
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/995b7ed1-f3c2-47b7-babd-524d2aec81b7/width=450/35858737.jpeg"
7386
+ ],
7387
+ "stirring_XL_v1": [
7388
+ "stirring",
7389
+ "Illustrious",
7390
+ "[SDXL&Pony] stirring / \u934b\u304b\u304d\u6df7\u305c",
7391
+ "https://civitai.com/models/863366",
7392
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/31072869-41b7-4efd-b34a-8573ba7e92d5/width=450/35074986.jpeg"
7393
+ ],
7394
  "stradding_chair_XL": [
7395
  "",
7396
  "SDXL 1.0",
 
7482
  "https://civitai.com/models/461839",
7483
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/f1f48385-5230-4eab-ba2a-080c1bb2af1a/width=450/13712411.jpeg"
7484
  ],
7485
+ "sukumizu_XL_illustrious_V1_0": [
7486
+ "school swimsuit / one-piece swimsuit / white one-piece swimsuit",
7487
+ "Illustrious",
7488
+ "\u30b9\u30af\u6c34/school swimsuit(XL,pony)",
7489
+ "https://civitai.com/models/461839",
7490
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/718d3dca-83b7-405d-8758-1ff7aaa2926f/width=450/35041111.jpeg"
7491
+ ],
7492
  "sukumizutan_XL_v1": [
7493
  "sukumizutan, tanlines, tan",
7494
  "SDXL 1.0",
 
7923
  "https://civitai.com/models/563723",
7924
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/1cdf9e3a-9412-4a37-aea6-01524c61f4ce/width=450/18879048.jpeg"
7925
  ],
7926
+ "ultra_rise": [
7927
+ "ultra rise,tokusatsu,full body,from above,",
7928
+ "Pony",
7929
+ "Ultraman Rising \u3050\u3093\u3050\u3093\u30ab\u30c3\u30c8",
7930
+ "https://civitai.com/models/876021",
7931
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e0da72af-c5c1-4d40-8142-d5bcf89da2b3/width=450/35960405.jpeg"
7932
+ ],
7933
  "under_the_table_blowjob": [
7934
  "under_the_table_blowjob",
7935
  "Pony",
 
8385
  "https://civitai.com/models/454664",
8386
  "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/e81c4662-b60a-4169-a30b-31753f93c7e7/width=450/15517389.jpeg"
8387
  ],
8388
+ "yudedako_xl_type1_v10": [
8389
+ "",
8390
+ "Pony",
8391
+ "[SDXL] Embarrased face / \u8d64\u9762\uff08\u8339\u3067\u30c0\u30b3\u9854\uff09",
8392
+ "https://civitai.com/models/884440",
8393
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/18a0fc9c-00ae-4a1d-a65c-cd0b344f5395/width=450/36323502.jpeg"
8394
+ ],
8395
+ "yudedako_xl_type2_v10": [
8396
+ "",
8397
+ "Pony",
8398
+ "[SDXL] Embarrased face / \u8d64\u9762\uff08\u8339\u3067\u30c0\u30b3\u9854\uff09",
8399
+ "https://civitai.com/models/884440",
8400
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d5178802-d2ef-4274-8910-4376fb1239ef/width=450/36323833.jpeg"
8401
+ ],
8402
+ "yudedako_xl_type3_v10": [
8403
+ "",
8404
+ "Pony",
8405
+ "[SDXL] Embarrased face / \u8d64\u9762\uff08\u8339\u3067\u30c0\u30b3\u9854\uff09",
8406
+ "https://civitai.com/models/884440",
8407
+ "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a9825ad3-e3fa-4590-9143-ec6f35b25ade/width=450/36323941.jpeg"
8408
+ ],
8409
  "yukata_pony_V1_0": [
8410
  " jyojifuku, yukata, japanese clothes, floral print,hair ornament,sandals",
8411
  "Pony",
modutils.py CHANGED
@@ -12,11 +12,16 @@ from urllib3.util import Retry
12
  import urllib.parse
13
  import pandas as pd
14
  from huggingface_hub import HfApi, HfFolder, hf_hub_download, snapshot_download
 
 
 
 
 
15
 
16
 
17
  from env import (HF_LORA_PRIVATE_REPOS1, HF_LORA_PRIVATE_REPOS2,
18
  HF_MODEL_USER_EX, HF_MODEL_USER_LIKES, DIFFUSERS_FORMAT_LORAS,
19
- directory_loras, hf_read_token, HF_TOKEN, CIVITAI_API_KEY)
20
 
21
 
22
  MODEL_TYPE_DICT = {
@@ -46,7 +51,6 @@ def is_repo_name(s):
46
  return re.fullmatch(r'^[^/]+?/[^/]+?$', s)
47
 
48
 
49
- from translatepy import Translator
50
  translator = Translator()
51
  def translate_to_en(input: str):
52
  try:
@@ -64,6 +68,7 @@ def get_local_model_list(dir_path):
64
  if file.suffix in valid_extensions:
65
  file_path = str(Path(f"{dir_path}/{file.name}"))
66
  model_list.append(file_path)
 
67
  return model_list
68
 
69
 
@@ -98,21 +103,81 @@ def split_hf_url(url: str):
98
  print(e)
99
 
100
 
101
- def download_hf_file(directory, url, progress=gr.Progress(track_tqdm=True)):
102
- hf_token = get_token()
103
  repo_id, filename, subfolder, repo_type = split_hf_url(url)
 
 
 
104
  try:
105
- print(f"Downloading {url} to {directory}")
106
- if subfolder is not None: path = hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder, repo_type=repo_type, local_dir=directory, token=hf_token)
107
- else: path = hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type, local_dir=directory, token=hf_token)
108
  return path
109
  except Exception as e:
110
- print(f"Failed to download: {e}")
111
  return None
112
 
113
 
114
- def download_things(directory, url, hf_token="", civitai_api_key=""):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  url = url.strip()
 
 
116
  if "drive.google.com" in url:
117
  original_dir = os.getcwd()
118
  os.chdir(directory)
@@ -123,18 +188,48 @@ def download_things(directory, url, hf_token="", civitai_api_key=""):
123
  # url = urllib.parse.quote(url, safe=':/') # fix encoding
124
  if "/blob/" in url:
125
  url = url.replace("/blob/", "/resolve/")
126
- download_hf_file(directory, url)
 
 
 
 
 
 
127
  elif "civitai.com" in url:
128
- if "?" in url:
129
- url = url.split("?")[0]
130
- if civitai_api_key:
131
- url = url + f"?token={civitai_api_key}"
132
- os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
133
- else:
134
  print("\033[91mYou need an API key to download Civitai models.\033[0m")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  else:
136
  os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
137
 
 
 
138
 
139
  def get_download_file(temp_dir, url, civitai_key="", progress=gr.Progress(track_tqdm=True)):
140
  if not "http" in url and is_repo_name(url) and not Path(url).exists():
@@ -173,7 +268,7 @@ def to_lora_key(path: str):
173
 
174
  def to_lora_path(key: str):
175
  if Path(key).is_file(): return key
176
- path = Path(f"{directory_loras}/{escape_lora_basename(key)}.safetensors")
177
  return str(path)
178
 
179
 
@@ -203,25 +298,24 @@ def save_images(images: list[Image.Image], metadatas: list[str]):
203
  raise Exception(f"Failed to save image file:") from e
204
 
205
 
206
- def save_gallery_images(images, progress=gr.Progress(track_tqdm=True)):
207
- from datetime import datetime, timezone, timedelta
208
  progress(0, desc="Updating gallery...")
209
- dt_now = datetime.now(timezone(timedelta(hours=9)))
210
- basename = dt_now.strftime('%Y%m%d_%H%M%S_')
211
- i = 1
212
- if not images: return images, gr.update(visible=False)
 
213
  output_images = []
214
  output_paths = []
215
- for image in images:
216
- filename = basename + str(i) + ".png"
217
- i += 1
218
  oldpath = Path(image[0])
219
  newpath = oldpath
220
  try:
221
  if oldpath.exists():
222
  newpath = oldpath.resolve().rename(Path(filename).resolve())
223
  except Exception as e:
224
- print(e)
225
  finally:
226
  output_paths.append(str(newpath))
227
  output_images.append((str(newpath), str(filename)))
@@ -229,10 +323,39 @@ def save_gallery_images(images, progress=gr.Progress(track_tqdm=True)):
229
  return gr.update(value=output_images), gr.update(value=output_paths, visible=True)
230
 
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  def download_private_repo(repo_id, dir_path, is_replace):
233
- if not hf_read_token: return
234
  try:
235
- snapshot_download(repo_id=repo_id, local_dir=dir_path, allow_patterns=['*.ckpt', '*.pt', '*.pth', '*.safetensors', '*.bin'], use_auth_token=hf_read_token)
236
  except Exception as e:
237
  print(f"Error: Failed to download {repo_id}.")
238
  print(e)
@@ -250,9 +373,9 @@ private_model_path_repo_dict = {} # {"local filepath": "huggingface repo_id", ..
250
  def get_private_model_list(repo_id, dir_path):
251
  global private_model_path_repo_dict
252
  api = HfApi()
253
- if not hf_read_token: return []
254
  try:
255
- files = api.list_repo_files(repo_id, token=hf_read_token)
256
  except Exception as e:
257
  print(f"Error: Failed to list {repo_id}.")
258
  print(e)
@@ -270,11 +393,11 @@ def get_private_model_list(repo_id, dir_path):
270
  def download_private_file(repo_id, path, is_replace):
271
  file = Path(path)
272
  newpath = Path(f'{file.parent.name}/{escape_lora_basename(file.stem)}{file.suffix}') if is_replace else file
273
- if not hf_read_token or newpath.exists(): return
274
  filename = file.name
275
  dirname = file.parent.name
276
  try:
277
- hf_hub_download(repo_id=repo_id, filename=filename, local_dir=dirname, use_auth_token=hf_read_token)
278
  except Exception as e:
279
  print(f"Error: Failed to download {filename}.")
280
  print(e)
@@ -404,9 +527,9 @@ def get_private_lora_model_lists():
404
  models1 = []
405
  models2 = []
406
  for repo in HF_LORA_PRIVATE_REPOS1:
407
- models1.extend(get_private_model_list(repo, directory_loras))
408
  for repo in HF_LORA_PRIVATE_REPOS2:
409
- models2.extend(get_private_model_list(repo, directory_loras))
410
  models = list_uniq(models1 + sorted(models2))
411
  private_lora_model_list = models.copy()
412
  return models
@@ -451,7 +574,7 @@ def get_civitai_info(path):
451
 
452
 
453
  def get_lora_model_list():
454
- loras = list_uniq(get_private_lora_model_lists() + get_local_model_list(directory_loras) + DIFFUSERS_FORMAT_LORAS)
455
  loras.insert(0, "None")
456
  loras.insert(0, "")
457
  return loras
@@ -503,14 +626,14 @@ def update_lora_dict(path):
503
  def download_lora(dl_urls: str):
504
  global loras_url_to_path_dict
505
  dl_path = ""
506
- before = get_local_model_list(directory_loras)
507
  urls = []
508
  for url in [url.strip() for url in dl_urls.split(',')]:
509
- local_path = f"{directory_loras}/{url.split('/')[-1]}"
510
  if not Path(local_path).exists():
511
- download_things(directory_loras, url, HF_TOKEN, CIVITAI_API_KEY)
512
  urls.append(url)
513
- after = get_local_model_list(directory_loras)
514
  new_files = list_sub(after, before)
515
  i = 0
516
  for file in new_files:
@@ -761,12 +884,14 @@ def update_loras(prompt, prompt_syntax, lora1, lora1_wt, lora2, lora2_wt, lora3,
761
  gr.update(value=tag5, label=label5, visible=on5), gr.update(visible=on5), gr.update(value=md5, visible=on5)
762
 
763
 
764
- def get_my_lora(link_url):
765
- before = get_local_model_list(directory_loras)
 
 
766
  for url in [url.strip() for url in link_url.split(',')]:
767
- if not Path(f"{directory_loras}/{url.split('/')[-1]}").exists():
768
- download_things(directory_loras, url, HF_TOKEN, CIVITAI_API_KEY)
769
- after = get_local_model_list(directory_loras)
770
  new_files = list_sub(after, before)
771
  for file in new_files:
772
  path = Path(file)
@@ -774,11 +899,16 @@ def get_my_lora(link_url):
774
  new_path = Path(f'{path.parent.name}/{escape_lora_basename(path.stem)}{path.suffix}')
775
  path.resolve().rename(new_path.resolve())
776
  update_lora_dict(str(new_path))
 
777
  new_lora_model_list = get_lora_model_list()
778
  new_lora_tupled_list = get_all_lora_tupled_list()
779
-
 
 
 
 
780
  return gr.update(
781
- choices=new_lora_tupled_list, value=new_lora_model_list[-1]
782
  ), gr.update(
783
  choices=new_lora_tupled_list
784
  ), gr.update(
@@ -787,6 +917,8 @@ def get_my_lora(link_url):
787
  choices=new_lora_tupled_list
788
  ), gr.update(
789
  choices=new_lora_tupled_list
 
 
790
  )
791
 
792
 
@@ -794,12 +926,12 @@ def upload_file_lora(files, progress=gr.Progress(track_tqdm=True)):
794
  progress(0, desc="Uploading...")
795
  file_paths = [file.name for file in files]
796
  progress(1, desc="Uploaded.")
797
- return gr.update(value=file_paths, visible=True), gr.update(visible=True)
798
 
799
 
800
  def move_file_lora(filepaths):
801
  for file in filepaths:
802
- path = Path(shutil.move(Path(file).resolve(), Path(f"./{directory_loras}").resolve()))
803
  newpath = Path(f'{path.parent.name}/{escape_lora_basename(path.stem)}{path.suffix}')
804
  path.resolve().rename(newpath.resolve())
805
  update_lora_dict(str(newpath))
@@ -941,7 +1073,7 @@ def update_civitai_selection(evt: gr.SelectData):
941
  selected = civitai_last_choices[selected_index][1]
942
  return gr.update(value=selected)
943
  except Exception:
944
- return gr.update(visible=True)
945
 
946
 
947
  def select_civitai_lora(search_result):
@@ -1425,3 +1557,78 @@ def get_model_pipeline(repo_id: str):
1425
  else:
1426
  return default
1427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  import urllib.parse
13
  import pandas as pd
14
  from huggingface_hub import HfApi, HfFolder, hf_hub_download, snapshot_download
15
+ from translatepy import Translator
16
+ from unidecode import unidecode
17
+ import copy
18
+ from datetime import datetime, timezone, timedelta
19
+ FILENAME_TIMEZONE = timezone(timedelta(hours=9)) # JST
20
 
21
 
22
  from env import (HF_LORA_PRIVATE_REPOS1, HF_LORA_PRIVATE_REPOS2,
23
  HF_MODEL_USER_EX, HF_MODEL_USER_LIKES, DIFFUSERS_FORMAT_LORAS,
24
+ DIRECTORY_LORAS, HF_READ_TOKEN, HF_TOKEN, CIVITAI_API_KEY)
25
 
26
 
27
  MODEL_TYPE_DICT = {
 
51
  return re.fullmatch(r'^[^/]+?/[^/]+?$', s)
52
 
53
 
 
54
  translator = Translator()
55
  def translate_to_en(input: str):
56
  try:
 
68
  if file.suffix in valid_extensions:
69
  file_path = str(Path(f"{dir_path}/{file.name}"))
70
  model_list.append(file_path)
71
+ #print('\033[34mFILE: ' + file_path + '\033[0m')
72
  return model_list
73
 
74
 
 
103
  print(e)
104
 
105
 
106
+ def download_hf_file(directory, url, force_filename="", hf_token="", progress=gr.Progress(track_tqdm=True)):
 
107
  repo_id, filename, subfolder, repo_type = split_hf_url(url)
108
+ kwargs = {}
109
+ if subfolder is not None: kwargs["subfolder"] = subfolder
110
+ if force_filename: kwargs["force_filename"] = force_filename
111
  try:
112
+ print(f"Start downloading: {url} to {directory}")
113
+ path = hf_hub_download(repo_id=repo_id, filename=filename, repo_type=repo_type, local_dir=directory, token=hf_token, **kwargs)
 
114
  return path
115
  except Exception as e:
116
+ print(f"Download failed: {url} {e}")
117
  return None
118
 
119
 
120
+ USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0'
121
+
122
+
123
+ def request_json_data(url):
124
+ model_version_id = url.split('/')[-1]
125
+ if "?modelVersionId=" in model_version_id:
126
+ match = re.search(r'modelVersionId=(\d+)', url)
127
+ model_version_id = match.group(1)
128
+
129
+ endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_version_id}"
130
+
131
+ params = {}
132
+ headers = {'User-Agent': USER_AGENT, 'content-type': 'application/json'}
133
+ session = requests.Session()
134
+ retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
135
+ session.mount("https://", HTTPAdapter(max_retries=retries))
136
+
137
+ try:
138
+ result = session.get(endpoint_url, params=params, headers=headers, stream=True, timeout=(3.0, 15))
139
+ result.raise_for_status()
140
+ json_data = result.json()
141
+ return json_data if json_data else None
142
+ except Exception as e:
143
+ print(f"Error: {e}")
144
+ return None
145
+
146
+
147
+ class ModelInformation:
148
+ def __init__(self, json_data):
149
+ self.model_version_id = json_data.get("id", "")
150
+ self.model_id = json_data.get("modelId", "")
151
+ self.download_url = json_data.get("downloadUrl", "")
152
+ self.model_url = f"https://civitai.com/models/{self.model_id}?modelVersionId={self.model_version_id}"
153
+ self.filename_url = next(
154
+ (v.get("name", "") for v in json_data.get("files", []) if str(self.model_version_id) in v.get("downloadUrl", "")), ""
155
+ )
156
+ self.filename_url = self.filename_url if self.filename_url else ""
157
+ self.description = json_data.get("description", "")
158
+ if self.description is None: self.description = ""
159
+ self.model_name = json_data.get("model", {}).get("name", "")
160
+ self.model_type = json_data.get("model", {}).get("type", "")
161
+ self.nsfw = json_data.get("model", {}).get("nsfw", False)
162
+ self.poi = json_data.get("model", {}).get("poi", False)
163
+ self.images = [img.get("url", "") for img in json_data.get("images", [])]
164
+ self.example_prompt = json_data.get("trainedWords", [""])[0] if json_data.get("trainedWords") else ""
165
+ self.original_json = copy.deepcopy(json_data)
166
+
167
+
168
+ def retrieve_model_info(url):
169
+ json_data = request_json_data(url)
170
+ if not json_data:
171
+ return None
172
+ model_descriptor = ModelInformation(json_data)
173
+ return model_descriptor
174
+
175
+
176
+ def download_things(directory, url, hf_token="", civitai_api_key="", romanize=False):
177
+ hf_token = get_token()
178
  url = url.strip()
179
+ downloaded_file_path = None
180
+
181
  if "drive.google.com" in url:
182
  original_dir = os.getcwd()
183
  os.chdir(directory)
 
188
  # url = urllib.parse.quote(url, safe=':/') # fix encoding
189
  if "/blob/" in url:
190
  url = url.replace("/blob/", "/resolve/")
191
+
192
+ filename = unidecode(url.split('/')[-1]) if romanize else url.split('/')[-1]
193
+
194
+ download_hf_file(directory, url, filename, hf_token)
195
+
196
+ downloaded_file_path = os.path.join(directory, filename)
197
+
198
  elif "civitai.com" in url:
199
+
200
+ if not civitai_api_key:
 
 
 
 
201
  print("\033[91mYou need an API key to download Civitai models.\033[0m")
202
+
203
+ model_profile = retrieve_model_info(url)
204
+ if model_profile.download_url and model_profile.filename_url:
205
+ url = model_profile.download_url
206
+ filename = unidecode(model_profile.filename_url) if romanize else model_profile.filename_url
207
+ else:
208
+ if "?" in url:
209
+ url = url.split("?")[0]
210
+ filename = ""
211
+
212
+ url_dl = url + f"?token={civitai_api_key}"
213
+ print(f"Filename: {filename}")
214
+
215
+ param_filename = ""
216
+ if filename:
217
+ param_filename = f"-o '{filename}'"
218
+
219
+ aria2_command = (
220
+ f'aria2c --console-log-level=error --summary-interval=10 -c -x 16 '
221
+ f'-k 1M -s 16 -d "{directory}" {param_filename} "{url_dl}"'
222
+ )
223
+ os.system(aria2_command)
224
+
225
+ if param_filename and os.path.exists(os.path.join(directory, filename)):
226
+ downloaded_file_path = os.path.join(directory, filename)
227
+
228
  else:
229
  os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
230
 
231
+ return downloaded_file_path
232
+
233
 
234
  def get_download_file(temp_dir, url, civitai_key="", progress=gr.Progress(track_tqdm=True)):
235
  if not "http" in url and is_repo_name(url) and not Path(url).exists():
 
268
 
269
  def to_lora_path(key: str):
270
  if Path(key).is_file(): return key
271
+ path = Path(f"{DIRECTORY_LORAS}/{escape_lora_basename(key)}.safetensors")
272
  return str(path)
273
 
274
 
 
298
  raise Exception(f"Failed to save image file:") from e
299
 
300
 
301
+ def save_gallery_images(images, model_name="", progress=gr.Progress(track_tqdm=True)):
 
302
  progress(0, desc="Updating gallery...")
303
+ #dt_now = datetime.now(timezone(timedelta(hours=9)))
304
+ #dt_now = datetime.now(FILENAME_TIMEZONE)
305
+ #basename = dt_now.strftime('%Y%m%d_%H%M%S_')
306
+ basename = f"{model_name.split('/')[-1]}_{datetime.now(FILENAME_TIMEZONE).strftime('%Y%m%d_%H%M%S')}_"
307
+ if not images: return images, gr.update()
308
  output_images = []
309
  output_paths = []
310
+ for i, image in enumerate(images):
311
+ filename = f"{basename}{str(i + 1)}.png"
 
312
  oldpath = Path(image[0])
313
  newpath = oldpath
314
  try:
315
  if oldpath.exists():
316
  newpath = oldpath.resolve().rename(Path(filename).resolve())
317
  except Exception as e:
318
+ print(e)
319
  finally:
320
  output_paths.append(str(newpath))
321
  output_images.append((str(newpath), str(filename)))
 
323
  return gr.update(value=output_images), gr.update(value=output_paths, visible=True)
324
 
325
 
326
+ def save_gallery_history(images, files, history_gallery, history_files, progress=gr.Progress(track_tqdm=True)):
327
+ if not images or not files: return gr.update(), gr.update()
328
+ if not history_gallery: history_gallery = []
329
+ if not history_files: history_files = []
330
+ output_gallery = images + history_gallery
331
+ output_files = files + history_files
332
+ return gr.update(value=output_gallery), gr.update(value=output_files, visible=True)
333
+
334
+
335
+ def save_image_history(image: str, gallery, files, model_name: str, progress=gr.Progress(track_tqdm=True)):
336
+ basename = f"{model_name.split('/')[-1]}_{datetime.now(FILENAME_TIMEZONE).strftime('%Y%m%d_%H%M%S')}"
337
+ if not image: return gr.update(), gr.update()
338
+ if not gallery: gallery = []
339
+ if not files: files = []
340
+ filename = f"{basename}.png"
341
+ oldpath = Path(image)
342
+ newpath = oldpath
343
+ try:
344
+ if newpath != oldpath and oldpath.exists():
345
+ shutil.copy(oldpath.resolve(), Path(filename).resolve())
346
+ newpath = Path(filename).resolve()
347
+ except Exception as e:
348
+ print(e)
349
+ finally:
350
+ files.isnert(0, str(newpath))
351
+ gallery.insert(0, (str(newpath), str(filename)))
352
+ return gr.update(value=gallery), gr.update(value=files, visible=True)
353
+
354
+
355
  def download_private_repo(repo_id, dir_path, is_replace):
356
+ if not HF_READ_TOKEN: return
357
  try:
358
+ snapshot_download(repo_id=repo_id, local_dir=dir_path, allow_patterns=['*.ckpt', '*.pt', '*.pth', '*.safetensors', '*.bin'], token=HF_READ_TOKEN)
359
  except Exception as e:
360
  print(f"Error: Failed to download {repo_id}.")
361
  print(e)
 
373
  def get_private_model_list(repo_id, dir_path):
374
  global private_model_path_repo_dict
375
  api = HfApi()
376
+ if not HF_READ_TOKEN: return []
377
  try:
378
+ files = api.list_repo_files(repo_id, token=HF_READ_TOKEN)
379
  except Exception as e:
380
  print(f"Error: Failed to list {repo_id}.")
381
  print(e)
 
393
  def download_private_file(repo_id, path, is_replace):
394
  file = Path(path)
395
  newpath = Path(f'{file.parent.name}/{escape_lora_basename(file.stem)}{file.suffix}') if is_replace else file
396
+ if not HF_READ_TOKEN or newpath.exists(): return
397
  filename = file.name
398
  dirname = file.parent.name
399
  try:
400
+ hf_hub_download(repo_id=repo_id, filename=filename, local_dir=dirname, token=HF_READ_TOKEN)
401
  except Exception as e:
402
  print(f"Error: Failed to download {filename}.")
403
  print(e)
 
527
  models1 = []
528
  models2 = []
529
  for repo in HF_LORA_PRIVATE_REPOS1:
530
+ models1.extend(get_private_model_list(repo, DIRECTORY_LORAS))
531
  for repo in HF_LORA_PRIVATE_REPOS2:
532
+ models2.extend(get_private_model_list(repo, DIRECTORY_LORAS))
533
  models = list_uniq(models1 + sorted(models2))
534
  private_lora_model_list = models.copy()
535
  return models
 
574
 
575
 
576
  def get_lora_model_list():
577
+ loras = list_uniq(get_private_lora_model_lists() + DIFFUSERS_FORMAT_LORAS + get_local_model_list(DIRECTORY_LORAS))
578
  loras.insert(0, "None")
579
  loras.insert(0, "")
580
  return loras
 
626
  def download_lora(dl_urls: str):
627
  global loras_url_to_path_dict
628
  dl_path = ""
629
+ before = get_local_model_list(DIRECTORY_LORAS)
630
  urls = []
631
  for url in [url.strip() for url in dl_urls.split(',')]:
632
+ local_path = f"{DIRECTORY_LORAS}/{url.split('/')[-1]}"
633
  if not Path(local_path).exists():
634
+ download_things(DIRECTORY_LORAS, url, HF_TOKEN, CIVITAI_API_KEY)
635
  urls.append(url)
636
+ after = get_local_model_list(DIRECTORY_LORAS)
637
  new_files = list_sub(after, before)
638
  i = 0
639
  for file in new_files:
 
884
  gr.update(value=tag5, label=label5, visible=on5), gr.update(visible=on5), gr.update(value=md5, visible=on5)
885
 
886
 
887
+ def get_my_lora(link_url, romanize):
888
+ l_name = ""
889
+ l_path = ""
890
+ before = get_local_model_list(DIRECTORY_LORAS)
891
  for url in [url.strip() for url in link_url.split(',')]:
892
+ if not Path(f"{DIRECTORY_LORAS}/{url.split('/')[-1]}").exists():
893
+ l_name = download_things(DIRECTORY_LORAS, url, HF_TOKEN, CIVITAI_API_KEY, romanize)
894
+ after = get_local_model_list(DIRECTORY_LORAS)
895
  new_files = list_sub(after, before)
896
  for file in new_files:
897
  path = Path(file)
 
899
  new_path = Path(f'{path.parent.name}/{escape_lora_basename(path.stem)}{path.suffix}')
900
  path.resolve().rename(new_path.resolve())
901
  update_lora_dict(str(new_path))
902
+ l_path = str(new_path)
903
  new_lora_model_list = get_lora_model_list()
904
  new_lora_tupled_list = get_all_lora_tupled_list()
905
+ msg_lora = "Downloaded"
906
+ if l_name:
907
+ msg_lora += f": <b>{l_name}</b>"
908
+ print(msg_lora)
909
+
910
  return gr.update(
911
+ choices=new_lora_tupled_list, value=l_path
912
  ), gr.update(
913
  choices=new_lora_tupled_list
914
  ), gr.update(
 
917
  choices=new_lora_tupled_list
918
  ), gr.update(
919
  choices=new_lora_tupled_list
920
+ ), gr.update(
921
+ value=msg_lora
922
  )
923
 
924
 
 
926
  progress(0, desc="Uploading...")
927
  file_paths = [file.name for file in files]
928
  progress(1, desc="Uploaded.")
929
+ return gr.update(value=file_paths, visible=True), gr.update()
930
 
931
 
932
  def move_file_lora(filepaths):
933
  for file in filepaths:
934
+ path = Path(shutil.move(Path(file).resolve(), Path(f"./{DIRECTORY_LORAS}").resolve()))
935
  newpath = Path(f'{path.parent.name}/{escape_lora_basename(path.stem)}{path.suffix}')
936
  path.resolve().rename(newpath.resolve())
937
  update_lora_dict(str(newpath))
 
1073
  selected = civitai_last_choices[selected_index][1]
1074
  return gr.update(value=selected)
1075
  except Exception:
1076
+ return gr.update()
1077
 
1078
 
1079
  def select_civitai_lora(search_result):
 
1557
  else:
1558
  return default
1559
 
1560
+
1561
+ EXAMPLES_GUI = [
1562
+ [
1563
+ "1girl, souryuu asuka langley, neon genesis evangelion, plugsuit, pilot suit, red bodysuit, sitting, crossing legs, black eye patch, cat hat, throne, symmetrical, looking down, from bottom, looking at viewer, outdoors, masterpiece, best quality, very aesthetic, absurdres",
1564
+ "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]",
1565
+ 1,
1566
+ 30,
1567
+ 7.5,
1568
+ True,
1569
+ -1,
1570
+ "Euler a",
1571
+ 1152,
1572
+ 896,
1573
+ "votepurchase/animagine-xl-3.1",
1574
+ ],
1575
+ [
1576
+ "solo, princess Zelda OOT, score_9, score_8_up, score_8, medium breasts, cute, eyelashes, cute small face, long hair, crown braid, hairclip, pointy ears, soft curvy body, looking at viewer, smile, blush, white dress, medium body, (((holding the Master Sword))), standing, deep forest in the background",
1577
+ "score_6, score_5, score_4, busty, ugly face, mutated hands, low res, blurry face, black and white,",
1578
+ 1,
1579
+ 30,
1580
+ 5.,
1581
+ True,
1582
+ -1,
1583
+ "Euler a",
1584
+ 1024,
1585
+ 1024,
1586
+ "votepurchase/ponyDiffusionV6XL",
1587
+ ],
1588
+ [
1589
+ "1girl, oomuro sakurako, yuru yuri, official art, school uniform, anime artwork, anime style, vibrant, studio anime, highly detailed, masterpiece, best quality, very aesthetic, absurdres",
1590
+ "photo, deformed, black and white, realism, disfigured, low contrast, 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]",
1591
+ 1,
1592
+ 40,
1593
+ 7.0,
1594
+ True,
1595
+ -1,
1596
+ "Euler a",
1597
+ 1024,
1598
+ 1024,
1599
+ "Raelina/Rae-Diffusion-XL-V2",
1600
+ ],
1601
+ [
1602
+ "1girl, akaza akari, yuru yuri, official art, anime artwork, anime style, vibrant, studio anime, highly detailed, masterpiece, best quality, very aesthetic, absurdres",
1603
+ "photo, deformed, black and white, realism, disfigured, low contrast, 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]",
1604
+ 1,
1605
+ 35,
1606
+ 7.0,
1607
+ True,
1608
+ -1,
1609
+ "Euler a",
1610
+ 1024,
1611
+ 1024,
1612
+ "Raelina/Raemu-XL-V4",
1613
+ ],
1614
+ [
1615
+ "yoshida yuuko, machikado mazoku, 1girl, solo, demon horns,horns, school uniform, long hair, open mouth, skirt, demon girl, ahoge, shiny, shiny hair, anime artwork",
1616
+ "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]",
1617
+ 1,
1618
+ 50,
1619
+ 7.,
1620
+ True,
1621
+ -1,
1622
+ "Euler a",
1623
+ 1024,
1624
+ 1024,
1625
+ "cagliostrolab/animagine-xl-3.1",
1626
+ ],
1627
+ ]
1628
+
1629
+
1630
+ RESOURCES = (
1631
+ """### Resources
1632
+ - You can also try the image generator in Colab’s free tier, which provides free GPU [link](https://github.com/R3gm/SD_diffusers_interactive).
1633
+ """
1634
+ )
requirements.txt CHANGED
@@ -1,6 +1,5 @@
1
  spaces
2
  accelerate
3
- spaces>=0.30.3
4
  diffusers
5
  invisible_watermark
6
  transformers
@@ -21,4 +20,5 @@ dartrs
21
  translatepy
22
  timm
23
  wrapt-timeout-decorator
24
- sentencepiece
 
 
1
  spaces
2
  accelerate
 
3
  diffusers
4
  invisible_watermark
5
  transformers
 
20
  translatepy
21
  timm
22
  wrapt-timeout-decorator
23
+ sentencepiece
24
+ unidecode
utils.py ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import gradio as gr
4
+ from constants import (
5
+ DIFFUSERS_FORMAT_LORAS,
6
+ CIVITAI_API_KEY,
7
+ HF_TOKEN,
8
+ MODEL_TYPE_CLASS,
9
+ DIRECTORY_LORAS,
10
+ )
11
+ from huggingface_hub import HfApi
12
+ from diffusers import DiffusionPipeline
13
+ from huggingface_hub import model_info as model_info_data
14
+ from diffusers.pipelines.pipeline_loading_utils import variant_compatible_siblings
15
+ from pathlib import PosixPath
16
+ from unidecode import unidecode
17
+ import urllib.parse
18
+ import copy
19
+ import requests
20
+ from requests.adapters import HTTPAdapter
21
+ from urllib3.util import Retry
22
+
23
+ USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0'
24
+
25
+
26
+ def request_json_data(url):
27
+ model_version_id = url.split('/')[-1]
28
+ if "?modelVersionId=" in model_version_id:
29
+ match = re.search(r'modelVersionId=(\d+)', url)
30
+ model_version_id = match.group(1)
31
+
32
+ endpoint_url = f"https://civitai.com/api/v1/model-versions/{model_version_id}"
33
+
34
+ params = {}
35
+ headers = {'User-Agent': USER_AGENT, 'content-type': 'application/json'}
36
+ session = requests.Session()
37
+ retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
38
+ session.mount("https://", HTTPAdapter(max_retries=retries))
39
+
40
+ try:
41
+ result = session.get(endpoint_url, params=params, headers=headers, stream=True, timeout=(3.0, 15))
42
+ result.raise_for_status()
43
+ json_data = result.json()
44
+ return json_data if json_data else None
45
+ except Exception as e:
46
+ print(f"Error: {e}")
47
+ return None
48
+
49
+
50
+ class ModelInformation:
51
+ def __init__(self, json_data):
52
+ self.model_version_id = json_data.get("id", "")
53
+ self.model_id = json_data.get("modelId", "")
54
+ self.download_url = json_data.get("downloadUrl", "")
55
+ self.model_url = f"https://civitai.com/models/{self.model_id}?modelVersionId={self.model_version_id}"
56
+ self.filename_url = next(
57
+ (v.get("name", "") for v in json_data.get("files", []) if str(self.model_version_id) in v.get("downloadUrl", "")), ""
58
+ )
59
+ self.filename_url = self.filename_url if self.filename_url else ""
60
+ self.description = json_data.get("description", "")
61
+ if self.description is None: self.description = ""
62
+ self.model_name = json_data.get("model", {}).get("name", "")
63
+ self.model_type = json_data.get("model", {}).get("type", "")
64
+ self.nsfw = json_data.get("model", {}).get("nsfw", False)
65
+ self.poi = json_data.get("model", {}).get("poi", False)
66
+ self.images = [img.get("url", "") for img in json_data.get("images", [])]
67
+ self.example_prompt = json_data.get("trainedWords", [""])[0] if json_data.get("trainedWords") else ""
68
+ self.original_json = copy.deepcopy(json_data)
69
+
70
+
71
+ def retrieve_model_info(url):
72
+ json_data = request_json_data(url)
73
+ if not json_data:
74
+ return None
75
+ model_descriptor = ModelInformation(json_data)
76
+ return model_descriptor
77
+
78
+
79
+ def download_things(directory, url, hf_token="", civitai_api_key="", romanize=False):
80
+ url = url.strip()
81
+ downloaded_file_path = None
82
+
83
+ if "drive.google.com" in url:
84
+ original_dir = os.getcwd()
85
+ os.chdir(directory)
86
+ os.system(f"gdown --fuzzy {url}")
87
+ os.chdir(original_dir)
88
+ elif "huggingface.co" in url:
89
+ url = url.replace("?download=true", "")
90
+ # url = urllib.parse.quote(url, safe=':/') # fix encoding
91
+ if "/blob/" in url:
92
+ url = url.replace("/blob/", "/resolve/")
93
+ user_header = f'"Authorization: Bearer {hf_token}"'
94
+
95
+ filename = unidecode(url.split('/')[-1]) if romanize else url.split('/')[-1]
96
+
97
+ if hf_token:
98
+ os.system(f"aria2c --console-log-level=error --summary-interval=10 --header={user_header} -c -x 16 -k 1M -s 16 {url} -d {directory} -o {filename}")
99
+ else:
100
+ os.system(f"aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 {url} -d {directory} -o {filename}")
101
+
102
+ downloaded_file_path = os.path.join(directory, filename)
103
+
104
+ elif "civitai.com" in url:
105
+
106
+ if not civitai_api_key:
107
+ print("\033[91mYou need an API key to download Civitai models.\033[0m")
108
+
109
+ model_profile = retrieve_model_info(url)
110
+ if model_profile.download_url and model_profile.filename_url:
111
+ url = model_profile.download_url
112
+ filename = unidecode(model_profile.filename_url) if romanize else model_profile.filename_url
113
+ else:
114
+ if "?" in url:
115
+ url = url.split("?")[0]
116
+ filename = ""
117
+
118
+ url_dl = url + f"?token={civitai_api_key}"
119
+ print(f"Filename: {filename}")
120
+
121
+ param_filename = ""
122
+ if filename:
123
+ param_filename = f"-o '{filename}'"
124
+
125
+ aria2_command = (
126
+ f'aria2c --console-log-level=error --summary-interval=10 -c -x 16 '
127
+ f'-k 1M -s 16 -d "{directory}" {param_filename} "{url_dl}"'
128
+ )
129
+ os.system(aria2_command)
130
+
131
+ if param_filename and os.path.exists(os.path.join(directory, filename)):
132
+ downloaded_file_path = os.path.join(directory, filename)
133
+
134
+ # # PLAN B
135
+ # # Follow the redirect to get the actual download URL
136
+ # curl_command = (
137
+ # f'curl -L -sI --connect-timeout 5 --max-time 5 '
138
+ # f'-H "Content-Type: application/json" '
139
+ # f'-H "Authorization: Bearer {civitai_api_key}" "{url}"'
140
+ # )
141
+
142
+ # headers = os.popen(curl_command).read()
143
+
144
+ # # Look for the redirected "Location" URL
145
+ # location_match = re.search(r'location: (.+)', headers, re.IGNORECASE)
146
+
147
+ # if location_match:
148
+ # redirect_url = location_match.group(1).strip()
149
+
150
+ # # Extract the filename from the redirect URL's "Content-Disposition"
151
+ # filename_match = re.search(r'filename%3D%22(.+?)%22', redirect_url)
152
+ # if filename_match:
153
+ # encoded_filename = filename_match.group(1)
154
+ # # Decode the URL-encoded filename
155
+ # decoded_filename = urllib.parse.unquote(encoded_filename)
156
+
157
+ # filename = unidecode(decoded_filename) if romanize else decoded_filename
158
+ # print(f"Filename: {filename}")
159
+
160
+ # aria2_command = (
161
+ # f'aria2c --console-log-level=error --summary-interval=10 -c -x 16 '
162
+ # f'-k 1M -s 16 -d "{directory}" -o "{filename}" "{redirect_url}"'
163
+ # )
164
+ # return_code = os.system(aria2_command)
165
+
166
+ # # if return_code != 0:
167
+ # # raise RuntimeError(f"Failed to download file: {filename}. Error code: {return_code}")
168
+ # downloaded_file_path = os.path.join(directory, filename)
169
+ # if not os.path.exists(downloaded_file_path):
170
+ # downloaded_file_path = None
171
+
172
+ # if not downloaded_file_path:
173
+ # # Old method
174
+ # if "?" in url:
175
+ # url = url.split("?")[0]
176
+ # url = url + f"?token={civitai_api_key}"
177
+ # os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
178
+
179
+ else:
180
+ os.system(f"aria2c --console-log-level=error --summary-interval=10 -c -x 16 -k 1M -s 16 -d {directory} {url}")
181
+
182
+ return downloaded_file_path
183
+
184
+
185
+ def get_model_list(directory_path):
186
+ model_list = []
187
+ valid_extensions = {'.ckpt', '.pt', '.pth', '.safetensors', '.bin'}
188
+
189
+ for filename in os.listdir(directory_path):
190
+ if os.path.splitext(filename)[1] in valid_extensions:
191
+ # name_without_extension = os.path.splitext(filename)[0]
192
+ file_path = os.path.join(directory_path, filename)
193
+ # model_list.append((name_without_extension, file_path))
194
+ model_list.append(file_path)
195
+ print('\033[34mFILE: ' + file_path + '\033[0m')
196
+ return model_list
197
+
198
+
199
+ def extract_parameters(input_string):
200
+ parameters = {}
201
+ input_string = input_string.replace("\n", "")
202
+
203
+ if "Negative prompt:" not in input_string:
204
+ if "Steps:" in input_string:
205
+ input_string = input_string.replace("Steps:", "Negative prompt: Steps:")
206
+ else:
207
+ print("Invalid metadata")
208
+ parameters["prompt"] = input_string
209
+ return parameters
210
+
211
+ parm = input_string.split("Negative prompt:")
212
+ parameters["prompt"] = parm[0].strip()
213
+ if "Steps:" not in parm[1]:
214
+ print("Steps not detected")
215
+ parameters["neg_prompt"] = parm[1].strip()
216
+ return parameters
217
+ parm = parm[1].split("Steps:")
218
+ parameters["neg_prompt"] = parm[0].strip()
219
+ input_string = "Steps:" + parm[1]
220
+
221
+ # Extracting Steps
222
+ steps_match = re.search(r'Steps: (\d+)', input_string)
223
+ if steps_match:
224
+ parameters['Steps'] = int(steps_match.group(1))
225
+
226
+ # Extracting Size
227
+ size_match = re.search(r'Size: (\d+x\d+)', input_string)
228
+ if size_match:
229
+ parameters['Size'] = size_match.group(1)
230
+ width, height = map(int, parameters['Size'].split('x'))
231
+ parameters['width'] = width
232
+ parameters['height'] = height
233
+
234
+ # Extracting other parameters
235
+ other_parameters = re.findall(r'(\w+): (.*?)(?=, \w+|$)', input_string)
236
+ for param in other_parameters:
237
+ parameters[param[0]] = param[1].strip('"')
238
+
239
+ return parameters
240
+
241
+
242
+ def get_my_lora(link_url, romanize):
243
+ l_name = ""
244
+ for url in [url.strip() for url in link_url.split(',')]:
245
+ if not os.path.exists(f"./loras/{url.split('/')[-1]}"):
246
+ l_name = download_things(DIRECTORY_LORAS, url, HF_TOKEN, CIVITAI_API_KEY, romanize)
247
+ new_lora_model_list = get_model_list(DIRECTORY_LORAS)
248
+ new_lora_model_list.insert(0, "None")
249
+ new_lora_model_list = new_lora_model_list + DIFFUSERS_FORMAT_LORAS
250
+ msg_lora = "Downloaded"
251
+ if l_name:
252
+ msg_lora += f": <b>{l_name}</b>"
253
+ print(msg_lora)
254
+
255
+ return gr.update(
256
+ choices=new_lora_model_list
257
+ ), gr.update(
258
+ choices=new_lora_model_list
259
+ ), gr.update(
260
+ choices=new_lora_model_list
261
+ ), gr.update(
262
+ choices=new_lora_model_list
263
+ ), gr.update(
264
+ choices=new_lora_model_list
265
+ ), gr.update(
266
+ value=msg_lora
267
+ )
268
+
269
+
270
+ def info_html(json_data, title, subtitle):
271
+ return f"""
272
+ <div style='padding: 0; border-radius: 10px;'>
273
+ <p style='margin: 0; font-weight: bold;'>{title}</p>
274
+ <details>
275
+ <summary>Details</summary>
276
+ <p style='margin: 0; font-weight: bold;'>{subtitle}</p>
277
+ </details>
278
+ </div>
279
+ """
280
+
281
+
282
+ def get_model_type(repo_id: str):
283
+ api = HfApi(token=os.environ.get("HF_TOKEN")) # if use private or gated model
284
+ default = "SD 1.5"
285
+ try:
286
+ model = api.model_info(repo_id=repo_id, timeout=5.0)
287
+ tags = model.tags
288
+ for tag in tags:
289
+ if tag in MODEL_TYPE_CLASS.keys(): return MODEL_TYPE_CLASS.get(tag, default)
290
+ except Exception:
291
+ return default
292
+ return default
293
+
294
+
295
+ def restart_space(repo_id: str, factory_reboot: bool):
296
+ api = HfApi(token=os.environ.get("HF_TOKEN"))
297
+ try:
298
+ runtime = api.get_space_runtime(repo_id=repo_id)
299
+ if runtime.stage == "RUNNING":
300
+ api.restart_space(repo_id=repo_id, factory_reboot=factory_reboot)
301
+ print(f"Restarting space: {repo_id}")
302
+ else:
303
+ print(f"Space {repo_id} is in stage: {runtime.stage}")
304
+ except Exception as e:
305
+ print(e)
306
+
307
+
308
+ def extract_exif_data(image):
309
+ if image is None: return ""
310
+
311
+ try:
312
+ metadata_keys = ['parameters', 'metadata', 'prompt', 'Comment']
313
+
314
+ for key in metadata_keys:
315
+ if key in image.info:
316
+ return image.info[key]
317
+
318
+ return str(image.info)
319
+
320
+ except Exception as e:
321
+ return f"Error extracting metadata: {str(e)}"
322
+
323
+
324
+ def create_mask_now(img, invert):
325
+ import numpy as np
326
+ import time
327
+
328
+ time.sleep(0.5)
329
+
330
+ transparent_image = img["layers"][0]
331
+
332
+ # Extract the alpha channel
333
+ alpha_channel = np.array(transparent_image)[:, :, 3]
334
+
335
+ # Create a binary mask by thresholding the alpha channel
336
+ binary_mask = alpha_channel > 1
337
+
338
+ if invert:
339
+ print("Invert")
340
+ # Invert the binary mask so that the drawn shape is white and the rest is black
341
+ binary_mask = np.invert(binary_mask)
342
+
343
+ # Convert the binary mask to a 3-channel RGB mask
344
+ rgb_mask = np.stack((binary_mask,) * 3, axis=-1)
345
+
346
+ # Convert the mask to uint8
347
+ rgb_mask = rgb_mask.astype(np.uint8) * 255
348
+
349
+ return img["background"], rgb_mask
350
+
351
+
352
+ def download_diffuser_repo(repo_name: str, model_type: str, revision: str = "main", token=True):
353
+
354
+ variant = None
355
+ if token is True and not os.environ.get("HF_TOKEN"):
356
+ token = None
357
+
358
+ if model_type == "SDXL":
359
+ info = model_info_data(
360
+ repo_name,
361
+ token=token,
362
+ revision=revision,
363
+ timeout=5.0,
364
+ )
365
+
366
+ filenames = {sibling.rfilename for sibling in info.siblings}
367
+ model_filenames, variant_filenames = variant_compatible_siblings(
368
+ filenames, variant="fp16"
369
+ )
370
+
371
+ if len(variant_filenames):
372
+ variant = "fp16"
373
+
374
+ cached_folder = DiffusionPipeline.download(
375
+ pretrained_model_name=repo_name,
376
+ force_download=False,
377
+ token=token,
378
+ revision=revision,
379
+ # mirror="https://hf-mirror.com",
380
+ variant=variant,
381
+ use_safetensors=True,
382
+ trust_remote_code=False,
383
+ timeout=5.0,
384
+ )
385
+
386
+ if isinstance(cached_folder, PosixPath):
387
+ cached_folder = cached_folder.as_posix()
388
+
389
+ # Task model
390
+ # from huggingface_hub import hf_hub_download
391
+ # hf_hub_download(
392
+ # task_model,
393
+ # filename="diffusion_pytorch_model.safetensors", # fix fp16 variant
394
+ # )
395
+
396
+ return cached_folder
397
+
398
+
399
+ def progress_step_bar(step, total):
400
+ # Calculate the percentage for the progress bar width
401
+ percentage = min(100, ((step / total) * 100))
402
+
403
+ return f"""
404
+ <div style="position: relative; width: 100%; background-color: gray; border-radius: 5px; overflow: hidden;">
405
+ <div style="width: {percentage}%; height: 17px; background-color: #800080; transition: width 0.5s;"></div>
406
+ <div style="position: absolute; width: 100%; text-align: center; color: white; top: 0; line-height: 19px; font-size: 13px;">
407
+ {int(percentage)}%
408
+ </div>
409
+ </div>
410
+ """
411
+
412
+
413
+ def html_template_message(msg):
414
+ return f"""
415
+ <div style="position: relative; width: 100%; background-color: gray; border-radius: 5px; overflow: hidden;">
416
+ <div style="width: 0%; height: 17px; background-color: #800080; transition: width 0.5s;"></div>
417
+ <div style="position: absolute; width: 100%; text-align: center; color: white; top: 0; line-height: 19px; font-size: 14px; font-weight: bold; text-shadow: 1px 1px 2px black;">
418
+ {msg}
419
+ </div>
420
+ </div>
421
+ """