John6666 commited on
Commit
2b8f0f4
β€’
1 Parent(s): 796babb

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +12 -12
  2. all_models.py +47 -532
  3. app.py +311 -216
  4. externalmod.py +580 -0
README.md CHANGED
@@ -1,13 +1,13 @@
1
- ---
2
- title: TestDifs
3
- emoji: πŸ›•πŸ›•
4
- colorFrom: green
5
- colorTo: blue
6
- sdk: gradio
7
- sdk_version: 3.46.0
8
- app_file: app.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: true
10
+ short_description: TestDifs
11
+ ---
12
+
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
all_models.py CHANGED
@@ -1,532 +1,47 @@
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
+ models = [
2
+ "Yntec/beLIEve", #865
3
+ "digiplay/MilkyWonderland_v1", #866
4
+ "Yntec/Hyperlink", #861
5
+ "digiplay/AnalogMadness-realistic-model-v5", #864
6
+ "Yntec/HyperRemix", #859
7
+ "digiplay/ZHMix-Dramatic-v2.0",
8
+ "Yntec/realisticStockPhoto3", #863
9
+ "digiplay/fishmix_other_v1",
10
+ "Yntec/HyperPhotoGASM", #858
11
+ "digiplay/Gap_2.6",
12
+ "Yntec/CrystalReality", #855
13
+ 'yodayo-ai/clandestine-xl-1.0',
14
+ 'yodayo-ai/kivotos-xl-2.0',
15
+ 'yodayo-ai/holodayo-xl-2.1',
16
+ 'cagliostrolab/animagine-xl-3.1',
17
+ 'votepurchase/ponyDiffusionV6XL',
18
+ 'eienmojiki/Anything-XL',
19
+ 'eienmojiki/Starry-XL-v5.2',
20
+ "digiplay/MilkyWonderland_v1",
21
+ 'digiplay/majicMIX_sombre_v2',
22
+ 'digiplay/majicMIX_realistic_v7',
23
+ 'votepurchase/counterfeitV30_v30',
24
+ 'Meina/MeinaMix_V11',
25
+ 'KBlueLeaf/Kohaku-XL-Epsilon-rev3',
26
+ 'KBlueLeaf/Kohaku-XL-Zeta',
27
+ 'kayfahaarukku/UrangDiffusion-1.2',
28
+ 'Eugeoter/artiwaifu-diffusion-1.0',
29
+ 'Raelina/Rae-Diffusion-XL-V2',
30
+ 'Raelina/Raemu-XL-V4',
31
+ ]
32
+
33
+ last = 'Raelina/Raemu-XL-V4',
34
+
35
+
36
+ from externalmod import find_model_list
37
+ #models = find_model_list("Yntec", [], "", "last_modified", 20)
38
+ models.extend(find_model_list("John6666", [], "", "last_modified", 200))
39
+ #models.extend(find_model_list("John6666", [], "", "last_modified", 20)) # The latest 20 models will be added to the models written above.
40
+
41
+ # Examples:
42
+ #models = ['yodayo-ai/kivotos-xl-2.0', 'yodayo-ai/holodayo-xl-2.1'] # specific models
43
+ #models = find_model_list("Yntec", [], "", "last_modified", 20) # Yntec's latest 20 models
44
+ #models = find_model_list("Yntec", ["anime"], "", "last_modified", 20) # Yntec's latest 20 models with 'anime' tag
45
+ #models = find_model_list("Yntec", [], "anime", "last_modified", 20) # Yntec's latest 20 models without 'anime' tag
46
+ #models = find_model_list("", [], "", "last_modified", 20) # latest 20 text-to-image models of huggingface
47
+ #models = find_model_list("", [], "", "downloads", 20) # monthly most downloaded 20 text-to-image models of huggingface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -1,216 +1,311 @@
1
- import os
2
- import gradio as gr
3
- from random import randint
4
- from all_models import models
5
- from datetime import datetime
6
-
7
- now2 = 0
8
- nb_models=24
9
-
10
- def split_models(models,nb_models):
11
- models_temp=[]
12
- models_lis_temp=[]
13
- i=0
14
- for m in models:
15
- models_temp.append(m)
16
- i=i+1
17
- if i%nb_models==0:
18
- models_lis_temp.append(models_temp)
19
- models_temp=[]
20
- if len(models_temp)>1:
21
- models_lis_temp.append(models_temp)
22
- return models_lis_temp
23
-
24
- def split_models_axb(models,a,b):
25
- models_temp=[]
26
- models_lis_temp=[]
27
- i=0
28
- nb_models=b
29
- for m in models:
30
- for j in range(a):
31
- models_temp.append(m)
32
- i=i+1
33
- if i%nb_models==0:
34
- models_lis_temp.append(models_temp)
35
- models_temp=[]
36
- if len(models_temp)>1:
37
- models_lis_temp.append(models_temp)
38
- return models_lis_temp , a*b
39
-
40
- def split_models_8x3(models,nb_models):
41
- models_temp=[]
42
- models_lis_temp=[]
43
- i=0
44
- nb_models_x3=8
45
- for m in models:
46
- models_temp.append(m)
47
- i=i+1
48
- if i%nb_models_x3==0:
49
- models_lis_temp.append(models_temp+models_temp+models_temp)
50
- models_temp=[]
51
- if len(models_temp)>1:
52
- models_lis_temp.append(models_temp+models_temp+models_temp)
53
- return models_lis_temp
54
-
55
- """models_test=split_models_x3(models,nb_models)"""
56
- """models_test=split_models(models,nb_models)"""
57
- models_test , nb_models =split_models_axb(models,2,20)
58
-
59
- def get_current_time():
60
- now = datetime.now()
61
- now2 = now
62
- current_time = now2.strftime("%Y-%m-%d %H:%M:%S")
63
- ki = f'{kii} {current_time}'
64
- return ki
65
-
66
- def load_fn(models):
67
- global models_load
68
- global num_models
69
- global default_models
70
- models_load = {}
71
- num_models = len(models)
72
- if num_models!=0:
73
- default_models = models[:num_models]
74
- else:
75
- default_models = {}
76
- for model in models:
77
- if model not in models_load.keys():
78
- try:
79
- m = gr.load(f'models/{model}')
80
- except Exception as error:
81
- m = gr.Interface(lambda txt: None, ['text'], ['image'])
82
- models_load.update({model: m})
83
-
84
-
85
- """models = models_test[1]"""
86
- load_fn(models)
87
- """models = {}
88
- load_fn(models)"""
89
-
90
-
91
- def extend_choices(choices):
92
- return choices + (nb_models - len(choices)) * ['NA']
93
- """return choices + (num_models - len(choices)) * ['NA']"""
94
-
95
- def extend_choices_b(choices):
96
- choices_plus = extend_choices(choices)
97
- return [gr.Textbox(m, visible=False) for m in choices_plus]
98
-
99
- def update_imgbox(choices):
100
- choices_plus = extend_choices(choices)
101
- return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choices_plus]
102
-
103
- def choice_group_a(group_model_choice):
104
- for m in models_test:
105
- if group_model_choice==m[1]:
106
- choice=m
107
- print(choice)
108
- return choice
109
-
110
- def choice_group_b(group_model_choice):
111
- choice=choice_group_a(group_model_choice)
112
- choice = extend_choices(choice)
113
- """return [gr.Image(label=m, min_width=170, height=170) for m in choice]"""
114
- return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choice]
115
-
116
- def choice_group_c(group_model_choice):
117
- choice=choice_group_a(group_model_choice)
118
- choice = extend_choices(choice)
119
- return [gr.Textbox(m, visible=False) for m in choice]
120
-
121
- def choice_group_d(var_Test):
122
- (gen_button,stop_button,output,current_models)=var_Test
123
- for m, o in zip(current_models, output):
124
- gen_event = gen_button.click(gen_fn, [m, txt_input], o)
125
- stop_button.click(lambda s: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
126
- return gen_event
127
-
128
- def test_pass(test):
129
- if test==os.getenv('p'):
130
- print("ok")
131
- return gr.Dropdown(label="test Model", show_label=False, choices=list(models_test) , allow_custom_value=True)
132
- else:
133
- print("nop")
134
- return gr.Dropdown(label="test Model", show_label=False, choices=list([]) , allow_custom_value=True)
135
-
136
- def gen_fn(model_str, prompt):
137
- if model_str == 'NA':
138
- return None
139
- noise = str(randint(0, 9999))
140
- try :
141
- m=models_load[model_str](f'{prompt} {noise}')
142
- except Exception as error :
143
- print("error : " + model_str)
144
- m=False
145
-
146
- return m
147
-
148
- def make_me():
149
- # with gr.Tab('The Dream'):
150
- with gr.Row():
151
- #txt_input = gr.Textbox(lines=3, width=300, max_height=100)
152
- txt_input = gr.Textbox(label='Your prompt:', lines=3, width=300, max_height=100)
153
-
154
- gen_button = gr.Button('Generate images', width=150, height=30)
155
- stop_button = gr.Button('Stop', variant='secondary', interactive=False, width=150, height=30)
156
- gen_button.click(lambda s: gr.update(interactive=True), None, stop_button)
157
- gr.HTML("""
158
- <div style="text-align: center; max-width: 100%; margin: 0 auto;">
159
- <body>
160
- </body>
161
- </div>
162
- """)
163
- with gr.Row():
164
- """output = [gr.Image(label=m, min_width=170, height=170) for m in default_models]
165
- current_models = [gr.Textbox(m, visible=False) for m in default_models]"""
166
- """choices=[models_test[0][0]]"""
167
- choices=models_test[0]
168
- """output = [gr.Image(label=m, min_width=170, height=170) for m in choices]
169
- current_models = [gr.Textbox(m, visible=False) for m in choices]"""
170
- output = update_imgbox([choices[0]])
171
- current_models = extend_choices_b([choices[0]])
172
-
173
- for m, o in zip(current_models, output):
174
- gen_event = gen_button.click(gen_fn, [m, txt_input], o)
175
- stop_button.click(lambda s: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
176
- """with gr.Accordion('Model selection'):
177
- model_choice = gr.CheckboxGroup(models, label=f' {num_models} different models selected', value=default_models, multiselect=True, max_choices=num_models, interactive=True, filterable=False)
178
- model_choice.change(update_imgbox, (gen_button,stop_button,group_model_choice), output)
179
- model_choice.change(extend_choices, model_choice, current_models)
180
- """
181
-
182
- with gr.Accordion("test", open=True):
183
- """group_model_choice = gr.Dropdown(label="test Model", show_label=False, choices=list(models_test) , allow_custom_value=True)"""
184
- group_model_choice = gr.Dropdown(label="test Model", show_label=False, choices=list([]) , allow_custom_value=True)
185
- group_model_choice.change(choice_group_b,group_model_choice,output)
186
- group_model_choice.change(choice_group_c,group_model_choice,current_models)
187
- """group_model_choice.change(choice_group_d,(gen_button,stop_button,output,current_models),gen_event)"""
188
- with gr.Row():
189
- txt_input_p = gr.Textbox(label='test', lines=1, width=300, max_height=100)
190
-
191
- test_button = gr.Button('test', width=30, height=10)
192
- test_button.click(test_pass,txt_input_p,group_model_choice)
193
- with gr.Row():
194
- gr.HTML("""
195
- <div class="footer">
196
- <p> Based on the <a href="https://huggingface.co/spaces/derwahnsinn/TestGen">TestGen</a> Space by derwahnsinn, the <a href="https://huggingface.co/spaces/RdnUser77/SpacIO_v1">SpacIO</a> Space by RdnUser77 and Omnibus's Maximum Multiplier!
197
- </p>
198
- """)
199
-
200
-
201
- js_code = """
202
-
203
-
204
- console.log('ghgh');
205
-
206
- """
207
-
208
-
209
- with gr.Blocks(css="div.float.svelte-1mwvhlq { position: absolute; top: var(--block-label-margin); left: var(--block-label-margin); background: none; border: none;}") as demo:
210
- gr.Markdown("<script>" + js_code + "</script>")
211
- make_me()
212
-
213
-
214
-
215
- demo.queue(concurrency_count=999)
216
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from random import randint
4
+ from all_models import models
5
+ from datetime import datetime
6
+ from externalmod import gr_Interface_load
7
+ import asyncio
8
+ import os
9
+ from threading import RLock
10
+ lock = RLock()
11
+ HF_TOKEN = os.environ.get("HF_TOKEN") if os.environ.get("HF_TOKEN") else None # If private or gated models aren't used, ENV setting is unnecessary.
12
+
13
+ now2 = 0
14
+ nb_models=24
15
+ inference_timeout = 300
16
+ MAX_SEED = 2**32-1
17
+
18
+ def split_models(models,nb_models):
19
+ models_temp=[]
20
+ models_lis_temp=[]
21
+ i=0
22
+ for m in models:
23
+ models_temp.append(m)
24
+ i=i+1
25
+ if i%nb_models==0:
26
+ models_lis_temp.append(models_temp)
27
+ models_temp=[]
28
+ if len(models_temp)>1:
29
+ models_lis_temp.append(models_temp)
30
+ return models_lis_temp
31
+
32
+ def split_models_axb(models,a,b):
33
+ models_temp=[]
34
+ models_lis_temp=[]
35
+ i=0
36
+ nb_models=b
37
+ for m in models:
38
+ for j in range(a):
39
+ models_temp.append(m)
40
+ i=i+1
41
+ if i%nb_models==0:
42
+ models_lis_temp.append(models_temp)
43
+ models_temp=[]
44
+ if len(models_temp)>1:
45
+ models_lis_temp.append(models_temp)
46
+ return models_lis_temp , a*b
47
+
48
+ def split_models_8x3(models,nb_models):
49
+ models_temp=[]
50
+ models_lis_temp=[]
51
+ i=0
52
+ nb_models_x3=8
53
+ for m in models:
54
+ models_temp.append(m)
55
+ i=i+1
56
+ if i%nb_models_x3==0:
57
+ models_lis_temp.append(models_temp+models_temp+models_temp)
58
+ models_temp=[]
59
+ if len(models_temp)>1:
60
+ models_lis_temp.append(models_temp+models_temp+models_temp)
61
+ return models_lis_temp
62
+
63
+ """models_test=split_models_x3(models,nb_models)"""
64
+ """models_test=split_models(models,nb_models)"""
65
+ models_test , nb_models =split_models_axb(models,2,20)
66
+
67
+ def get_current_time():
68
+ now = datetime.now()
69
+ now2 = now
70
+ current_time = now2.strftime("%Y-%m-%d %H:%M:%S")
71
+ kii = "" # ?
72
+ ki = f'{kii} {current_time}'
73
+ return ki
74
+
75
+ def load_fn_original(models):
76
+ global models_load
77
+ global num_models
78
+ global default_models
79
+ models_load = {}
80
+ num_models = len(models)
81
+ if num_models!=0:
82
+ default_models = models[:num_models]
83
+ else:
84
+ default_models = {}
85
+ for model in models:
86
+ if model not in models_load.keys():
87
+ try:
88
+ m = gr.load(f'models/{model}')
89
+ except Exception as error:
90
+ m = gr.Interface(lambda txt: None, ['text'], ['image'])
91
+ print(error)
92
+ models_load.update({model: m})
93
+
94
+ def load_fn(models):
95
+ global models_load
96
+ global num_models
97
+ global default_models
98
+ models_load = {}
99
+ num_models = len(models)
100
+ if num_models!=0:
101
+ default_models = models[:num_models]
102
+ else:
103
+ default_models = {}
104
+ for model in models:
105
+ if model not in models_load.keys():
106
+ try:
107
+ m = gr_Interface_load(f'models/{model}', hf_token=HF_TOKEN)
108
+ except Exception as error:
109
+ m = gr.Interface(lambda txt: None, ['text'], ['image'])
110
+ print(error)
111
+ models_load.update({model: m})
112
+
113
+
114
+ """models = models_test[1]"""
115
+ #load_fn_original
116
+ load_fn(models)
117
+ """models = {}
118
+ load_fn(models)"""
119
+
120
+
121
+ def extend_choices(choices):
122
+ return choices + (nb_models - len(choices)) * ['NA']
123
+ """return choices + (num_models - len(choices)) * ['NA']"""
124
+
125
+ def extend_choices_b(choices):
126
+ choices_plus = extend_choices(choices)
127
+ return [gr.Textbox(m, visible=False) for m in choices_plus]
128
+
129
+ def update_imgbox(choices):
130
+ choices_plus = extend_choices(choices)
131
+ return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choices_plus]
132
+
133
+ def choice_group_a(group_model_choice):
134
+ for m in models_test:
135
+ if group_model_choice==m[1]:
136
+ choice=m
137
+ print(choice)
138
+ return choice
139
+
140
+ def choice_group_b(group_model_choice):
141
+ choice=choice_group_a(group_model_choice)
142
+ choice = extend_choices(choice)
143
+ """return [gr.Image(label=m, min_width=170, height=170) for m in choice]"""
144
+ return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choice]
145
+
146
+ def choice_group_c(group_model_choice):
147
+ choice=choice_group_a(group_model_choice)
148
+ choice = extend_choices(choice)
149
+ return [gr.Textbox(m, visible=False) for m in choice]
150
+
151
+ def choice_group_d(var_Test):
152
+ (gen_button,stop_button,output,current_models, txt_input)=var_Test
153
+ for m, o in zip(current_models, output):
154
+ gen_event = gen_button.click(gen_fn, [m, txt_input], o)
155
+ stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
156
+ return gen_event
157
+
158
+ def test_pass(test):
159
+ if test==os.getenv('p'):
160
+ print("ok")
161
+ return gr.Dropdown(label="test Model", show_label=False, choices=list(models_test) , allow_custom_value=True)
162
+ else:
163
+ print("nop")
164
+ return gr.Dropdown(label="test Model", show_label=False, choices=list([]) , allow_custom_value=True)
165
+
166
+ # https://huggingface.co/docs/api-inference/detailed_parameters
167
+ # https://huggingface.co/docs/huggingface_hub/package_reference/inference_client
168
+ async def infer(model_str, prompt, nprompt="", height=None, width=None, steps=None, cfg=None, seed=-1, timeout=inference_timeout):
169
+ from pathlib import Path
170
+ kwargs = {}
171
+ if height is not None and height >= 256: kwargs["height"] = height
172
+ if width is not None and width >= 256: kwargs["width"] = width
173
+ if steps is not None and steps >= 1: kwargs["num_inference_steps"] = steps
174
+ if cfg is not None and cfg > 0: cfg = kwargs["guidance_scale"] = cfg
175
+ noise = ""
176
+ if seed >= 0: kwargs["seed"] = seed
177
+ else:
178
+ rand = randint(1, 500)
179
+ for i in range(rand):
180
+ noise += " "
181
+ task = asyncio.create_task(asyncio.to_thread(models_load[model_str].fn,
182
+ prompt=f'{prompt} {noise}', negative_prompt=nprompt, **kwargs, token=HF_TOKEN))
183
+ await asyncio.sleep(0)
184
+ try:
185
+ result = await asyncio.wait_for(task, timeout=timeout)
186
+ except (Exception, asyncio.TimeoutError) as e:
187
+ print(e)
188
+ print(f"Task timed out: {model_str}")
189
+ if not task.done(): task.cancel()
190
+ result = None
191
+ if task.done() and result is not None:
192
+ with lock:
193
+ png_path = "image.png"
194
+ result.save(png_path)
195
+ image = str(Path(png_path).resolve())
196
+ return image
197
+ return None
198
+
199
+ def gen_fn(model_str, prompt, nprompt="", height=None, width=None, steps=None, cfg=None, seed=-1):
200
+ if model_str == 'NA':
201
+ return None
202
+ try:
203
+ loop = asyncio.new_event_loop()
204
+ result = loop.run_until_complete(infer(model_str, prompt, nprompt,
205
+ height, width, steps, cfg, seed, inference_timeout))
206
+ except (Exception, asyncio.CancelledError) as e:
207
+ print(e)
208
+ print(f"Task aborted: {model_str}")
209
+ result = None
210
+ finally:
211
+ loop.close()
212
+ return result
213
+
214
+ def gen_fn_original(model_str, prompt):
215
+ if model_str == 'NA':
216
+ return None
217
+ noise = str(randint(0, 9999))
218
+ try :
219
+ m=models_load[model_str](f'{prompt} {noise}')
220
+ except Exception as error :
221
+ print("error : " + model_str)
222
+ print(error)
223
+ m=False
224
+
225
+ return m
226
+
227
+ def make_me():
228
+ # with gr.Tab('The Dream'):
229
+ with gr.Row():
230
+ #txt_input = gr.Textbox(lines=3, width=300, max_height=100)
231
+ #txt_input = gr.Textbox(label='Your prompt:', lines=3, width=300, max_height=100)
232
+ txt_input = gr.Textbox(label='Your prompt:', lines=3)
233
+ #gen_button = gr.Button('Generate images', width=150, height=30)
234
+ #stop_button = gr.Button('Stop', variant='secondary', interactive=False, width=150, height=30)
235
+ gen_button = gr.Button('Generate images')
236
+ stop_button = gr.Button('Stop', variant='secondary', interactive=False)
237
+ with gr.Accordion("Advanced", open=False, visible=True):
238
+ neg_input = gr.Textbox(label='Negative prompt:', lines=1)
239
+ with gr.Row():
240
+ width = gr.Number(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
241
+ height = gr.Number(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
242
+ with gr.Row():
243
+ steps = gr.Number(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
244
+ cfg = gr.Number(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
245
+ seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
246
+ gen_button.click(lambda: gr.update(interactive=True), None, stop_button)
247
+ gr.HTML("""
248
+ <div style="text-align: center; max-width: 100%; margin: 0 auto;">
249
+ <body>
250
+ </body>
251
+ </div>
252
+ """)
253
+ with gr.Row():
254
+ """output = [gr.Image(label=m, min_width=170, height=170) for m in default_models]
255
+ current_models = [gr.Textbox(m, visible=False) for m in default_models]"""
256
+ """choices=[models_test[0][0]]"""
257
+ choices=models_test[0]
258
+ """output = [gr.Image(label=m, min_width=170, height=170) for m in choices]
259
+ current_models = [gr.Textbox(m, visible=False) for m in choices]"""
260
+ output = update_imgbox([choices[0]])
261
+ current_models = extend_choices_b([choices[0]])
262
+
263
+ for m, o in zip(current_models, output):
264
+ #gen_event = gen_button.click(gen_fn_original, [m, txt_input], o)
265
+ gen_event = gr.on(triggers=[gen_button.click, txt_input.submit], fn=gen_fn,
266
+ inputs=[m, txt_input, neg_input, height, width, steps, cfg, seed], outputs=[o])
267
+ stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event])
268
+ """with gr.Accordion('Model selection'):
269
+ model_choice = gr.CheckboxGroup(models, label=f' {num_models} different models selected', value=default_models, multiselect=True, max_choices=num_models, interactive=True, filterable=False)
270
+ model_choice.change(update_imgbox, (gen_button,stop_button,group_model_choice), output)
271
+ model_choice.change(extend_choices, model_choice, current_models)
272
+ """
273
+
274
+ with gr.Accordion("test", open=True):
275
+ """group_model_choice = gr.Dropdown(label="test Model", show_label=False, choices=list(models_test) , allow_custom_value=True)"""
276
+ group_model_choice = gr.Dropdown(label="test Model", show_label=False, choices=list([]) , allow_custom_value=True)
277
+ group_model_choice.change(choice_group_b,group_model_choice,output)
278
+ group_model_choice.change(choice_group_c,group_model_choice,current_models)
279
+ """group_model_choice.change(choice_group_d,(gen_button,stop_button,output,current_models,txt_input),gen_event)"""
280
+ with gr.Row():
281
+ #txt_input_p = gr.Textbox(label='test', lines=1, width=300, max_height=100)
282
+ txt_input_p = gr.Textbox(label='test', lines=1)
283
+
284
+ #test_button = gr.Button('test', width=30, height=10)
285
+ test_button = gr.Button('test')
286
+ test_button.click(test_pass,txt_input_p,group_model_choice)
287
+ with gr.Row():
288
+ gr.HTML("""
289
+ <div class="footer">
290
+ <p> Based on the <a href="https://huggingface.co/spaces/derwahnsinn/TestGen">TestGen</a> Space by derwahnsinn, the <a href="https://huggingface.co/spaces/RdnUser77/SpacIO_v1">SpacIO</a> Space by RdnUser77 and Omnibus's Maximum Multiplier!
291
+ </p>
292
+ """)
293
+
294
+
295
+ js_code = """
296
+
297
+
298
+ console.log('ghgh');
299
+
300
+ """
301
+
302
+
303
+ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css="div.float.svelte-1mwvhlq { position: absolute; top: var(--block-label-margin); left: var(--block-label-margin); background: none; border: none;}") as demo:
304
+ gr.Markdown("<script>" + js_code + "</script>")
305
+ make_me()
306
+
307
+
308
+ # https://www.gradio.app/guides/setting-up-a-demo-for-maximum-performance
309
+ #demo.queue(concurrency_count=999) # concurrency_count is deprecated in 4.x
310
+ demo.queue()
311
+ demo.launch()
externalmod.py ADDED
@@ -0,0 +1,580 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ return load_blocks_from_repo(name, src, hf_token, alias)
535
+
536
+
537
+ def list_uniq(l):
538
+ return sorted(set(l), key=l.index)
539
+
540
+
541
+ def get_status(model_name: str):
542
+ from huggingface_hub import InferenceClient
543
+ client = InferenceClient(timeout=10)
544
+ return client.get_model_status(model_name)
545
+
546
+
547
+ def is_loadable(model_name: str, force_gpu: bool = False):
548
+ try:
549
+ status = get_status(model_name)
550
+ except Exception as e:
551
+ print(e)
552
+ print(f"Couldn't load {model_name}.")
553
+ return False
554
+ gpu_state = isinstance(status.compute_type, dict) and "gpu" in status.compute_type.keys()
555
+ if status is None or status.state not in ["Loadable", "Loaded"] or (force_gpu and not gpu_state):
556
+ print(f"Couldn't load {model_name}. Model state:'{status.state}', GPU:{gpu_state}")
557
+ return status is not None and status.state in ["Loadable", "Loaded"] and (not force_gpu or gpu_state)
558
+
559
+
560
+ def find_model_list(author: str="", tags: list[str]=[], not_tag="", sort: str="last_modified", limit: int=30, force_gpu=False, check_status=False):
561
+ from huggingface_hub import HfApi
562
+ api = HfApi()
563
+ default_tags = ["diffusers"]
564
+ if not sort: sort = "last_modified"
565
+ limit = limit * 20 if check_status and force_gpu else limit * 5
566
+ models = []
567
+ try:
568
+ model_infos = api.list_models(author=author, task="text-to-image",
569
+ tags=list_uniq(default_tags + tags), cardData=True, sort=sort, limit=limit)
570
+ except Exception as e:
571
+ print(f"Error: Failed to list models.")
572
+ print(e)
573
+ return models
574
+ for model in model_infos:
575
+ if not model.private and not model.gated:
576
+ loadable = is_loadable(model.id, force_gpu) if check_status else True
577
+ if not_tag and not_tag in model.tags or not loadable: continue
578
+ models.append(model.id)
579
+ if len(models) == limit: break
580
+ return models