Yntec commited on
Commit
f5b8400
β€’
1 Parent(s): f11f9bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -306
app.py CHANGED
@@ -1,325 +1,89 @@
1
  import gradio as gr
2
- import os
3
- import sys
4
- from pathlib import Path
5
 
6
- models = [
7
- {"name": "Chik 2 (new)", "url": "Yntec/Chik2"}, #224
8
- {"name": "Cute Yuki 2 (new)", "url": "Yntec/CuteYuki2"}, #225
9
- {"name": "Game Assets (new)", "url": "Yntec/GameAssetsDigitalUnitsCreationKit"}, #226
10
- {"name": "Insane.m3u (new)", "url": "Yntec/InsaneM3U"}, #227
11
- {"name": "Insane Realistic Color (new)", "url": "Yntec/InsaneRealisticCVAE"}, #228
12
- {"name": "Luma (new)", "url": "Yntec/Luma"}, #229
13
- {"name": "Lunar Luma (new)", "url": "Yntec/LunarLuma"}, #230
14
- {"name": "Lunar (new)", "url": "Yntec/Lunar"}, #231
15
- {"name": "Noosphere v3 Color (new)", "url": "Yntec/Noosphere_v3_CVAE"}, #232
16
- {"name": "Orange Remix (new)", "url": "Yntec/OrangeRemix"}, #233
17
- {"name": "Peach Mix 3 (new)", "url": "Yntec/PeachMix3"}, #234
18
- {"name": "QTori Reloaded (new)", "url": "Yntec/QToriReloaded"}, #235
19
- {"name": "Real Rainbows (new)", "url": "Yntec/RealRainbows"}, #236
20
- {"name": "RPG Remix (new)", "url": "Yntec/RPG_Remix"}, #237
21
- {"name": "Sexy Toons (new)", "url": "Yntec/sexyToons"}, #238
22
- {"name": "Style Like DucHaiten (new)", "url": "Yntec/DucHaiten-StyleLikeMeVAE"}, #224
23
- {"name": "Children Stories Anime (featured)", "url": "Yntec/ChildrenStoriesAnime"}, #201
24
- {"name": "COOLKIDSV2 (featured)", "url": "Yntec/COOLKIDSV2"}, #202
25
- {"name": "Dream Anything (featured)", "url": "Yntec/DreamAnything"}, #203
26
- {"name": "Dreamlike Anime (featured)", "url": "dreamlike-art/dreamlike-anime-1.0"}, #204
27
- {"name": "Dreamlike Diffusion (featured)", "url": "dreamlike-art/dreamlike-diffusion-1.0"}, #205
28
- {"name": "Dreamlike Photoreal (featured)", "url": "dreamlike-art/dreamlike-photoreal-2.0"}, #206
29
- {"name": "Dreamsphere (featured)", "url": "Yntec/Dreamsphere"}, #207
30
- {"name": "DucHaiten AI Art (featured)", "url": "Yntec/DucHaitenAIart-beta"}, #208
31
- {"name": "DucHaiten Anime (featured)", "url": "Yntec/DucHaitenAnime768"}, #209
32
- {"name": "DucHaiten Classic Anime (featured)", "url": "Yntec/DucHaitenClassicAnime768"}, #210
33
- {"name": "DucHaiten Retro (featured)", "url": "Yntec/DucHaiten-Retro-Diffusers"}, #211
34
- {"name": "Elldreth's Retro Mix (featured)", "url": "Yntec/ElldrethsRetroMix_Diffusers"}, #212
35
- {"name": "Gold Fish (featured)", "url": "Yntec/GOLDFish"}, #213
36
- {"name": "KIDSILLUSTRATIONS (featured)", "url": "Yntec/KIDSILLUSTRATIONS"}, #214
37
- {"name": "Never Existed (featured)", "url": "Yntec/NeverExisted"}, #215
38
- {"name": "Ninja (featured)", "url": "Yntec/Ninja-Diffusers"}, #216
39
- {"name": "Pavo (featured)", "url": "Yntec/Pavo-Mix-Diffusers"}, #217
40
- {"name": "Photosphere (featured)", "url": "Yntec/Photosphere"}, #218
41
- {"name": "Rainbow Classic Anime (featured)", "url": "Yntec/RainbowClassicAnime"}, #219
42
- {"name": "Rainbow Dreams (featured)", "url": "Yntec/RainbowDreams"}, #220
43
- {"name": "Rainbowpatch (featured)", "url": "Yntec/rainbowpatch"}, #221
44
- {"name": "Rainbowsphere (featured)", "url": "Yntec/Rainbowsphere"}, #222
45
- {"name": "The Ally Mix IV (featured)", "url": "Yntec/theallysMixIV-verisimilar"}, #223
46
- {"name": "Western Animation (featured)", "url": "Yntec/WesternAnimation"},
47
- {"name": "YabaL Mix True 2.5D (featured)", "url": "Yntec/yabalMixTrue25D_v2_VAE"},
48
- {"name": "2.5D SET", "url": "digiplay/2.5DSET_diffusers"},
49
- {"name": "2-KWI", "url": "digiplay/2-KWI"},
50
- {"name": "2K", "url": "digiplay/2K"}, #183
51
- {"name": "7 Pa", "url": "AIARTCHAN/7pa"},
52
- {"name": "A Certain Model", "url": "JosephusCheung/ACertainModel"},
53
- {"name": "A Certain Thing", "url": "JosephusCheung/ACertainThing"},
54
- {"name": "A Certainity", "url": "JosephusCheung/ACertainty"},
55
- {"name": "Abyss Hell Hero", "url": "AIARTCHAN/AbyssHellHero"},
56
- {"name": "Abyss Maple 3", "url": "AIARTCHAN/AbyssMapleVer3"},
57
- {"name": "Abyss Orange Mix 2", "url": "WarriorMama777/AbyssOrangeMix2"},
58
- {"name": "Abyss Orange Mix", "url": "WarriorMama777/AbyssOrangeMix"},
59
- {"name": "AbyssHell 3", "url": "AIARTCHAN/AbyssHellVer3"},
60
- {"name": "Alice in Diffusion Land", "url": "Guizmus/SDArt_AliceInDiffusionLand"},
61
- {"name": "All 526 Animated", "url": "stablediffusionapi/all-526-animated"},
62
- {"name": "All 526", "url": "stablediffusionapi/all-526"},
63
- {"name": "AmiIReal", "url": "stablediffusionapi/amireal"},
64
- {"name": "Analog Diffusion", "url": "wavymulder/Analog-Diffusion"},
65
- {"name": "Anidosmix 2", "url": "AIARTCHAN/anidosmixV2"},
66
- {"name": "Anime Kawai Diffusion", "url": "Ojimi/anime-kawai-diffusion"},
67
- {"name": "Anireal 3D V2", "url": "circulus/sd-anireal-3d-v2"},
68
- {"name": "AnyLORA", "url": "kubanemil/AnyLORA"},
69
- {"name": "Anything 3.0 Light", "url": "mm00/anything-v3.0-light"},
70
- {"name": "Anything 3.0", "url": "Linaqruf/anything-v3.0"},
71
- {"name": "Anything 3.1", "url": "cag/anything-v3-1"},
72
- {"name": "Anything 3X", "url": "iZELX1/Anything-V3-X"},
73
- {"name": "Anything 5.0", "url": "stablediffusionapi/anything-v5"},
74
- {"name": "Anything Else 4", "url": "stablediffusionapi/anythingelse-v4"},
75
- {"name": "Anything Midjourney 4.1", "url": "Joeythemonster/anything-midjourney-v-4-1"},
76
- {"name": "Arcane Diffusion", "url": "nitrosocke/Arcane-Diffusion"},
77
- {"name": "Archer Diffusion", "url": "nitrosocke/archer-diffusion"},
78
- {"name": "Asian Mix", "url": "D1b4l4p/AsianMix"},
79
- {"name": "Astro Emeria", "url": "digiplay/alstroemeriaMix_v1"},
80
- {"name": "Balloon Art", "url": "Fictiverse/Stable_Diffusion_BalloonArt_Model"},
81
- {"name": "Blood Orange Mix", "url": "WarriorMama777/BloodOrangeMix"},
82
- {"name": "Blue Pencil Realistic", "url": "digiplay/bluePencilRealistic_v01"},
83
- {"name": "BRA", "url": "digiplay/bra_v40_diffusers"},
84
- {"name": "Brick And Mortar", "url": "digiplay/BrickAndMortarMix_v2.0_diffusers"},
85
- {"name": "Burger Semi", "url": "digiplay/Burger_Mix_semiR2Lite"},
86
- {"name": "Calico Real", "url": "digiplay/calicomixreal_v2.0_diffusers"},
87
- {"name": "CamelliaMix 2.5D","url": "stablediffusionapi/camelliamix25d"},
88
- {"name": "CamelliaMix Line","url": "stablediffusionapi/camelliamixline"},
89
- {"name": "CCTV 2.5D","url": "digiplay/CCTV2.5d_v1"},
90
- {"name": "Chaos and Order", "url": "Guizmus/SDArt_ChaosAndOrder768"},
91
- {"name": "Chillout App Factory","url": "stablediffusionapi/chillout-app-factory"}, #194
92
- {"name": "Chillout Mix","url": "stablediffusionapi/chilloutmixsf"},
93
- {"name": "Chilloutvlara", "url": "Fred99774/chilloutvlara"},
94
- {"name": "Chilly Mix", "url": "digiplay/ChillyMix_v1"},
95
- {"name": "Chrisan The Mum", "url": "digiplay/chrysanthemumMix_v1"}, #190
96
- {"name": "CosF Mix", "url": "digiplay/cosfMix_v1"},
97
- {"name": "Circulus 2.8", "url": "circulus/sd-photoreal-v2.8"},
98
- {"name": "Circulus Photoreal V2", "url": "circulus/sd-photoreal-real-v2"},
99
- {"name": "Circulus Semi Real 2", "url": "circulus/sd-photoreal-semi-v2"},
100
- {"name": "Clam", "url": "Johnhex/Clam"},
101
- {"name": "Classic Anime", "url": "nitrosocke/classic-anim-diffusion"},
102
- {"name": "Claudfuen 1", "url": "claudfuen/photorealistic-fuen-v1"},
103
- {"name": "Cocotifa Cute", "url": "digiplay/cocotifacute_v1"},
104
- {"name": "Collage Diffusion", "url": "wavymulder/collage-diffusion"},
105
- {"name": "Colorful 4.5", "url": "Manseo/Colorful-v4.5-Plus"},
106
- {"name": "Comic Diffusion", "url": "ogkalu/Comic-Diffusion"},
107
- {"name": "Complex-Lineart", "url": "Conflictx/Complex-Lineart"},
108
- {"name": "Cool Japan Diffusion", "url": "aipicasso/cool-japan-diffusion-2-1-2"},
109
- {"name": "Cosmic Babes", "url": "stablediffusionapi/cosmic-babes"},
110
- {"name": "Cosmic Horros 768", "url": "Guizmus/SDArt_cosmichorrors768"},
111
- {"name": "Cosmic Horros", "url": "Guizmus/SDArt_cosmichorrors"},
112
- {"name": "Counterfeit 2.0", "url": "gsdf/Counterfeit-V2.0"},
113
- {"name": "Counterfeit 3.0", "url": "stablediffusionapi/counterfeit-v30"},
114
- {"name": "Curious Merge 2.5D", "url": "digiplay/CuriousMerge2.5D_v5"},
115
- {"name": "Cusp Of Serenity", "url": "stablediffusionapi/cusp-of-serenity"}, #195
116
- {"name": "CounterMix", "url": "digiplay/CounterMix_v2"},
117
- {"name": "CyberPunk Anime", "url": "DGSpitzer/Cyberpunk-Anime-Diffusion"},
118
- {"name": "Cyberrealistic", "url": "stablediffusionapi/cyberrealistic"},
119
- {"name": "Dark Sushi Mix", "url": "stablediffusionapi/dark-sushi-mix"},
120
- {"name": "Dash Sushi 25d", "url": "stablediffusionapi/dark-sushi-25d"},
121
- {"name": "Defacta", "url": "digiplay/Defacta_v1_diffusers"}, #191
122
- {"name": "Deliberate", "url": "Masagin/Deliberate"},
123
- {"name": "Deliberate App Factory", "url": "stablediffusionapi/deliberateappfactory"},
124
- {"name": "DGSpitzer", "url": "DGSpitzer/DGSpitzer-Art-Diffusion"},
125
- {"name": "DosMix", "url": "digiplay/dosmix"},
126
- {"name": "Double Exposure Diffusion", "url": "joachimsallstrom/Double-Exposure-Diffusion"},
127
- {"name": "Dreamful 2", "url": "Hius/DreamFul-V2"},
128
- {"name": "Dreamshaper", "url": "Lykon/DreamShaper"},
129
- {"name": "Dreamshaper 6", "url": "stablediffusionapi/dreamshaper-v6"}, #199
130
- {"name": "DucHaiten Anime 512x512", "url": "DucHaiten/DucHaitenAnime"},
131
- {"name": "DucHaiten AI Art 512x512", "url": "DucHaiten/DucHaitenAIart"},
132
- {"name": "DucHaiten ClassicAnime 512x512", "url": "DucHaiten/DH_ClassicAnime"},
133
- {"name": "DucHaiten DreamWorld", "url": "DucHaiten/DucHaitenDreamWorld"},
134
- {"name": "DucHaiten Journey", "url": "DucHaiten/DucHaitenJourney"},
135
- {"name": "DucHaiten StyleLikeMe", "url": "DucHaiten/DucHaiten-StyleLikeMe"},
136
- {"name": "DucHaiten SuperCute", "url": "DucHaiten/DucHaitenSuperCute"},
137
- {"name": "Duel Anime", "url": "digiplay/DuelAnimeMix_v1"},
138
- {"name": "Dungeons and Diffusion", "url": "0xJustin/Dungeons-and-Diffusion"},
139
- {"name": "Eerie Orange Mix", "url": "WarriorMama777/EerieOrangeMix"},
140
- {"name": "Eimis Anime Diffusion", "url": "eimiss/EimisAnimeDiffusion_1.0v"},
141
- {"name": "Elden Ring", "url": "nitrosocke/elden-ring-diffusion"},
142
- {"name": "Elegant Entropy", "url": "digiplay/elegantEntropy_v1.1"},
143
- {"name": "Epic Diffusion 1.1", "url": "johnslegers/epic-diffusion-v1.1"},
144
- {"name": "Epic Diffusion", "url": "johnslegers/epic-diffusion"},
145
- {"name": "EpicMix Realism", "url": "Duskfallcrew/EpicMix_Realism"},
146
- {"name": "Epi PhotoGodess", "url": "digiplay/epi_2.5Dphotogodess_diffusers"},
147
- {"name": "Fantastic Anime", "url": "digiplay/fantasticAnime_diffusers"},
148
- {"name": "FanTexi", "url": "digiplay/fantexi_v0.7"},
149
- {"name": "Fantasy Mix", "url": "theintuitiveye/FantasyMix"},
150
- {"name": "Fluid Art", "url": "Fictiverse/Stable_Diffusion_FluidArt_Model"},
151
- {"name": "Form Cleansing", "url": "digiplay/FormCleansingMix_v1"},
152
- {"name": "Future Diffusion", "url": "nitrosocke/Future-Diffusion"},
153
- {"name": "Gakki Mix 768", "url": "Sa1i/gakki-mix-768"},
154
- {"name": "Ghibli Diffusion", "url": "nitrosocke/Ghibli-Diffusion"},
155
- {"name": "Girl New 1", "url": "Fred99774/girlnew1"},
156
- {"name": "Grimoeresigils", "url": "ECarbenia/grimoiresigils"},
157
- {"name": "GTA5 Artwork Diffusion", "url": "ItsJayQz/GTA5_Artwork_Diffusion"},
158
- {"name": "GuoFeng 3", "url": "xiaolxl/GuoFeng3"},
159
- {"name": "HARDBlend", "url": "theintuitiveye/HARDblend"},
160
- {"name": "HassanBlend 1.4", "url": "hassanblend/hassanblend1.4"},
161
- {"name": "HassanBlend 256x256", "url": "hassanblend/HassanBlend1.5.1.2"},
162
- {"name": "Hodge Podge", "url": "digiplay/Hodgepodge_v2.1"},
163
- {"name": "Hrrzg Style 768px", "url": "TheLastBen/hrrzg-style-768px"},
164
- {"name": "Icomix 2", "url": "stablediffusionapi/icomix-2"},
165
- {"name": "Illustro", "url": "digiplay/illustro1stEdition_illustroV1"},
166
- {"name": "InkPunk Diffusion", "url": "Envvi/Inkpunk-Diffusion"},
167
- {"name": "JWST Deep Space Diffusion", "url": "dallinmackay/JWST-Deep-Space-diffusion"},
168
- {"name": "KencanMix", "url": "digiplay/kencanmix_v2.0beta"},
169
- {"name": "KotosMix", "url": "digiplay/kotosmix_diffusers"}, #193
170
- {"name": "Lomo Diffusion", "url": "wavymulder/lomo-diffusion"},
171
- {"name": "Luna Diffusion 256x256", "url": "proximasanfinetuning/luna-diffusion"},
172
- {"name": "Majic Mix Fantasy", "url": "stablediffusionapi/majicmixfantasy"},
173
- {"name": "Majic Mix Realistic", "url": "stablediffusionapi/majicmixrealistic"},
174
- {"name": "Majic Mix Sombre", "url": "stablediffusionapi/majicmixsombre"},
175
- {"name": "Marvel WhatIf Diffusion", "url": "ItsJayQz/Marvel_WhatIf_Diffusion"},
176
- {"name": "Meina Alter", "url": "stablediffusionapi/meinaalter"},
177
- {"name": "Meina Pastel", "url": "stablediffusionapi/meinapastel"},
178
- {"name": "MeinaMix 7", "url": "Nacholmo/meinamixv7-diffusers"},
179
- {"name": "Myne Factory Base", "url": "MyneFactory/MF-Base"},
180
- {"name": "Microscopic Model", "url": "Fictiverse/Stable_Diffusion_Microscopic_model"},
181
- {"name": "Midjourney 4.0", "url": "prompthero/midjourney-v4-diffusion"},
182
- {"name": "Mix Pro V4", "url": "AIARTCHAN/MIX-Pro-V4"},
183
- {"name": "Model Shoot", "url": "wavymulder/modelshoot"},
184
- {"name": "Mo-Di Diffusion", "url": "nitrosocke/mo-di-diffusion"},
185
- {"name": "Naruto Diffuser", "url": "lambdalabs/sd-naruto-diffusers"},
186
- {"name": "Never Ending Dream 2", "url": "luongphamit/NeverEnding-Dream2"},
187
- {"name": "NeverEnding-Dream", "url": "Lykon/NeverEnding-Dream"},
188
- {"name": "Nitro Diffusion", "url": "nitrosocke/Nitro-Diffusion"},
189
- {"name": "NK15", "url": "digiplay/nk15_diffusers"},
190
- {"name": "Openjourney 2", "url": "PeggyWang/openjourney-v2",}, #197
191
- {"name": "Openjourney 4", "url": "prompthero/openjourney-v4"},
192
- {"name": "Openjourney", "url": "prompthero/openjourney"},
193
- {"name": "OpenNiji", "url": "Korakoe/OpenNiji"},
194
- {"name": "Paint Journey", "url": "FredZhang7/paint-journey-v2"}, #196
195
- {"name": "Papercut", "url": "Fictiverse/Stable_Diffusion_PaperCut_Model"},
196
- {"name": "Picasso Diffusion 1.1", "url": "aipicasso/picasso-diffusion-1-1"},
197
- {"name": "Plat Diffusion 256x256", "url": "p1atdev/plat-diffusion"},
198
- {"name": "Pokemon Diffuser", "url": "lambdalabs/sd-pokemon-diffusers"},
199
- {"name": "Portrait Plus", "url": "wavymulder/portraitplus"},
200
- {"name": "Protogen 2.2", "url": "darkstorm2150/Protogen_v2.2_Official_Release"},
201
- {"name": "Protogen Infinity", "url": "darkstorm2150/Protogen_Infinity_Official_Release"},
202
- {"name": "Protogen X 3.4", "url": "darkstorm2150/Protogen_x3.4_Official_Release"},
203
- {"name": "Protogen X 5.8", "url": "darkstorm2150/Protogen_x5.8_Official_Release"},
204
- {"name": "QuinceMix", "url": "Hemlok/QuinceMix"},
205
- {"name": "Realistic Vision 1.4", "url": "SG161222/Realistic_Vision_V1.4"},
206
- {"name": "Redshift Diffusion 768", "url": "nitrosocke/redshift-diffusion-768"},
207
- {"name": "Redshift Diffusion", "url": "nitrosocke/redshift-diffusion"},
208
- {"name": "Rev Anim", "url": "stablediffusionapi/rev-anim"},
209
- {"name": "Rev Animated", "url": "LottePeisch/RevAnimated-Diffusers"},
210
- {"name": "Robo Diffusion 2 Base", "url": "nousr/robo-diffusion-2-base"},
211
- {"name": "Robo Diffusion", "url": "nousr/robo-diffusion"},
212
- {"name": "Seek Art Mega", "url": "coreco/seek.art_MEGA"},
213
- {"name": "Semi Real Mix", "url": "robotjung/SemiRealMix"},
214
- {"name": "Short Journey", "url": "x67/shortjourney"}, #198
215
- {"name": "Something V 2.2","url": "NoCrypt/SomethingV2_2"},
216
- {"name": "Something V2","url": "NoCrypt/SomethingV2"},
217
- {"name": "Something", "url": "Guizmus/SDArt_something"},
218
- {"name": "Spider Verse diffusion", "url": "nitrosocke/spider-verse-diffusion"},
219
- {"name": "SpyBG", "url": "stablediffusionapi/spybg"},
220
- {"name": "Stable Diffusion 1.4","url": "CompVis/stable-diffusion-v1-4"},
221
- {"name": "Stable Diffusion 1.5","url": "runwayml/stable-diffusion-v1-5"},
222
- {"name": "Stable Diffusion 2.1 Base","url": "stabilityai/stable-diffusion-2-1-base"},
223
- {"name": "Stable Diffusion 2.1 Unclip","url": "stabilityai/stable-diffusion-2-1-unclip"},
224
- {"name": "Stable Diffusion 2.1","url": "stabilityai/stable-diffusion-2-1"},
225
- {"name": "Subtly", "url": "ddPn08/subtly"},
226
- {"name": "Synthwave Punk 2", "url": "ItsJayQz/SynthwavePunk-v2"},
227
- {"name": "The Ally", "url": "stablediffusionapi/the-ally"},
228
- {"name": "Three Delicacy", "url": "stablediffusionapi/three-delicacy"},
229
- {"name": "Three Delicacy wonto", "url": "stablediffusionapi/three-delicacy-wonto"},
230
- {"name": "Timeless Diffusion", "url": "wavymulder/timeless-diffusion"},
231
- {"name": "TMND mix", "url": "stablediffusionapi/tmnd-mix"},
232
- {"name": "Tron Legacy Diffusion", "url": "dallinmackay/Tron-Legacy-diffusion"},
233
- {"name": "UltraSkin 256x256", "url": "VegaKH/Ultraskin"},
234
- {"name": "Valorant Diffusion", "url": "ItsJayQz/Valorant_Diffusion"},
235
- {"name": "Van Gogh Diffusion", "url": "dallinmackay/Van-Gogh-diffusion"},
236
- {"name": "Vectorartz Diffusion", "url": "coder119/Vectorartz_Diffusion"},
237
- {"name": "Vintedois 1.0", "url": "22h/vintedois-diffusion-v0-1"},
238
- {"name": "Vivid Watercolors", "url": "Evel/VividWatercolors"},
239
- {"name": "VoxelArt", "url": "Fictiverse/Stable_Diffusion_VoxelArt_Model"},
240
- {"name": "Waifu Diffusion", "url": "hakurei/waifu-diffusion"},
241
- {"name": "Wavyfusion", "url": "wavymulder/wavyfusion"},
242
- {"name": "White Dreamy Hill", "url": "digiplay/WhiteDreamyHillMix_v1"},
243
- ]
244
 
