DemiPoto commited on
Commit
375f1f1
1 Parent(s): 9027be6

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +13 -12
  2. all_models.py +129 -531
  3. externalmod.py +584 -0
README.md CHANGED
@@ -1,13 +1,14 @@
1
- ---
2
- title: TestDifs
3
- emoji: 🛕🛕
4
- colorFrom: green
5
- colorTo: blue
6
- sdk: gradio
7
- sdk_version: 3.46.0
8
- app_file: app3.py
9
- pinned: true
10
- short_description: TestDifs
11
- ---
12
-
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ---
2
+ title: TestDifs (Gradio 4.x)
3
+ emoji: 🛕🛕
4
+ colorFrom: green
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 4.42.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: DemiPoto/TestDifs
11
+ short_description: TestDifs
12
+ ---
13
+
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
all_models.py CHANGED
@@ -1,532 +1,130 @@
1
- models = [
2
-
3
- "John6666/3x3mix-xl-typed-v1-sdxl",
4
- "John6666/3x3mix-xl-typee-v1-sdxl",
5
- "John6666/3x3mix-xl-typef-v1-sdxl",
6
- "John6666/3x3mix-xl-typeh-v1-sdxl",
7
- "John6666/3x3x3mixxl-v1-sdxl",
8
- "John6666/3x3x3mixxl-v1-sdxl-spo",
9
- "John6666/3x3x3mixxl-v2-sdxl",
10
- "John6666/3x3x3mixxl-v2-sdxl-spo",
11
- "John6666/cutified-anime-character-design-ponyxl-v2-sdxl",
12
- "John6666/kntan-mix-xl-pony-v14-sdxl",
13
- "John6666/kntan-mix-xl-pony-v14-turbo-sdxl",
14
- "John6666/chacol-omega-mix-v11a-sdxl",
15
- "John6666/chacol-omega-mix-v11a-sdxl-spo",
16
- "John6666/deep-dark-hentai-mix-v60-sdxl",
17
- "John6666/deep-dark-hentai-mix-v61hybrid-sdxl",
18
- "John6666/hentai-cinematic-pony-v1-sdxl",
19
- "John6666/hentai-cinematic-pony-v2-sdxl",
20
- "John6666/30104-v1-sdxl",
21
- "John6666/30104-v2-sdxl",
22
- "John6666/30104-v21-sdxl",
23
- "John6666/30104-v30-sdxl",
24
- "John6666/savant-v201-sdxl",
25
- "John6666/no-pony-beta01-v1-sdxl",
26
- "John6666/dreamland-base-28d-pony-v3-sdxl",
27
- "John6666/ioli-pony-mix-v2-sdxl",
28
- "John6666/ioli-pony-mix-v2-sdxl-spo",
29
- "John6666/ioli-pony-mix-v31-sdxl",
30
- "John6666/xl-caulkinum-animeline-gep-sdxl",
31
- "John6666/xl-caulkinum-animeline-gd-sdxl",
32
- "John6666/xlp-caulkinum-animeline-bnd-sdxl",
33
- "John6666/hassaku-xl-hentai-v12-sdxl",
34
- "John6666/hassaku-xl-hentai-v13-sdxl",
35
- "John6666/hassaku-xl-hentai-v13-better-eyes-sdxl",
36
- "John6666/hassaku-xl-hentai-v13-better-eyes-sdxl-spo",
37
- "John6666/authaku-mix-v1-sdxl",
38
- "John6666/authaku-mix-otaku-mix-sdxl",
39
- "John6666/smooth-hassaku-authaku-mix-v1-sdxl",
40
- "John6666/smooth-hassaku-authaku-mix-v2-sdxl",
41
- "John6666/smooth-hassaku-authaku-mix-v3-sdxl",
42
- "John6666/ohara-pdxl-v1-sdxl",
43
- "John6666/ohara-pdxl-v2-sdxl",
44
- "John6666/ohara-pdxl-v3-sdxl",
45
- "John6666/ohara-pdxl-v4-sdxl",
46
- "John6666/animix-v9-xl-sdxl",
47
- "John6666/animix-v9-xl-animetvmix-2nd-sdxl",
48
- "John6666/animix-v9-xl-animetvmix-v25-sdxl",
49
- "John6666/magical-pony-2-sdxl",
50
- "John6666/magical-pony-3-sdxl",
51
- "John6666/orphic-1-sdxl",
52
- "John6666/orphic-2-sdxl",
53
- "John6666/orphic-3-sdxl",
54
- "John6666/orphic-0-sdxl",
55
- "John6666/god-pony-v2-sdxl",
56
- "John6666/god-pony-v21-sdxl",
57
- "John6666/wai-ani-hentai-pony-v1-sdxl",
58
- "John6666/wai-ani-hentai-pony-v2-sdxl",
59
- "John6666/wai-ani-hentai-pony-v3-sdxl",
60
- "John6666/wai-ani-hentai-pony-v4-sdxl",
61
- "John6666/wai-ani-nsfw-ponyxl-v5-sdxl",
62
- "John6666/wai-ani-nsfw-ponyxl-v6-sdxl",
63
- "John6666/wai-ani-nsfw-ponyxl-v7-sdxl",
64
- "John6666/wai-celluloid-style-v1-sdxl",
65
- "John6666/wai-celluloid-style-v2-sdxl",
66
- "John6666/wai-c-v3-sdxl",
67
- "John6666/wai-c-v4-sdxl",
68
- "John6666/wai-c-v5-sdxl",
69
- "John6666/hadrian-delice-xl-styled-stylea-v10d-sdxl",
70
- "John6666/hadrian-delice-xl-styled-stylea-v11h-sdxl",
71
- "John6666/hadrian-delice-xl-styled-stylea-v12d-sdxl",
72
- "John6666/hadrian-delice-xl-v20l-sdxl",
73
- "John6666/hadrian-delice-xl-v25e-sdxl",
74
- "John6666/hadrian-delice-xl-v26j-sdxl",
75
- "John6666/hadrian-delice-xl-v27v1-sdxl",
76
- "John6666/mala-kawaii-pony-xl-v1-sdxl",
77
- "John6666/mala-smooth-v1-sdxl",
78
- "John6666/mala-smooth-v2-sdxl",
79
- "John6666/mala-anime-mix-nsfw-pony-xl-v3-sdxl",
80
- "John6666/mala-anime-mix-nsfw-pony-xl-v4-sdxl",
81
- "John6666/mala-anime-mix-nsfw-pony-xl-v5-sdxl",
82
- "John6666/mala-anime-mix-nsfw-pony-xl-v5-sdxl-spo",
83
- "John6666/mala-anime-mix-nsfw-pony-xl-v5new-sdxl",
84
- "John6666/mala-anime-mix-nsfw-pony-xl-v5new-sdxl-spo",
85
- "John6666/mala-anime-mix-nsfw-pony-xl-v6-sdxl",
86
- "John6666/mala-anime-mix-nsfw-pony-xl-v6-sdxl-spo-pcm",
87
- "John6666/mala-anime-mix-nsfw-pony-xl-v6-sdxl-spo-hyper",
88
- "John6666/jupiter-2dnpony-v1-sdxl",
89
- "John6666/cranberry-xl-v3-sdxl",
90
- "John6666/pinky-promise-pony-v1-sdxl",
91
- "John6666/stable-pony-v1-sdxl",
92
- "John6666/accretion-disc-xl-v1-sdxl",
93
- "John6666/pys-gallery-anime-v24-sdxl",
94
- "John6666/tsuki-v2-sdxl",
95
- "John6666/tsuki-v35-sdxl",
96
- "John6666/osorubeshi-ultra-anime-v1-sdxl",
97
- "John6666/bunny-mint-sdxl",
98
- "John6666/bunny-mint-v3-ns-sdxl",
99
- "John6666/grimoire-p0239-sdxl",
100
- "John6666/grimoire-p0666-sdxl",
101
- "John6666/pony-flat-mix-4l30-sdxl",
102
- "John6666/perfect-rsb-mix-multiuse-v61-sdxl",
103
- "John6666/duchaiten-pony-xl-no-score-v5-sdxl",
104
- "John6666/duchaiten-pony-xl-no-score-v51fix-sdxl",
105
- "John6666/duchaiten-pony-xl-no-score-v52-sdxl",
106
- "John6666/satpony-niji-v2-sdxl",
107
- "John6666/meichidark-mix-meichidarkanimxlv1-sdxl",
108
- "John6666/meichidark-mix-reload-meichidarkponreal-sdxl",
109
- "John6666/js-confetti-v2-sdxl",
110
- "John6666/0002-pony-v3-sdxl",
111
- "John6666/0002-pony-v31alt-sdxl",
112
- "John6666/0003-pony-delta-sdxl",
113
- "John6666/0003-pony-epsilon-sdxl",
114
- "John6666/nova-anime-xl-pony-v2-sdxl",
115
- "John6666/nova-anime-xl-pony-v3-sdxl",
116
- "John6666/nova-garden-v1-sdxl",
117
- "John6666/mmxl-v1-sdxl",
118
- "John6666/homemade-pony-v1-sdxl",
119
- "John6666/clamsauce-v2-sdxl",
120
- "John6666/t-ponynai3-v51-sdxl",
121
- "John6666/t-ponynai3-v51wo-sdxl-spo",
122
- "John6666/t-ponynai3-v55-sdxl",
123
- "John6666/t-ponynai3-v55-sdxl-spo",
124
- "John6666/t-ponynai3-v6-sdxl",
125
- "John6666/t-ponynai3-v6-sdxl-bf16",
126
- "John6666/florag-pony-half-xl-sdxl",
127
- "John6666/red-blue-fantasy-pony-sdxl",
128
- "John6666/knk-cieloblend-ponyv6-v1-sdxl",
129
- "John6666/knk-pony-merge-v2-sdxl",
130
- "John6666/obsidian-pdxl-v1-sdxl",
131
- "John6666/penny-diffusion-v1-v1-sdxl",
132
- "John6666/rdxl-anime-sdxlpony7-sdxl",
133
- "John6666/rdxl-anime-sdxlpony8-sdxl",
134
- "John6666/anipony-xl-v23-sdxl",
135
- "John6666/ls-equos-xl-v2-sdxl",
136
- "John6666/prefect-pony-xl-v1-sdxl",
137
- "John6666/prefect-pony-xl-v2-cleaned-style-sdxl",
138
- "John6666/daisyxl-v1-sdxl",
139
- "John6666/rain-pony-xl-rainfall-v2-sdxl",
140
- "John6666/rain-cloud-v1-sdxl",
141
- "John6666/pony-mistlan-mix-pdxl-v1-sdxl",
142
- "John6666/kawaii-Internum-v10-sdxl",
143
- "John6666/base-anime-style-pony-v3-sdxl",
144
- "John6666/boleromix-pony-v14-sdxl",
145
- "John6666/boleromix-pony-v141vae-sdxl",
146
- "John6666/7th-anime-xl-pony-a-v1-sdxl-spo",
147
- "John6666/ytcyponyxl-v1-sdxl",
148
- "John6666/perillanium-ccm-sdxl",
149
- "John6666/perillanium-ccm-sp1-sdxl",
150
- "John6666/perillaniumccm-pony-v1-sdxl",
151
- "John6666/perillanium-seft-sdxl",
152
- "John6666/perillanium-v1-sdxl",
153
- "John6666/perillanium-cem-sdxl",
154
- "John6666/nsfw-cocoa-mix-pony-v1-sdxl",
155
- "John6666/nsfw-cocoa-mix-pony-v2-sdxl",
156
- "John6666/mistoon-xl-copper-v20fast-sdxl",
157
- "John6666/mistoon-anime-ponyalpha-sdxl",
158
- "John6666/catloaf-v1-sdxl",
159
- "John6666/peroperositai-v1-sdxl",
160
- "John6666/white-unicorn-v2-sdxl",
161
- "John6666/white-unicorn-v2-sdxl-spo",
162
- "John6666/white-unicorn-v3-sdxl",
163
- "John6666/white-unicorn-another-sdxl",
164
- "John6666/hamef-kawaii-mix-type2light-sdxl",
165
- "John6666/hamef-kawaii-mix-type24light-warm-sdxl",
166
- "John6666/hamef-kawaii-mix-type24normal-warm-sdxl",
167
- "John6666/hamef-kawaii-mix-type3deep-sdxl",
168
- "John6666/hamef-kawaii-mix-type39deep-sdxl",
169
- "John6666/hamef-kawaii-mix-type45dpo-sdxl",
170
- "John6666/ebara-pony-v1-sdxl",
171
- "John6666/ebara-pony-v1-sdxl-spo",
172
- "John6666/ebara-pony-v21-sdxl-fp32",
173
- "John6666/ebara-mfcg-pony-mix-v11-sdxl",
174
- "John6666/ebara-mfcg-pony-mix-v12-sdxl",
175
- "John6666/momoiro-pony-v14-sdxl",
176
- "John6666/momoiro-pony-v15-sdxl",
177
- "John6666/featureless-mix-pony-v1-sdxl",
178
- "John6666/featureless-mix-pony-v2-sdxl",
179
- "John6666/featureless-mix-pony-v2-sdxl-spo",
180
- "John6666/epona-mix-v3-sdxl",
181
- "John6666/stuffy-mix-v1-sdxl",
182
- "John6666/pony-pencil-sdxl",
183
- "John6666/pony-pencil-xl-v102-sdxl",
184
- "John6666/eva-claus-mix-pony-xl-v1-sdxl",
185
- "John6666/eva-claus-mix-pony-xl-v21-sdxl",
186
- "John6666/better-days-v08-sdxl",
187
- "John6666/better-days-v081-sdxl",
188
- "John6666/pthno2-v1-sdxl",
189
- "John6666/adamah-mix-xl-v15-sdxl",
190
- "John6666/copycat-asc-v1-sdxl",
191
- "John6666/copycat-bg-v1-sdxl",
192
- "John6666/copycat-v2-sdxl",
193
- "John6666/pegasusxx-v35-sdxl",
194
- "John6666/pegasusxx-v383-sdxl",
195
- "John6666/pegasusxx-v40-twilightsky-sdxl",
196
- "John6666/persona-style-checkpoint-pony-xl-sdxl",
197
- "John6666/sol-pony-v2-alt-sdxl",
198
- "John6666/sympony-v1-prelude-sdxl",
199
- "John6666/sympony-v2-fuga-sdxl",
200
- "John6666/sympony-v3-ariette-sdxl",
201
- "John6666/celeste-pony-v1-sdxl",
202
- "John6666/celeste-pony-v2-sdxl",
203
- "John6666/ytpony3860xl-v09-sdxl",
204
- "John6666/ytpony3860xl-v1-sdxl",
205
- "John6666/nxt-next-generation-v1-sdxl",
206
- "John6666/nxt-next-generation-v2-sdxl",
207
- "John6666/pony-diffusion-v6-xl-sdxl-spo",
208
- "John6666/sorkh-pony-v1-sdxl",
209
- "John6666/horny-fox-v2-sdxl",
210
- "John6666/ras-real-anime-screencap-v1-sdxl",
211
- "John6666/hda-matrix-copdxl-v1-sdxl",
212
- "John6666/bamboo-shoot-mix-v1-sdxl",
213
- "John6666/fpl005-sdxl",
214
- "John6666/dissonance-v11-sdxl",
215
- "John6666/boring-cake-v1-sdxl",
216
- "John6666/mikoshi-pony-v1-sdxl",
217
- "John6666/asami-xl-v1-sdxl",
218
- "John6666/unreal-tulip-v1-sdxl",
219
- "John6666/agenda-mix-pdxl-v15-sdxl",
220
- "John6666/satan-pony-v2-sdxl",
221
- "John6666/model-ex-v5-sdxl",
222
- "John6666/hotdog-pony-mix-xl-v4-sdxl",
223
- "John6666/asuma-xl-sdxl",
224
- "John6666/true-anime-style-pony-v2-sdxl",
225
- "John6666/aaaautism-pony-finetune-aaaarestart-sdxl",
226
- "John6666/monster-coffee-celsius-mix-v1-sdxl",
227
- "John6666/koji-pony-mix-v1-sdxl",
228
- "John6666/sweet-mix-xl-v11-sdxl",
229
- "John6666/oceaneyes-pony-merge-v1-sdxl",
230
- "John6666/limestone-yen-ver2-sdxl",
231
- "John6666/yozora-ponyxl-v1-sdxl",
232
- "John6666/darkmix-pony-v1-sdxl",
233
- "John6666/artemix-pony1-sdxl",
234
- "John6666/artemix-pony2-sdxl",
235
- "John6666/rinemix-v10ponyxl-sdxl",
236
- "John6666/reweik-ponyxl-v13-sdxl",
237
- "John6666/thick-coating-style-pdxl10-sdxl",
238
- "John6666/konan-mix-pdxl-v1-sdxl",
239
- "John6666/incursios-meme-diffusion-v27-pdxl-sdxl",
240
- "John6666/satyr-remix-pony-ankara10-sdxl",
241
- "John6666/alisco-mix-v01-v10-sdxl",
242
- "John6666/flyx3-mix-pony-xl-v1-sdxl",
243
- "John6666/new-tail-multiple-artists-v1-sdxl",
244
- "John6666/manmaru-mix-pony-v2-sdxl",
245
- "John6666/jackpot-mix-v1-sdxl",
246
- "John6666/jackpot-mix-v2-sdxl",
247
- "John6666/jackpot-mix-v3-sdxl",
248
- "John6666/kurotsuki-mix-v1-sdxl",
249
- "John6666/seishun-mix-v1-sdxl",
250
- "John6666/2dfish-pony-animemix-v1-sdxl",
251
- "John6666/weakened-brs-pony-v1-sdxl",
252
- "John6666/ecstacy-pony-v19-photoreal-sdxl",
253
- "John6666/izariamergemix-pony-v1-sdxl",
254
- "John6666/izariamergemix-pony-v15-sdxl",
255
- "John6666/ely-pony-xl-v1-sdxl",
256
- "John6666/ely-pony-xl-v15-sdxl",
257
- "John6666/ether-pdxl-a2-sdxl",
258
- "John6666/ether-pdxl-a2b-sdxl",
259
- "John6666/mugen-infinity-xl-v1-sdxl",
260
- "John6666/mugen-infinity-xl-v2-sdxl",
261
- "John6666/mugen-infinity-xl-v3-sdxl",
262
- "John6666/pixiv-pony-epita-mix-v1-sdxl",
263
- "John6666/mocase-mix-v1-sdxl",
264
- "John6666/gusgenm-pony-v1-sdxl",
265
- "John6666/gusgenm-pony-sp1-sdxl",
266
- "John6666/catpony-ani-v1-sdxl",
267
- "John6666/catpony-ani-v2-sdxl",
268
- "John6666/anime-test-pony-v05-2d-sdxl",
269
- "John6666/catrush-v1-sdxl",
270
- "John6666/aios-v101foal-v1100foalii-sdxl",
271
- "John6666/mklan-anime-hentai-nextgen-darkhentai-v1-sdxl",
272
- "John6666/bho-nsfw-mix2-v10-sdxl",
273
- "John6666/perfect-nai-v1-sdxl",
274
- "John6666/pony-nai3-zycc-sdxl",
275
- "John6666/snow4thtailautism-v1-sdxl",
276
- "John6666/evo-merge-sdxlpony20-sdxl",
277
- "John6666/toonystark-korean-webtoon-xl-pony10-sdxl",
278
- "John6666/crucible-ring-v1-sdxl",
279
- "John6666/stardrop-xl-v3-sdxl",
280
- "John6666/hoseki-lustrousmix-pony-v1-sdxl",
281
- "John6666/honey-mix-xl-high-contrast-anime-checkpoint-v1-sdxl",
282
- "John6666/silvermoon-mix-01xl-v10-sdxl",
283
- "John6666/yozora-ponyxl-v1-sdxl",
284
- "John6666/yozora-ponyxl-v2-sdxl",
285
- "John6666/animeliner-ponyxl-v1-sdxl",
286
- "John6666/conrad-xl-v1-sdxl",
287
- "John6666/formulae-one-sdxl",
288
- "John6666/real-simple-anime-v10-sdxl",
289
- "John6666/chaos-pony-starfire-sdxl",
290
- "John6666/miku-factory-xl2-v20-sdxl",
291
- "John6666/atomix-pony-anime-xl-v3-sdxl",
292
- "John6666/ceii-mix-pdxl-v12-sdxl",
293
-
294
-
295
-
296
-
297
-
298
-
299
- "John6666/fluffy-tart-xl-v14-sdxl",
300
- "John6666/fluffy-tart-xl-v15-sdxl",
301
- "John6666/lemontart-v1-sdxl",
302
- "John6666/lemontart-v2-sdxl",
303
- "John6666/cute-candy-mix-pony-sdxl",
304
- "John6666/cute-core-xlb59-sdxl",
305
- "John6666/wai-cute-v2-sdxl",
306
- "John6666/wai-cute-v3-sdxl",
307
- "John6666/wai-cute-v4-sdxl",
308
- "John6666/wai-cute-v5-sdxl",
309
- "John6666/wai-cute-v6-sdxl",
310
- "John6666/jitq-pony-sdxl",
311
-
312
-
313
-
314
-
315
-
316
-
317
-
318
- "John6666/fritillary-xl-v1-sdxl",
319
- "John6666/super-pixelart-xl-m-v1-v10-sdxl",
320
- "John6666/rdxl-pixel-art-pony1-sdxl",
321
- "John6666/pixnite-xl-v10-sdxl",
322
- "John6666/wai-plastic-doll-v1-sdxl",
323
- "John6666/wai-doll-cn-v2-sdxl",
324
- "John6666/wai-doll-cn-v3-sdxl",
325
- "John6666/pvc-style-model-movable-pony-151-sdxl-spo",
326
- "John6666/pvc-style-model-movable-pony-160-sdxl",
327
- "John6666/mist-xl-hyper-character-style-model-sdxl",
328
- "John6666/susamix-pony-v02-v1-sdxl",
329
- "John6666/susamix-pony-v02-v1-sdxl-spo",
330
- "John6666/pickled-pony-mix-v1-sdxl",
331
- "John6666/titania-noah-mix-25d27d-v50-sdxl",
332
- "John6666/duchaiten-gameart-unrealenginev10-sdxl",
333
- "John6666/3d-rendering-style-beta2-sdxl",
334
- "John6666/pegana-merge-v1-sdxl",
335
- "John6666/pegana-merge-v2-sdxl",
336
- "John6666/pegana-merge-v3-sdxl",
337
-
338
-
339
-
340
-
341
-
342
-
343
-
344
-
345
- "John6666/titania-mix-realistic-pony-gbvr10-sdxl",
346
- "John6666/titania-mix-realistic-pony-gbvr20-sdxl",
347
- "John6666/titania-mix-realistic-pony-gbvr30-sdxl",
348
- "John6666/noah-mix-pony-2d25d-v3-sdxl",
349
- "John6666/noah-mix-pony-2d25d-v5-sdxl",
350
- "John6666/raemora-xl-v3-sdxl",
351
- "John6666/lilith-pony-realmix-v1-sdxl",
352
- "John6666/lilith-pony-realmix-v12-sdxl",
353
- "John6666/perfect-rsb-mixl-xl-real-anime-sfw-nsfw-v1-sdxl",
354
- "John6666/perfect-rsb-mix-pony-real-anime-sfw-nsfw-v71-sdxl",
355
- "John6666/perfect-rsb-mix-pony-real-v86-sdxl",
356
- "John6666/serendipity-pdxl-darkfantasy-sdxl",
357
- "John6666/serendipity-pdxl-v2-sdxl",
358
- "John6666/sifw-annihilation-xl-v2-sdxl",
359
- "John6666/knk-soft-shading-v1-sdxl",
360
- "John6666/rdxl-smash-bros-pony1-sdxl",
361
- "John6666/rdxl-smash-bros-pony2-sdxl",
362
- "John6666/uncanny-valley-v2-sdxl",
363
- "John6666/featureless-25d-mix-pony-v1-sdxl",
364
- "John6666/featureless-25d-mix-pony-v2-sdxl",
365
- "John6666/asyncs-mix-pony-pony-v1-sdxl",
366
- "John6666/asyncs-mix-pony-pony-v2-sdxl",
367
- "John6666/anime-test-pony-v31-sdxl",
368
- "John6666/yaminabe-pony-v008-sdxl",
369
-
370
-
371
-
372
-
373
-
374
-
375
-
376
-
377
- "John6666/3x3mix-xl-typeg-v1-sdxl",
378
- "John6666/3x3mix-xl-typej-v1-sdxl",
379
- "John6666/3x3mix-xl-typel-v1-sdxl",
380
- "John6666/3x3x3mixxl-3dv01-sdxl",
381
- "John6666/chacol-semi-real-pony-mix-xl-v1-sdxl",
382
- "John6666/3010xxx-v10c-sdxl",
383
- "John6666/3010xxx-v1-sdxl",
384
- "John6666/3010nc-xx-mixpony-v15-sdxl",
385
- "John6666/3010nc-xx-mixpony-v16-sdxl",
386
- "John6666/3010nc-xx-mixpony-v17-sdxl",
387
- "John6666/3010nc-xx-mixpony-v30-sdxl",
388
- "John6666/3010nc-xx-mixpony-v31-sdxl",
389
- "John6666/3010nc-xx-mixpony-v20-sdxl",
390
- "John6666/3010nc-xx-mixpony-v21-sdxl",
391
- "John6666/3010nc-xx-mixpony-v25-sdxl",
392
- "John6666/3010nc-xx-mixpony-v26-sdxl",
393
- "John6666/pinkiepie-pony-mix-v30beta-sdxl",
394
- "John6666/pinkiepie-pony-mix-v32-sdxl",
395
- "John6666/pinkiepie-pony-mix-v34-sdxl",
396
- "John6666/pinkiepie-pony-mix-v35alt-sdxl",
397
- "John6666/titania-mix-realistic-pony-gbv10-sdxl",
398
- "John6666/titania-mix-realistic-pony-gbv20-sdxl",
399
- "John6666/titania-mix-realistic-pony-gbv30-sdxl",
400
- "John6666/titania-mix-realistic-pony-gbv40-sdxl",
401
- "John6666/titania-mix-realistic-pony-gbv50-sdxl",
402
- "John6666/titania-mix-realistic-pony-gbv60-sdxl",
403
- "John6666/titania-mix-realistic-pony-gbv70-sdxl",
404
- "John6666/titania-mix-realistic-pony-gbv80-sdxl",
405
- "John6666/titania-mix-realistic-pony-gbv90-sdxl",
406
- "John6666/titania-juggernaut-mix-v1-sdxl",
407
- "John6666/pony-asian-realism-alpha-v05-sdxl",
408
- "John6666/asian-orchid-blossom-beauty-and-golden-silk-v1-sdxl",
409
- "John6666/pony-realism-v21main-sdxl",
410
- "John6666/hpony-realism-25d-v20real-sdxl",
411
- "John6666/datass-rev-final-pony-realism-final-sdxl",
412
- "John6666/wai-real-cn-v4-sdxl",
413
- "John6666/wai-real-cn-v5-sdxl",
414
- "John6666/wai-real-cn-v6-sdxl",
415
- "John6666/wai-real-cn-v8-sdxl",
416
- "John6666/wai-real-cn-v9-sdxl",
417
- "John6666/wai-real-mix-v7-sdxl-spo",
418
- "John6666/wai-real-mix-v8-sdxl",
419
- "John6666/wai-real-mix-v8-sdxl-spo",
420
- "John6666/wai-real-mix-v9-sdxl",
421
- "John6666/wai-real-e-v1-sdxl",
422
- "John6666/wai-semireal-v1-sdxl",
423
- "John6666/wai-semireal-v2-sdxl",
424
- "John6666/wai-simpleuse-for-real-pony-v1-sdxl",
425
- "John6666/wai-nature-real-mix-v1-sdxl",
426
- "John6666/wai-10step-hyper-no-score-realistic-pony-xl-v1-sdxl",
427
- "John6666/real-mix-pony-v01-sdxl",
428
- "John6666/real-mix-pony-v2-sdxl",
429
- "John6666/real-mix-pony-v3-sdxl",
430
- "John6666/real-mix-pony-v4-sdxl",
431
- "John6666/real-mix-pony-v5-sdxl",
432
- "John6666/goddess-of-realism-gor-pony-v2art-sdxl",
433
- "John6666/goddess-of-realism-gor-pony-v2artfix-sdxl",
434
- "John6666/vendo-pony-realistic-v12-sdxl",
435
- "John6666/vendo-pony-realistic-v13lora-sdxl",
436
- "John6666/badbro-xl-v3-sdxl",
437
- "John6666/badbro-xl-v5-sdxl",
438
- "John6666/badbro-xl-v8-sdxl",
439
- "John6666/stanleys-triweekend-xxl-v5-stanleys-prancing-pony-sdxl",
440
- "John6666/sevenof9-pony-real-mix-nextgen-sdxl",
441
- "John6666/sevenof9-pony-real-mix-smartevolution-sdxl",
442
- "John6666/sevenof9-pony-real-mix-smartevolution-contrast-sdxl",
443
- "John6666/osorubeshi-pony-real-x-sdxl",
444
- "John6666/osorubeshi-pony-real-v7-sdxl",
445
- "John6666/batch-co-pony-v1-sdxl",
446
- "John6666/getphat-pony-lewdfusion-v1-sdxl",
447
- "John6666/cosplay-serendipity-pny-v2-sdxl",
448
- "John6666/cosplay-serendipity-pny-v3-sdxl",
449
- "John6666/cosplay-serendipity-pny-v4-sdxl",
450
- "John6666/cosplay-serendipity-pny-v5-sdxl",
451
- "John6666/duchaiten-pony-real-alpha7-sdxl",
452
- "John6666/duchaiten-pony-real-beta4-sdxl",
453
- "John6666/duchaiten-pony-real-v1-sdxl",
454
- "John6666/duchaiten-pony-real-v11fix-sdxl",
455
- "John6666/real-dream-sdxlpony9-sdxl",
456
- "John6666/real-dream-sdxlpony10-sdxl",
457
- "John6666/satpony-v3-realism-sdxl",
458
- "John6666/satpony-no-score-v3-sdxl",
459
- "John6666/cyberrealistic-pony-v5-sdxl",
460
- "John6666/cyberrealistic-pony-v6-sdxl",
461
- "John6666/cyberrealistic-pony-v61-sdxl",
462
- "John6666/nova-asian-v1-sdxl",
463
- "John6666/cinero-pony-nsfw-v09a-sdxl",
464
- "John6666/cinero-pony-nsfw-v09d-sdxl",
465
- "John6666/cinero-pony-nsfw-v10-sdxl",
466
- "John6666/cinero-pony-nsfw-v11art-sdxl",
467
- "John6666/indecent-v1-sdxl",
468
- "John6666/pony-photo-real-merge-x3-v2sharper-sdxl",
469
- "John6666/gdp-pony-xl-v11-sdxl",
470
- "John6666/sasaki-pony-sdxl-ponyv01-sdxl",
471
- "John6666/sasaki-pony-sdxl-ponyv05-sdxl",
472
- "John6666/fennfoto-pony-v2-sdxl",
473
- "John6666/fennfoto-pony-v3-sdxl",
474
- "John6666/fennfoto-pony-v4-sdxl",
475
- "John6666/bemypony-photo2-sdxl",
476
- "John6666/bemypony-photo3-sdxl",
477
- "John6666/granfinos-mirage-pony-v1-sdxl",
478
- "John6666/granfinos-mirage-pony-v2-sdxl",
479
- "John6666/ls-equost-real-xl-aev1-sdxl",
480
- "John6666/ls-equostreal-xl-v20-sdxl",
481
- "John6666/only-porn-sdxl-pony-sdxl",
482
- "John6666/kojono-pony-checkpoint-ponyv01-sdxl",
483
- "John6666/real-pony-real-anime-v4-sdxl",
484
- "John6666/real-pony-cutejp-v3-sdxl",
485
- "John6666/photo-realistic-pony-v5-sdxl",
486
- "John6666/eternal-champon-a-v1-sdxl",
487
- "John6666/eternal-champon-a-v2-sdxl",
488
- "John6666/maple-mix-pony-v1-sdxl",
489
- "John6666/jac-nsfw-v2f-sdxl",
490
- "John6666/jib-mix-pony-realistic-v2-sdxl",
491
- "John6666/digital-af-xlp-v1-sdxl",
492
- "John6666/damn-ponyxl-realistic-model-v3-sdxl",
493
- "John6666/bd-pony-real-v01h-sdxl",
494
- "John6666/eros-ultima-realistic-sdxl",
495
- "John6666/stallion-dreams-pony-realistic-v1-sdxl",
496
- "John6666/realpony-dreams-v1-sdxl",
497
- "John6666/speciosa-v12-sdxl",
498
- "John6666/speciosa-25d-v12-sdxl",
499
- "John6666/zonkey-realism-v5-sdxl",
500
- "John6666/godiva-v2-sdxl",
501
- "John6666/godiva-v3-sdxl",
502
- "John6666/pony-photo-real-merge-x3-v1-sdxl",
503
- "John6666/dream-pony-v83-sdxl",
504
- "John6666/mugen-infinity-xl-v31-sdxl",
505
- "John6666/foxai-x-duchaiten-v1-sdxl",
506
- "John6666/satpony-journey-v1-sdxl",
507
- "John6666/satpony-journey-v2-sdxl",
508
- "John6666/goth-chix-mix-v1-sdxl",
509
- "John6666/voluptuous-mix-ponyxl-v11-sdxl",
510
- "John6666/st2-bedamnrealpony-v1-sdxl",
511
- "John6666/dagny-pony-half-xl-sdxl",
512
- "John6666/nostra-realistic-mix-v10-sdxl",
513
- "John6666/final-fantasy-diffusion-alpha-sdxl",
514
- "John6666/pony-forreal-v02-sdxl",
515
- "John6666/one-trick-ponyxl-v10-sdxl",
516
- "John6666/aimz-dream-real-pony-mix-v3-sdxl",
517
-
518
-
519
-
520
-
521
-
522
-
523
-
524
-
525
- "John6666/toketap-v1-sdxl",
526
- "John6666/silkysaido-v1-sdxl",
527
- "John6666/3010xxx-v25d-sdxl",
528
- "John6666/wai-middle-v2-sdxl",
529
- ]
530
 