245
- current_model = models[0]
246
 
247
- text_gen = gr.Interface.load("spaces/daspartho/prompt-extend")
248
-
249
- models2 = []
250
- for model in models:
251
- model_url = f"models/{model['url']}"
252
- loaded_model = gr.Interface.load(model_url, live=True, preprocess=True)
253
- models2.append(loaded_model)
 
 
 
 
254
 
255
 
256
- def text_it(inputs, text_gen=text_gen):
257
- return text_gen(inputs)
258
 
259
 
260
- def set_model(current_model_index):
261
- global current_model
262
- current_model = models[current_model_index]
263
- return gr.update(value=f"{current_model['name']}")
264
 
265
 
266
- def send_it(inputs, model_choice):
267
- proc = models2[model_choice]
268
- return proc(inputs)
269
 
 
 
270
 
271
- with gr.Blocks() as myface:
272
- gr.HTML(
273
 
274
- )
 
 
275
 
276
- with gr.Row():
277
- with gr.Row():
278
- input_text = gr.Textbox(label="Prompt Idea", placeholder="", lines=1)
279
- # Model selection dropdown
280
- model_name1 = gr.Dropdown(
281
- label="Choose Model (Ignore the errors, all work)",
282
- choices=[m["name"] for m in models],
283
- type="index",
284
- value=current_model["name"],
285
- interactive=True,
286
- )
287
- with gr.Row():
288
- see_prompts = gr.Button("Generate Prompts Based On Prompt Idea")
289
- run = gr.Button("Generate 6 Images (once all boxes below have prompts)", variant="primary")
290
 
291
- with gr.Row():
292
- output1 = gr.Image(label="")
293
- output2 = gr.Image(label="")
294
- output3 = gr.Image(label="")
295
- with gr.Row():
296
- magic1 = gr.Textbox(label="Generated Prompt", lines=2)
297
- magic2 = gr.Textbox(label="Generated Prompt", lines=2)
298
- magic3 = gr.Textbox(label="Generated Prompt", lines=2)
299
- with gr.Row():
300
- output4 = gr.Image(label="")
301
- output5 = gr.Image(label="")
302
- output6 = gr.Image(label="")
303
- with gr.Row():
304
- magic4 = gr.Textbox(label="Generated Prompt", lines=2)
305
- magic5 = gr.Textbox(label="Generated Prompt", lines=2)
306
- magic6 = gr.Textbox(label="Generated Prompt", lines=2)
307
 
308
- model_name1.change(set_model, inputs=model_name1, outputs=[output1, output2, output3, output4, output5, output6])
309
 
310
- run.click(send_it, inputs=[magic1, model_name1], outputs=[output1])
311
- run.click(send_it, inputs=[magic2, model_name1], outputs=[output2])
312
- run.click(send_it, inputs=[magic3, model_name1], outputs=[output3])
313
- run.click(send_it, inputs=[magic4, model_name1], outputs=[output4])
314
- run.click(send_it, inputs=[magic5, model_name1], outputs=[output5])
315
- run.click(send_it, inputs=[magic6, model_name1], outputs=[output6])
316
 