531
- last = "John6666/titania-mix-realistic-pony-gbvr30-sdxl",
532
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from blacklist import bad_tags,bad_models,fav_models
2
+ models = []
3
+ models_plus_tags=[]
4
+ tags_plus_models=[]
5
+
6
+
7
+ def list_uniq(l):
8
+ return sorted(set(l), key=l.index)
9
+
10
+ def find_model_list(author: str="", tags: list[str]=[], not_tag="", sort: str="last_modified", limit: int=30, force_gpu=False, check_status=False, bad_models=bad_models):
11
+ from huggingface_hub import HfApi
12
+ api = HfApi()
13
+ default_tags = ["diffusers"]
14
+ if not sort: sort = "last_modified"
15
+ models = []
16
+ models_plus_tags=[]
17
+ try:
18
+ model_infos = api.list_models(author=author, task="text-to-image",
19
+ tags=list_uniq(default_tags + tags), cardData=True, sort=sort, limit=limit)
20
+ except Exception as e:
21
+ print(f"Error: Failed to list models.")
22
+ print(e)
23
+ return models
24
+ for model in model_infos:
25
+
26
+ if not model.private and not model.gated:
27
+ loadable = True
28
+ if not_tag and not_tag in model.tags or not loadable: continue
29
+ if model.id not in bad_models :
30
+ models.append(model.id)
31
+ #models_plus_tags.append([model.id,process_tags(model.tags)])
32
+ models_plus_tags.append([model.id,process_tags(model.cardData.tags)])
33
+ if len(models) == limit: break
34
+ return models , models_plus_tags
35
+
36
+ def process_tags(tags,bad_tags=bad_tags):
37
+ t1=True
38
+ new_tags=[]
39
+ for tag in tags:
40
+ if tag not in bad_tags:
41
+ if tag == 'en':
42
+ t1=False
43
+ if t1 :
44
+ new_tags.append(tag)
45
+ return new_tags
46
+
47
+ def clas_tags(models_plus_tags,min):
48
+ tags_plus_models=[]
49
+ listTemp=[]
50
+ listAllModels=['all',0,[]]
51
+ new_tag=True
52
+ for ent in models_plus_tags:
53
+ listAllModels[1]+=1
54
+ listAllModels[2].append(ent[0])
55
+ for tagClas in ent[1]:
56
+ new_tag=True
57
+ for tag in listTemp:
58
+ if tag[0] == tagClas:
59
+ tag[1]+=1
60
+ tag[2].append(ent[0])
61
+ new_tag=False
62
+ if new_tag:
63
+ listTemp.append([tagClas,1,[ent[0]]])
64
+ tags_plus_models.append(listAllModels)
65
+ for t in listTemp:
66
+ if t[1]>=min and t[1]!=len(models_plus_tags):
67
+ tags_plus_models.append(t)
68
+ return tags_plus_models
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ def orga_tag(tags_plus_models):
71
+ output=[]
72
+ while(len(output)<len(tags_plus_models)):
73
+ max=0
74
+ for tag in tags_plus_models:
75
+ if tag[1]>max:
76
+ if tag not in output:
77
+ max=tag[1]
78
+ tagMax=tag
79
+ output.append(tagMax)
80
+ return output
81
+ def tag_new(models,limit=40):
82
+ output=["NEW",0,[]]
83
+ if limit>len(models):
84
+ limit=len(models)
85
+ for i in range(limit):
86
+ output[1]+=1
87
+ output[2].append(models[i])
88
+ return output
89
+
90
+ def tag_fav(models=models,fav_models=fav_models):
91
+ output=["FAV",0,[]]
92
+ for m in fav_models:
93
+ if m in models:
94
+ output[1]+=1
95
+ output[2].append(m)
96
+ return output
97
+
98
+ def update_tag(models_plus_tags,list_new_tag):
99
+ for m_new in list_new_tag[2]:
100
+ for m in models_plus_tags:
101
+ if m_new == m[0]:
102
+ m[1].append(list_new_tag[0])
103
+ return models_plus_tags
104
+
105
+
106
+ from operator import itemgetter
107
+
108
+ #models = find_model_list("Yntec", [], "", "last_modified", 20)
109
+ models , models_plus_tags = find_model_list("John6666", ["stable-diffusion-xl"], "", "last_modified", 100)
110
+ #tags_plus_models = orga_tag(clas_tags(models_plus_tags,2))
111
+ tags_plus_models = orga_tag(clas_tags(sorted(models_plus_tags, key=itemgetter(0)),2))
112
+ list_new=tag_new(models,40)
113
+ models_plus_tags=update_tag(models_plus_tags,list_new)
114
+ tags_plus_models.insert(1,list_new)
115
+ list_fav=tag_fav()
116
+ if list_fav[1]>0:
117
+ tags_plus_models.insert(1,list_fav)
118
+ models_plus_tags=update_tag(models_plus_tags,list_fav)
119
+
120
+ #models.extend(find_model_list("John6666", ["stable-diffusion-xl"], "", "last_modified", 200))
121
+
122
+ #models.extend(find_model_list("John6666", [], "", "last_modified", 20)) # The latest 20 models will be added to the models written above.
123
+
124
+ # Examples:
125
+ #models = ['yodayo-ai/kivotos-xl-2.0', 'yodayo-ai/holodayo-xl-2.1'] # specific models
126
+ #models = find_model_list("Yntec", [], "", "last_modified", 20) # Yntec's latest 20 models
127
+ #models = find_model_list("Yntec", ["anime"], "", "last_modified", 20) # Yntec's latest 20 models with 'anime' tag
128
+ #models = find_model_list("Yntec", [], "anime", "last_modified", 20) # Yntec's latest 20 models without 'anime' tag
129
+ #models = find_model_list("", [], "", "last_modified", 20) # latest 20 text-to-image models of huggingface
130
+ #models = find_model_list("", [], "", "downloads", 20) # monthly most downloaded 20 text-to-image models of huggingface
externalmod.py ADDED
@@ -0,0 +1,584 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """This module should not be used directly as its API is subject to change. Instead,
2
+ use the `gr.Blocks.load()` or `gr.load()` functions."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ import os
8
+ import re
9
+ import tempfile
10
+ import warnings
11
+ from pathlib import Path
12
+ from typing import TYPE_CHECKING, Callable
13
+
14
+ import httpx
15
+ import huggingface_hub
16
+ from gradio_client import Client
17
+ from gradio_client.client import Endpoint
18
+ from gradio_client.documentation import document
19
+ from packaging import version
20
+
21
+ import gradio
22
+ from gradio import components, external_utils, utils
23
+ from gradio.context import Context
24
+ from gradio.exceptions import (
25
+ GradioVersionIncompatibleError,
26
+ ModelNotFoundError,
27
+ TooManyRequestsError,
28
+ )
29
+ from gradio.processing_utils import save_base64_to_cache, to_binary
30
+
31
+ if TYPE_CHECKING:
32
+ from gradio.blocks import Blocks
33
+ from gradio.interface import Interface
34
+
35
+
36
+ server_timeout = 600
37
+
38
+
39
+ @document()
40
+ def load(
41
+ name: str,
42
+ src: str | None = None,
43
+ hf_token: str | None = None,
44
+ alias: str | None = None,
45
+ **kwargs,
46
+ ) -> Blocks:
47
+ """
48
+ Constructs a demo from a Hugging Face repo. Can accept model repos (if src is "models") or Space repos (if src is "spaces"). The input
49
+ and output components are automatically loaded from the repo. Note that if a Space is loaded, certain high-level attributes of the Blocks (e.g.
50
+ custom `css`, `js`, and `head` attributes) will not be loaded.
51
+ Parameters:
52
+ name: the name of the model (e.g. "gpt2" or "facebook/bart-base") or space (e.g. "flax-community/spanish-gpt2"), can include the `src` as prefix (e.g. "models/facebook/bart-base")
53
+ src: the source of the model: `models` or `spaces` (or leave empty if source is provided as a prefix in `name`)
54
+ hf_token: optional access token for loading private Hugging Face Hub models or spaces. Find your token here: https://huggingface.co/settings/tokens. Warning: only provide this if you are loading a trusted private Space as it can be read by the Space you are loading.
55
+ alias: optional string used as the name of the loaded model instead of the default name (only applies if loading a Space running Gradio 2.x)
56
+ Returns:
57
+ a Gradio Blocks object for the given model
58
+ Example:
59
+ import gradio as gr
60
+ demo = gr.load("gradio/question-answering", src="spaces")
61
+ demo.launch()
62
+ """
63
+ return load_blocks_from_repo(
64
+ name=name, src=src, hf_token=hf_token, alias=alias, **kwargs
65
+ )
66
+
67
+
68
+ def load_blocks_from_repo(
69
+ name: str,
70
+ src: str | None = None,
71
+ hf_token: str | None = None,
72
+ alias: str | None = None,
73
+ **kwargs,
74
+ ) -> Blocks:
75
+ """Creates and returns a Blocks instance from a Hugging Face model or Space repo."""
76
+ if src is None:
77
+ # Separate the repo type (e.g. "model") from repo name (e.g. "google/vit-base-patch16-224")
78
+ tokens = name.split("/")
79
+ if len(tokens) <= 1:
80
+ raise ValueError(
81
+ "Either `src` parameter must be provided, or `name` must be formatted as {src}/{repo name}"
82
+ )
83
+ src = tokens[0]
84
+ name = "/".join(tokens[1:])
85
+
86
+ factory_methods: dict[str, Callable] = {
87
+ # for each repo type, we have a method that returns the Interface given the model name & optionally an hf_token
88
+ "huggingface": from_model,
89
+ "models": from_model,
90
+ "spaces": from_spaces,
91
+ }
92
+ if src.lower() not in factory_methods:
93
+ raise ValueError(f"parameter: src must be one of {factory_methods.keys()}")
94
+
95
+ if hf_token is not None:
96
+ if Context.hf_token is not None and Context.hf_token != hf_token:
97
+ warnings.warn(
98
+ """You are loading a model/Space with a different access token than the one you used to load a previous model/Space. This is not recommended, as it may cause unexpected behavior."""
99
+ )
100
+ Context.hf_token = hf_token
101
+
102
+ blocks: gradio.Blocks = factory_methods[src](name, hf_token, alias, **kwargs)
103
+ return blocks
104
+
105
+
106
+ def from_model(model_name: str, hf_token: str | None, alias: str | None, **kwargs):
107
+ model_url = f"https://huggingface.co/{model_name}"
108
+ api_url = f"https://api-inference.huggingface.co/models/{model_name}"
109
+ print(f"Fetching model from: {model_url}")
110
+
111
+ headers = {"Authorization": f"Bearer {hf_token}"} if hf_token is not None else {}
112
+ response = httpx.request("GET", api_url, headers=headers)
113
+ if response.status_code != 200:
114
+ raise ModelNotFoundError(
115
+ f"Could not find model: {model_name}. If it is a private or gated model, please provide your Hugging Face access token (https://huggingface.co/settings/tokens) as the argument for the `hf_token` parameter."
116
+ )
117
+ p = response.json().get("pipeline_tag")
118
+
119
+ headers["X-Wait-For-Model"] = "true"
120
+ client = huggingface_hub.InferenceClient(
121
+ model=model_name, headers=headers, token=hf_token, timeout=server_timeout,
122
+ )
123
+
124
+ # For tasks that are not yet supported by the InferenceClient
125
+ GRADIO_CACHE = os.environ.get("GRADIO_TEMP_DIR") or str( # noqa: N806
126
+ Path(tempfile.gettempdir()) / "gradio"
127
+ )
128
+
129
+ def custom_post_binary(data):
130
+ data = to_binary({"path": data})
131
+ response = httpx.request("POST", api_url, headers=headers, content=data)
132
+ return save_base64_to_cache(
133
+ external_utils.encode_to_base64(response), cache_dir=GRADIO_CACHE
134
+ )
135
+
136
+ preprocess = None
137
+ postprocess = None
138
+ examples = None
139
+
140
+ # example model: ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition
141
+ if p == "audio-classification":
142
+ inputs = components.Audio(type="filepath", label="Input")
143
+ outputs = components.Label(label="Class")
144
+ postprocess = external_utils.postprocess_label
145
+ examples = [
146
+ "https://gradio-builds.s3.amazonaws.com/demo-files/audio_sample.wav"
147
+ ]
148
+ fn = client.audio_classification
149
+ # example model: facebook/xm_transformer_sm_all-en
150
+ elif p == "audio-to-audio":
151
+ inputs = components.Audio(type="filepath", label="Input")
152
+ outputs = components.Audio(label="Output")
153
+ examples = [
154
+ "https://gradio-builds.s3.amazonaws.com/demo-files/audio_sample.wav"
155
+ ]
156
+ fn = custom_post_binary
157
+ # example model: facebook/wav2vec2-base-960h
158
+ elif p == "automatic-speech-recognition":
159
+ inputs = components.Audio(type="filepath", label="Input")
160
+ outputs = components.Textbox(label="Output")
161
+ examples = [
162
+ "https://gradio-builds.s3.amazonaws.com/demo-files/audio_sample.wav"
163
+ ]
164
+ fn = client.automatic_speech_recognition
165
+ # example model: microsoft/DialoGPT-medium
166
+ elif p == "conversational":
167
+ inputs = [
168
+ components.Textbox(render=False),
169
+ components.State(render=False),
170
+ ]
171
+ outputs = [
172
+ components.Chatbot(render=False),
173
+ components.State(render=False),
174
+ ]
175
+ examples = [["Hello World"]]
176
+ preprocess = external_utils.chatbot_preprocess
177
+ postprocess = external_utils.chatbot_postprocess
178
+ fn = client.conversational
179
+ # example model: julien-c/distilbert-feature-extraction
180
+ elif p == "feature-extraction":
181
+ inputs = components.Textbox(label="Input")
182
+ outputs = components.Dataframe(label="Output")
183
+ fn = client.feature_extraction
184
+ postprocess = utils.resolve_singleton
185
+ # example model: distilbert/distilbert-base-uncased
186
+ elif p == "fill-mask":
187
+ inputs = components.Textbox(label="Input")
188
+ outputs = components.Label(label="Classification")
189
+ examples = [
190
+ "Hugging Face is the AI community, working together, to [MASK] the future."
191
+ ]
192
+ postprocess = external_utils.postprocess_mask_tokens
193
+ fn = client.fill_mask
194
+ # Example: google/vit-base-patch16-224
195
+ elif p == "image-classification":
196
+ inputs = components.Image(type="filepath", label="Input Image")
197
+ outputs = components.Label(label="Classification")
198
+ postprocess = external_utils.postprocess_label
199
+ examples = ["https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg"]
200
+ fn = client.image_classification
201
+ # Example: deepset/xlm-roberta-base-squad2
202
+ elif p == "question-answering":
203
+ inputs = [
204
+ components.Textbox(label="Question"),
205
+ components.Textbox(lines=7, label="Context"),
206
+ ]
207
+ outputs = [
208
+ components.Textbox(label="Answer"),
209
+ components.Label(label="Score"),
210
+ ]
211
+ examples = [
212
+ [
213
+ "What entity was responsible for the Apollo program?",
214
+ "The Apollo program, also known as Project Apollo, was the third United States human spaceflight"
215
+ " program carried out by the National Aeronautics and Space Administration (NASA), which accomplished"
216
+ " landing the first humans on the Moon from 1969 to 1972.",
217
+ ]
218
+ ]
219
+ postprocess = external_utils.postprocess_question_answering
220
+ fn = client.question_answering
221
+ # Example: facebook/bart-large-cnn
222
+ elif p == "summarization":
223
+ inputs = components.Textbox(label="Input")
224
+ outputs = components.Textbox(label="Summary")
225
+ examples = [
226
+ [
227
+ "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."
228
+ ]
229
+ ]
230
+ fn = client.summarization
231
+ # Example: distilbert-base-uncased-finetuned-sst-2-english
232
+ elif p == "text-classification":
233
+ inputs = components.Textbox(label="Input")
234
+ outputs = components.Label(label="Classification")
235
+ examples = ["I feel great"]
236
+ postprocess = external_utils.postprocess_label
237
+ fn = client.text_classification
238
+ # Example: gpt2
239
+ elif p == "text-generation":
240
+ inputs = components.Textbox(label="Text")
241
+ outputs = inputs
242
+ examples = ["Once upon a time"]
243
+ fn = external_utils.text_generation_wrapper(client)
244
+ # Example: valhalla/t5-small-qa-qg-hl
245
+ elif p == "text2text-generation":
246
+ inputs = components.Textbox(label="Input")
247
+ outputs = components.Textbox(label="Generated Text")
248
+ examples = ["Translate English to Arabic: How are you?"]
249
+ fn = client.text_generation
250
+ # Example: Helsinki-NLP/opus-mt-en-ar
251
+ elif p == "translation":
252
+ inputs = components.Textbox(label="Input")
253
+ outputs = components.Textbox(label="Translation")
254
+ examples = ["Hello, how are you?"]
255
+ fn = client.translation
256
+ # Example: facebook/bart-large-mnli
257
+ elif p == "zero-shot-classification":
258
+ inputs = [
259
+ components.Textbox(label="Input"),
260
+ components.Textbox(label="Possible class names (" "comma-separated)"),
261
+ components.Checkbox(label="Allow multiple true classes"),
262
+ ]
263
+ outputs = components.Label(label="Classification")
264
+ postprocess = external_utils.postprocess_label
265
+ examples = [["I feel great", "happy, sad", False]]
266
+ fn = external_utils.zero_shot_classification_wrapper(client)
267
+ # Example: sentence-transformers/distilbert-base-nli-stsb-mean-tokens
268
+ elif p == "sentence-similarity":
269
+ inputs = [
270
+ components.Textbox(
271
+ label="Source Sentence",
272
+ placeholder="Enter an original sentence",
273
+ ),
274
+ components.Textbox(
275
+ lines=7,
276
+ placeholder="Sentences to compare to -- separate each sentence by a newline",
277
+ label="Sentences to compare to",
278
+ ),
279
+ ]
280
+ outputs = components.JSON(label="Similarity scores")
281
+ examples = [["That is a happy person", "That person is very happy"]]
282
+ fn = external_utils.sentence_similarity_wrapper(client)
283
+ # Example: julien-c/ljspeech_tts_train_tacotron2_raw_phn_tacotron_g2p_en_no_space_train
284
+ elif p == "text-to-speech":
285
+ inputs = components.Textbox(label="Input")
286
+ outputs = components.Audio(label="Audio")
287
+ examples = ["Hello, how are you?"]
288
+ fn = client.text_to_speech
289
+ # example model: osanseviero/BigGAN-deep-128
290
+ elif p == "text-to-image":
291
+ inputs = components.Textbox(label="Input")
292
+ outputs = components.Image(label="Output")
293
+ examples = ["A beautiful sunset"]
294
+ fn = client.text_to_image
295
+ # example model: huggingface-course/bert-finetuned-ner
296
+ elif p == "token-classification":
297
+ inputs = components.Textbox(label="Input")
298
+ outputs = components.HighlightedText(label="Output")
299
+ examples = [
300
+ "Hugging Face is a company based in Paris and New York City that acquired Gradio in 2021."
301
+ ]
302
+ fn = external_utils.token_classification_wrapper(client)
303
+ # example model: impira/layoutlm-document-qa
304
+ elif p == "document-question-answering":
305
+ inputs = [
306
+ components.Image(type="filepath", label="Input Document"),
307
+ components.Textbox(label="Question"),
308
+ ]
309
+ postprocess = external_utils.postprocess_label
310
+ outputs = components.Label(label="Label")
311
+ fn = client.document_question_answering
312
+ # example model: dandelin/vilt-b32-finetuned-vqa
313
+ elif p == "visual-question-answering":
314
+ inputs = [
315
+ components.Image(type="filepath", label="Input Image"),
316
+ components.Textbox(label="Question"),
317
+ ]
318
+ outputs = components.Label(label="Label")
319
+ postprocess = external_utils.postprocess_visual_question_answering
320
+ examples = [
321
+ [
322
+ "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
323
+ "What animal is in the image?",
324
+ ]
325
+ ]
326
+ fn = client.visual_question_answering
327
+ # example model: Salesforce/blip-image-captioning-base
328
+ elif p == "image-to-text":
329
+ inputs = components.Image(type="filepath", label="Input Image")
330
+ outputs = components.Textbox(label="Generated Text")
331
+ examples = ["https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg"]
332
+ fn = client.image_to_text
333
+ # example model: rajistics/autotrain-Adult-934630783
334
+ elif p in ["tabular-classification", "tabular-regression"]:
335
+ examples = external_utils.get_tabular_examples(model_name)
336
+ col_names, examples = external_utils.cols_to_rows(examples) # type: ignore
337
+ examples = [[examples]] if examples else None
338
+ inputs = components.Dataframe(
339
+ label="Input Rows",
340
+ type="pandas",
341
+ headers=col_names,
342
+ col_count=(len(col_names), "fixed"),
343
+ render=False,
344
+ )
345
+ outputs = components.Dataframe(
346
+ label="Predictions", type="array", headers=["prediction"]
347
+ )
348
+ fn = external_utils.tabular_wrapper
349
+ # example model: microsoft/table-transformer-detection
350
+ elif p == "object-detection":
351
+ inputs = components.Image(type="filepath", label="Input Image")
352
+ outputs = components.AnnotatedImage(label="Annotations")
353
+ fn = external_utils.object_detection_wrapper(client)
354
+ # example model: stabilityai/stable-diffusion-xl-refiner-1.0
355
+ elif p == "image-to-image":
356
+ inputs = [
357
+ components.Image(type="filepath", label="Input Image"),
358
+ components.Textbox(label="Input"),
359
+ ]
360
+ outputs = components.Image(label="Output")
361
+ examples = [
362
+ [
363
+ "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
364
+ "Photo of a cheetah with green eyes",
365
+ ]
366
+ ]
367
+ fn = client.image_to_image
368
+ else:
369
+ raise ValueError(f"Unsupported pipeline type: {p}")
370
+
371
+ def query_huggingface_inference_endpoints(*data, **kwargs):
372
+ if preprocess is not None:
373
+ data = preprocess(*data)
374
+ data = fn(*data, **kwargs) # type: ignore
375
+ if postprocess is not None:
376
+ data = postprocess(data) # type: ignore
377
+ return data
378
+
379
+ query_huggingface_inference_endpoints.__name__ = alias or model_name
380
+
381
+ interface_info = {
382
+ "fn": query_huggingface_inference_endpoints,
383
+ "inputs": inputs,
384
+ "outputs": outputs,
385
+ "title": model_name,
386
+ # "examples": examples,
387
+ }
388
+
389
+ kwargs = dict(interface_info, **kwargs)
390
+ interface = gradio.Interface(**kwargs)
391
+ return interface
392
+
393
+
394
+ def from_spaces(
395
+ space_name: str, hf_token: str | None, alias: str | None, **kwargs
396
+ ) -> Blocks:
397
+ client = Client(
398
+ space_name,
399
+ hf_token=hf_token,
400
+ download_files=False,
401
+ _skip_components=False,
402
+ )
403
+
404
+ space_url = f"https://huggingface.co/spaces/{space_name}"
405
+
406
+ print(f"Fetching Space from: {space_url}")
407
+
408
+ headers = {}
409
+ if hf_token is not None:
410
+ headers["Authorization"] = f"Bearer {hf_token}"
411
+
412
+ iframe_url = (
413
+ httpx.get(
414
+ f"https://huggingface.co/api/spaces/{space_name}/host", headers=headers
415
+ )
416
+ .json()
417
+ .get("host")
418
+ )
419
+
420
+ if iframe_url is None:
421
+ raise ValueError(
422
+ f"Could not find Space: {space_name}. If it is a private or gated Space, please provide your Hugging Face access token (https://huggingface.co/settings/tokens) as the argument for the `hf_token` parameter."
423
+ )
424
+
425
+ r = httpx.get(iframe_url, headers=headers)
426
+
427
+ result = re.search(
428
+ r"window.gradio_config = (.*?);[\s]*</script>", r.text
429
+ ) # some basic regex to extract the config
430
+ try:
431
+ config = json.loads(result.group(1)) # type: ignore
432
+ except AttributeError as ae:
433
+ raise ValueError(f"Could not load the Space: {space_name}") from ae
434
+ if "allow_flagging" in config: # Create an Interface for Gradio 2.x Spaces
435
+ return from_spaces_interface(
436
+ space_name, config, alias, hf_token, iframe_url, **kwargs
437
+ )
438
+ else: # Create a Blocks for Gradio 3.x Spaces
439
+ if kwargs:
440
+ warnings.warn(
441
+ "You cannot override parameters for this Space by passing in kwargs. "
442
+ "Instead, please load the Space as a function and use it to create a "
443
+ "Blocks or Interface locally. You may find this Guide helpful: "
444
+ "https://gradio.app/using_blocks_like_functions/"
445
+ )
446
+ if client.app_version < version.Version("4.0.0b14"):
447
+ return from_spaces_blocks(space=space_name, hf_token=hf_token)
448
+
449
+
450
+ def from_spaces_blocks(space: str, hf_token: str | None) -> Blocks:
451
+ client = Client(
452
+ space,
453
+ hf_token=hf_token,
454
+ download_files=False,
455
+ _skip_components=False,
456
+ )
457
+ # We set deserialize to False to avoid downloading output files from the server.
458
+ # Instead, we serve them as URLs using the /proxy/ endpoint directly from the server.
459
+
460
+ if client.app_version < version.Version("4.0.0b14"):
461
+ raise GradioVersionIncompatibleError(
462
+ f"Gradio version 4.x cannot load spaces with versions less than 4.x ({client.app_version})."
463
+ "Please downgrade to version 3 to load this space."
464
+ )
465
+
466
+ # Use end_to_end_fn here to properly upload/download all files
467
+ predict_fns = []
468
+ for fn_index, endpoint in client.endpoints.items():
469
+ if not isinstance(endpoint, Endpoint):
470
+ raise TypeError(
471
+ f"Expected endpoint to be an Endpoint, but got {type(endpoint)}"
472
+ )
473
+ helper = client.new_helper(fn_index)
474
+ if endpoint.backend_fn:
475
+ predict_fns.append(endpoint.make_end_to_end_fn(helper))
476
+ else:
477
+ predict_fns.append(None)
478
+ return gradio.Blocks.from_config(client.config, predict_fns, client.src) # type: ignore
479
+
480
+
481
+ def from_spaces_interface(
482
+ model_name: str,
483
+ config: dict,
484
+ alias: str | None,
485
+ hf_token: str | None,
486
+ iframe_url: str,
487
+ **kwargs,
488
+ ) -> Interface:
489
+ config = external_utils.streamline_spaces_interface(config)
490
+ api_url = f"{iframe_url}/api/predict/"
491
+ headers = {"Content-Type": "application/json"}
492
+ if hf_token is not None:
493
+ headers["Authorization"] = f"Bearer {hf_token}"
494
+
495
+ # The function should call the API with preprocessed data
496
+ def fn(*data):
497
+ data = json.dumps({"data": data})
498
+ response = httpx.post(api_url, headers=headers, data=data) # type: ignore
499
+ result = json.loads(response.content.decode("utf-8"))
500
+ if "error" in result and "429" in result["error"]:
501
+ raise TooManyRequestsError("Too many requests to the Hugging Face API")
502
+ try:
503
+ output = result["data"]
504
+ except KeyError as ke:
505
+ raise KeyError(
506
+ f"Could not find 'data' key in response from external Space. Response received: {result}"
507
+ ) from ke
508
+ if (
509
+ len(config["outputs"]) == 1
510
+ ): # if the fn is supposed to return a single value, pop it
511
+ output = output[0]
512
+ if (
513
+ len(config["outputs"]) == 1 and isinstance(output, list)
514
+ ): # Needed to support Output.Image() returning bounding boxes as well (TODO: handle different versions of gradio since they have slightly different APIs)
515
+ output = output[0]
516
+ return output
517
+
518
+ fn.__name__ = alias if (alias is not None) else model_name
519
+ config["fn"] = fn
520
+
521
+ kwargs = dict(config, **kwargs)
522
+ kwargs["_api_mode"] = True
523
+ interface = gradio.Interface(**kwargs)
524
+ return interface
525
+
526
+
527
+ def gr_Interface_load(
528
+ name: str,
529
+ src: str | None = None,
530
+ hf_token: str | None = None,
531
+ alias: str | None = None,
532
+ **kwargs,
533
+ ) -> Blocks:
534
+ try:
535
+ return load_blocks_from_repo(name, src, hf_token, alias)
536
+ except Exception as e:
537
+ print(e)
538
+ return gradio.Interface(lambda: None, ['text'], ['image'])
539
+
540
+
541
+ def list_uniq(l):
542
+ return sorted(set(l), key=l.index)
543
+
544
+
545
+ def get_status(model_name: str):
546
+ from huggingface_hub import InferenceClient
547
+ client = InferenceClient(timeout=10)
548
+ return client.get_model_status(model_name)
549
+
550
+
551
+ def is_loadable(model_name: str, force_gpu: bool = False):
552
+ try:
553
+ status = get_status(model_name)
554
+ except Exception as e:
555
+ print(e)
556
+ print(f"Couldn't load {model_name}.")
557
+ return False
558
+ gpu_state = isinstance(status.compute_type, dict) and "gpu" in status.compute_type.keys()
559
+ if status is None or status.state not in ["Loadable", "Loaded"] or (force_gpu and not gpu_state):
560
+ print(f"Couldn't load {model_name}. Model state:'{status.state}', GPU:{gpu_state}")
561
+ return status is not None and status.state in ["Loadable", "Loaded"] and (not force_gpu or gpu_state)
562
+
563
+
564
+ def find_model_list(author: str="", tags: list[str]=[], not_tag="", sort: str="last_modified", limit: int=30, force_gpu=False, check_status=False):
565
+ from huggingface_hub import HfApi
566
+ api = HfApi()
567
+ default_tags = ["diffusers"]
568
+ if not sort: sort = "last_modified"
569
+ limit = limit * 20 if check_status and force_gpu else limit * 5
570
+ models = []
571
+ try:
572
+ model_infos = api.list_models(author=author, task="text-to-image",
573
+ tags=list_uniq(default_tags + tags), cardData=True, sort=sort, limit=limit)
574
+ except Exception as e:
575
+ print(f"Error: Failed to list models.")
576
+ print(e)
577
+ return models
578
+ for model in model_infos:
579
+ if not model.private and not model.gated:
580
+ loadable = is_loadable(model.id, force_gpu) if check_status else True
581
+ if not_tag and not_tag in model.tags or not loadable: continue
582
+ models.append(model.id)
583
+ if len(models) == limit: break
584
+ return models