317
- see_prompts.click(text_it, inputs=[input_text], outputs=[magic1])
318
- see_prompts.click(text_it, inputs=[input_text], outputs=[magic2])
319
- see_prompts.click(text_it, inputs=[input_text], outputs=[magic3])
320
- see_prompts.click(text_it, inputs=[input_text], outputs=[magic4])
321
- see_prompts.click(text_it, inputs=[input_text], outputs=[magic5])
322
- see_prompts.click(text_it, inputs=[input_text], outputs=[magic6])
323
 
324
- myface.queue(concurrency_count=200)
325
- myface.launch(inline=True, show_api=False, max_threads=400)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from random import randint
3
+ from all_models import models
 
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
 
6
 
7
+ def load_fn(models):
8
+ global models_load
9
+ models_load = {}
10
+
11
+ for model in models:
12
+ if model not in models_load.keys():
13
+ try:
14
+ m = gr.load(f'models/{model}')
15
+ except Exception as error:
16
+ m = gr.Interface(lambda txt: None, ['text'], ['image'])
17
+ models_load.update({model: m})
18
 
19
 
20
+ load_fn(models)
 
21
 
22
 
23
+ num_models = 6
24
+ default_models = models[:num_models]
 
 
25
 
26
 
 
 
 
27
 
28
+ def extend_choices(choices):
29
+ return choices + (num_models - len(choices)) * ['NA']
30
 
 
 
31
 
32
+ def update_imgbox(choices):
33
+ choices_plus = extend_choices(choices)
34
+ return [gr.Image(None, label = m, visible = (m != 'NA')) for m in choices_plus]
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ def gen_fn(model_str, prompt):
38
+ if model_str == 'NA':
39
+ return None
40
+ noise = str(randint(0, 99999999999))
41
+ return models_load[model_str](f'{prompt} {noise}')
 
 
 
 
 
 
 
 
 
 
 
42
 
 
43
 
 
 
 
 
 
 
44
 
45
+ with gr.Blocks() as demo:
46
+ with gr.Tab('Multiple models'):
47
+ with gr.Accordion('Model selection'):
48
+ model_choice = gr.CheckboxGroup(models, label = f'Choose up to {num_models} different models', value = default_models, multiselect = True, max_choices = num_models, interactive = True, filterable = False)
 
 
49
 
50
+ txt_input = gr.Textbox(label = 'Prompt text')
51
+ gen_button = gr.Button('Generate')
52
+ stop_button = gr.Button('Stop', variant = 'secondary', interactive = False)
53
+ gen_button.click(lambda s: gr.update(interactive = True), None, stop_button)
54
+
55
+ with gr.Row():
56
+ output = [gr.Image(label = m) for m in default_models]
57
+ current_models = [gr.Textbox(m, visible = False) for m in default_models]
58
+
59
+ model_choice.change(update_imgbox, model_choice, output)
60
+ model_choice.change(extend_choices, model_choice, current_models)
61
+
62
+ for m, o in zip(current_models, output):
63
+ gen_event = gen_button.click(gen_fn, [m, txt_input], o)
64
+ stop_button.click(lambda s: gr.update(interactive = False), None, stop_button, cancels = [gen_event])
65
+
66
+
67
+ with gr.Tab('Single model'):
68
+ model_choice2 = gr.Dropdown(models, label = 'Choose model', value = models[0], filterable = False)
69
+ txt_input2 = gr.Textbox(label = 'Prompt text')
70
+
71
+ max_images = 6
72
+ num_images = gr.Slider(1, max_images, value = max_images, step = 1, label = 'Number of images')
73
+
74
+ gen_button2 = gr.Button('Generate')
75
+ stop_button2 = gr.Button('Stop', variant = 'secondary', interactive = False)
76
+ gen_button2.click(lambda s: gr.update(interactive = True), None, stop_button2)
77
+
78
+ with gr.Row():
79
+ output2 = [gr.Image(label = '') for _ in range(max_images)]
80
+
81
+ for i, o in enumerate(output2):
82
+ img_i = gr.Number(i, visible = False)
83
+ num_images.change(lambda i, n: gr.update(visible = (i < n)), [img_i, num_images], o)
84
+ gen_event2 = gen_button2.click(lambda i, n, m, t: gen_fn(m, t) if (i < n) else None, [img_i, num_images, model_choice2, txt_input2], o)
85
+ stop_button2.click(lambda s: gr.update(interactive = False), None, stop_button2, cancels = [gen_event2])
86
+
87
+
88
+ demo.queue(concurrency_count = 200)
89
+ demo.launch()