Nymbo commited on
Commit
872bd27
·
verified ·
1 Parent(s): 7f9b67f

adding Replicate and Fal as inference providers

Browse files
Files changed (1) hide show
  1. app.py +313 -357
app.py CHANGED
@@ -1,26 +1,20 @@
1
- import gradio as gr
2
- import requests
3
  import io
4
  import random
5
  import os
6
  import time
7
  from PIL import Image
8
  import json
 
9
 
10
  # Project by Nymbo
11
 
12
- # Base API URL for Hugging Face inference
13
- API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
14
- # Retrieve the API token from environment variables
15
- API_TOKEN = os.getenv("HF_READ_TOKEN")
16
- headers = {"Authorization": f"Bearer {API_TOKEN}"}
17
- # Timeout for requests
18
- timeout = 100
19
-
20
- def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, width=1024, height=1024):
21
- # Debug log to indicate function start
22
- print("Starting query function...")
23
- # Print the parameters for debugging purposes
24
  print(f"Prompt: {prompt}")
25
  print(f"Model: {model}")
26
  print(f"Custom LoRA: {custom_lora}")
@@ -28,358 +22,320 @@ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7,
28
 
29
  # Check if the prompt is empty or None
30
  if prompt == "" or prompt is None:
31
- print("Prompt is empty or None. Exiting query function.") # Debug log
32
  return None
33
 
34
  # Generate a unique key for tracking the generation process
35
  key = random.randint(0, 999)
36
- print(f"Generated key: {key}") # Debug log
37
-
38
- # Randomly select an API token from available options to distribute the load
39
- API_TOKEN = random.choice([os.getenv("HF_READ_TOKEN"), os.getenv("HF_READ_TOKEN_2"), os.getenv("HF_READ_TOKEN_3"), os.getenv("HF_READ_TOKEN_4"), os.getenv("HF_READ_TOKEN_5")])
40
- headers = {"Authorization": f"Bearer {API_TOKEN}"}
41
- print(f"Selected API token: {API_TOKEN}") # Debug log
42
 
43
  # Enhance the prompt with additional details for better quality
44
- prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
45
- print(f'Generation {key}: {prompt}') # Debug log
46
-
47
- # Set the API URL based on the selected model or custom LoRA
48
- if custom_lora.strip() != "":
49
- API_URL = f"https://api-inference.huggingface.co/models/{custom_lora.strip()}"
50
- else:
51
- if model == 'Stable Diffusion XL':
52
- API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
53
- if model == 'FLUX.1 [Dev]':
54
- API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
55
- if model == 'FLUX.1 [Schnell]':
56
- API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
57
- if model == 'HiDream-I1-Full':
58
- API_URL = "https://api-inference.huggingface.co/models/HiDream-ai/HiDream-I1-Full"
59
- if model == 'HiDream-I1-Dev':
60
- API_URL = "https://api-inference.huggingface.co/models/HiDream-ai/HiDream-I1-Dev"
61
- if model == 'HiDream-I1-Fast':
62
- API_URL = "https://api-inference.huggingface.co/models/HiDream-ai/HiDream-I1-Fast"
63
- if model == 'Animagine 4.0':
64
- API_URL = "https://api-inference.huggingface.co/models/cagliostrolab/animagine-xl-4.0"
65
- prompt = f"masterpiece, high score, great score, absurdres, {prompt}"
66
- if model == 'Flux Icon Kit':
67
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Icon-Kit-LoRA"
68
- prompt = f"Icon Kit, {prompt}"
69
- if model == 'Pixel Background':
70
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Pixel-Background-LoRA"
71
- prompt = f"Pixel Background, {prompt}"
72
- if model == 'Meme XD':
73
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Flux-Meme-Xd-LoRA"
74
- prompt = f"meme, {prompt}"
75
- if model == 'Chill Guy':
76
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Flux-Chill-Guy-Zone"
77
- prompt = f"chill guy, {prompt}"
78
- if model == 'Pepe':
79
- API_URL = "https://api-inference.huggingface.co/models/openfree/pepe"
80
- prompt = f"pepe, {prompt}"
81
- if model == 'NSFWmodel':
82
- API_URL = "https://api-inference.huggingface.co/models/lexa862/NSFWmodel"
83
- prompt = f"nude, {prompt}"
84
- if model == 'Claude Art':
85
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Claude-Art"
86
- prompt = f"claude art, {prompt}"
87
- if model == 'Open Genmoji':
88
- API_URL = "https://api-inference.huggingface.co/models/EvanZhouDev/open-genmoji"
89
- prompt = f"emoji, {prompt}"
90
- if model == 'EBook Creative Cover':
91
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/EBook-Creative-Cover-Flux-LoRA"
92
- prompt = f"EBook Cover, {prompt}"
93
- if model == 'Flux Logo Design 2':
94
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Logo-Design-Flux-LoRA"
95
- prompt = f"Logo Design, {prompt}"
96
- if model == 'Isometric 3D':
97
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Isometric-3D-LoRA"
98
- prompt = f"Isometric 3D, {prompt}"
99
- if model == 'Flux Condensation':
100
- API_URL = "https://api-inference.huggingface.co/models/fofr/flux-condensation"
101
- prompt = f"CONDENSATION, {prompt}"
102
- if model == 'Flux Handwriting':
103
- API_URL = "https://api-inference.huggingface.co/models/fofr/flux-handwriting"
104
- prompt = f"HWRIT handwriting, {prompt}"
105
- if model == 'Shou Xin':
106
- API_URL = "https://api-inference.huggingface.co/models/Datou1111/shou_xin"
107
- prompt = f"shou_xin, pencil sketch, {prompt}"
108
- if model == 'Sketch Smudge':
109
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Sketch-Smudge-LoRA"
110
- prompt = f"Sketch Smudge, {prompt}"
111
- if model == '80s Cyberpunk':
112
- API_URL = "https://api-inference.huggingface.co/models/fofr/flux-80s-cyberpunk"
113
- prompt = f"80s cyberpunk, {prompt}"
114
- if model == 'Coloring Book Flux':
115
- API_URL = "https://api-inference.huggingface.co/models/renderartist/coloringbookflux"
116
- prompt = f"c0l0ringb00k, coloring book, coloring book page, {prompt}"
117
- if model == 'Flux Miniature LoRA':
118
- API_URL = "https://api-inference.huggingface.co/models/gokaygokay/Flux-Miniature-LoRA"
119
- prompt = f"MNTR, miniature drawing, {prompt}"
120
- if model == 'Sketch Paint':
121
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Sketch-Paint"
122
- prompt = f"Sketch paint, {prompt}"
123
- if model == 'Flux UltraRealism 2.0':
124
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0"
125
- prompt = f"Ultra realistic, {prompt}"
126
- if model == 'Midjourney Mix':
127
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Midjourney-Mix-LoRA"
128
- prompt = f"midjourney mix, {prompt}"
129
- if model == 'Midjourney Mix 2':
130
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Midjourney-Mix2-LoRA"
131
- prompt = f"MJ v6, {prompt}"
132
- if model == 'Flux Logo Design':
133
- API_URL = "https://api-inference.huggingface.co/models/Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design"
134
- prompt = f"wablogo, logo, Minimalist, {prompt}"
135
- if model == 'Flux Uncensored':
136
- API_URL = "https://api-inference.huggingface.co/models/enhanceaiteam/Flux-uncensored"
137
- if model == 'Flux Uncensored V2':
138
- API_URL = "https://api-inference.huggingface.co/models/enhanceaiteam/Flux-Uncensored-V2"
139
- if model == 'Flux Tarot Cards':
140
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Ton618-Tarot-Cards-Flux-LoRA"
141
- prompt = f"Tarot card, {prompt}"
142
- if model == 'Pixel Art Sprites':
143
- API_URL = "https://api-inference.huggingface.co/models/sWizad/pokemon-trainer-sprites-pixelart-flux"
144
- prompt = f"a pixel image, {prompt}"
145
- if model == '3D Sketchfab':
146
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Castor-3D-Sketchfab-Flux-LoRA"
147
- prompt = f"3D Sketchfab, {prompt}"
148
- if model == 'Retro Comic Flux':
149
- API_URL = "https://api-inference.huggingface.co/models/renderartist/retrocomicflux"
150
- prompt = f"c0m1c, comic book panel, {prompt}"
151
- if model == 'Caricature':
152
- API_URL = "https://api-inference.huggingface.co/models/TheAwakenOne/caricature"
153
- prompt = f"CCTUR3, {prompt}"
154
- if model == 'Huggieverse':
155
- API_URL = "https://api-inference.huggingface.co/models/Chunte/flux-lora-Huggieverse"
156
- prompt = f"HGGRE, {prompt}"
157
- if model == 'Propaganda Poster':
158
- API_URL = "https://api-inference.huggingface.co/models/AlekseyCalvin/Propaganda_Poster_Schnell_by_doctor_diffusion"
159
- prompt = f"propaganda poster, {prompt}"
160
- if model == 'Flux Game Assets V2':
161
- API_URL = "https://api-inference.huggingface.co/models/gokaygokay/Flux-Game-Assets-LoRA-v2"
162
- prompt = f"wbgmsst, white background, {prompt}"
163
- if model == 'SDXL HS Card Style':
164
- API_URL = "https://api-inference.huggingface.co/models/Norod78/sdxl-hearthstone-card-style-lora"
165
- prompt = f"Hearthstone Card, {prompt}"
166
- if model == 'SLDR FLUX NSFW v2 Studio':
167
- API_URL = "https://api-inference.huggingface.co/models/xey/sldr_flux_nsfw_v2-studio"
168
- if model == 'SoftPasty Flux':
169
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/softpasty-flux-dev"
170
- prompt = f"araminta_illus illustration style, {prompt}"
171
- if model == 'Flux Stickers':
172
- API_URL = "https://api-inference.huggingface.co/models/diabolic6045/Flux_Sticker_Lora"
173
- prompt = f"5t1cker 5ty1e, {prompt}"
174
- if model == 'Flux Animex V2':
175
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Animex-v2-LoRA"
176
- prompt = f"Animex, {prompt}"
177
- if model == 'Flux Animeo V1':
178
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Animeo-v1-LoRA"
179
- prompt = f"Animeo, {prompt}"
180
- if model == 'Movie Board':
181
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Flux.1-Dev-Movie-Boards-LoRA"
182
- prompt = f"movieboard, {prompt}"
183
- if model == 'Purple Dreamy':
184
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Purple-Dreamy-Flux-LoRA"
185
- prompt = f"Purple Dreamy, {prompt}"
186
- if model == 'PS1 Style Flux':
187
- API_URL = "https://api-inference.huggingface.co/models/veryVANYA/ps1-style-flux"
188
- prompt = f"ps1 game screenshot, {prompt}"
189
- if model == 'Softserve Anime':
190
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/softserve_anime"
191
- prompt = f"sftsrv style illustration, {prompt}"
192
- if model == 'Flux Tarot v1':
193
- API_URL = "https://api-inference.huggingface.co/models/multimodalart/flux-tarot-v1"
194
- prompt = f"in the style of TOK a trtcrd tarot style, {prompt}"
195
- if model == 'Half Illustration':
196
- API_URL = "https://api-inference.huggingface.co/models/davisbro/half_illustration"
197
- prompt = f"in the style of TOK, {prompt}"
198
- if model == 'OpenDalle v1.1':
199
- API_URL = "https://api-inference.huggingface.co/models/dataautogpt3/OpenDalleV1.1"
200
- if model == 'Flux Ghibsky Illustration':
201
- API_URL = "https://api-inference.huggingface.co/models/aleksa-codes/flux-ghibsky-illustration"
202
- prompt = f"GHIBSKY style, {prompt}"
203
- if model == 'Flux Koda':
204
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/flux-koda"
205
- prompt = f"flmft style, {prompt}"
206
- if model == 'Soviet Diffusion XL':
207
- API_URL = "https://api-inference.huggingface.co/models/openskyml/soviet-diffusion-xl"
208
- prompt = f"soviet poster, {prompt}"
209
- if model == 'Flux Realism LoRA':
210
- API_URL = "https://api-inference.huggingface.co/models/XLabs-AI/flux-RealismLora"
211
- if model == 'Frosting Lane Flux':
212
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/frosting_lane_flux"
213
- prompt = f"frstingln illustration, {prompt}"
214
- if model == 'Phantasma Anime':
215
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/phantasma-anime"
216
- if model == 'Boreal':
217
- API_URL = "https://api-inference.huggingface.co/models/kudzueye/Boreal"
218
- prompt = f"photo, {prompt}"
219
- if model == 'How2Draw':
220
- API_URL = "https://api-inference.huggingface.co/models/glif/how2draw"
221
- prompt = f"How2Draw, {prompt}"
222
- if model == 'Flux AestheticAnime':
223
- API_URL = "https://api-inference.huggingface.co/models/dataautogpt3/FLUX-AestheticAnime"
224
- if model == 'Fashion Hut Modeling LoRA':
225
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Fashion-Hut-Modeling-LoRA"
226
- prompt = f"Modeling of, {prompt}"
227
- if model == 'Flux SyntheticAnime':
228
- API_URL = "https://api-inference.huggingface.co/models/dataautogpt3/FLUX-SyntheticAnime"
229
- prompt = f"1980s anime screengrab, VHS quality, syntheticanime, {prompt}"
230
- if model == 'Flux Midjourney Anime':
231
- API_URL = "https://api-inference.huggingface.co/models/brushpenbob/flux-midjourney-anime"
232
- prompt = f"egmid, {prompt}"
233
- if model == 'Coloring Book Generator':
234
- API_URL = "https://api-inference.huggingface.co/models/robert123231/coloringbookgenerator"
235
- if model == 'Collage Flux':
236
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Castor-Collage-Dim-Flux-LoRA"
237
- prompt = f"collage, {prompt}"
238
- if model == 'Flux Product Ad Backdrop':
239
- API_URL = "https://api-inference.huggingface.co/models/prithivMLmods/Flux-Product-Ad-Backdrop"
240
- prompt = f"Product Ad, {prompt}"
241
- if model == 'Product Design':
242
- API_URL = "https://api-inference.huggingface.co/models/multimodalart/product-design"
243
- prompt = f"product designed by prdsgn, {prompt}"
244
- if model == '90s Anime Art':
245
- API_URL = "https://api-inference.huggingface.co/models/glif/90s-anime-art"
246
- if model == 'Brain Melt Acid Art':
247
- API_URL = "https://api-inference.huggingface.co/models/glif/Brain-Melt-Acid-Art"
248
- prompt = f"maximalism, in an acid surrealism style, {prompt}"
249
- if model == 'Lustly Flux Uncensored v1':
250
- API_URL = "https://api-inference.huggingface.co/models/lustlyai/Flux_Lustly.ai_Uncensored_nsfw_v1"
251
- if model == 'NSFW Master Flux':
252
- API_URL = "https://api-inference.huggingface.co/models/Keltezaa/NSFW_MASTER_FLUX"
253
- prompt = f"NSFW, {prompt}"
254
- if model == 'Flux Outfit Generator':
255
- API_URL = "https://api-inference.huggingface.co/models/tryonlabs/FLUX.1-dev-LoRA-Outfit-Generator"
256
- if model == 'Midjourney':
257
- API_URL = "https://api-inference.huggingface.co/models/Jovie/Midjourney"
258
- if model == 'DreamPhotoGASM':
259
- API_URL = "https://api-inference.huggingface.co/models/Yntec/DreamPhotoGASM"
260
- if model == 'Flux Super Realism LoRA':
261
- API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Super-Realism-LoRA"
262
- if model == 'Stable Diffusion 2-1':
263
- API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1-base"
264
- if model == 'Stable Diffusion 3.5 Large':
265
- API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3.5-large"
266
- if model == 'Stable Diffusion 3.5 Large Turbo':
267
- API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3.5-large-turbo"
268
- if model == 'Stable Diffusion 3 Medium':
269
- API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3-medium-diffusers"
270
- prompt = f"A, {prompt}"
271
- if model == 'Duchaiten Real3D NSFW XL':
272
- API_URL = "https://api-inference.huggingface.co/models/stablediffusionapi/duchaiten-real3d-nsfw-xl"
273
- if model == 'Pixel Art XL':
274
- API_URL = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
275
- prompt = f"pixel art, {prompt}"
276
- if model == 'Character Design':
277
- API_URL = "https://api-inference.huggingface.co/models/KappaNeuro/character-design"
278
- prompt = f"Character Design, {prompt}"
279
- if model == 'Sketched Out Manga':
280
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/sketchedoutmanga"
281
- prompt = f"daiton, {prompt}"
282
- if model == 'Archfey Anime':
283
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/archfey_anime"
284
- if model == 'Lofi Cuties':
285
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/lofi-cuties"
286
- if model == 'YiffyMix':
287
- API_URL = "https://api-inference.huggingface.co/models/Yntec/YiffyMix"
288
- if model == 'Analog Madness Realistic v7':
289
- API_URL = "https://api-inference.huggingface.co/models/digiplay/AnalogMadness-realistic-model-v7"
290
- if model == 'Selfie Photography':
291
- API_URL = "https://api-inference.huggingface.co/models/artificialguybr/selfiephotographyredmond-selfie-photography-lora-for-sdxl"
292
- prompt = f"instagram model, discord profile picture, {prompt}"
293
- if model == 'Filmgrain':
294
- API_URL = "https://api-inference.huggingface.co/models/artificialguybr/filmgrain-redmond-filmgrain-lora-for-sdxl"
295
- prompt = f"Film Grain, FilmGrainAF, {prompt}"
296
- if model == 'Leonardo AI Style Illustration':
297
- API_URL = "https://api-inference.huggingface.co/models/goofyai/Leonardo_Ai_Style_Illustration"
298
- prompt = f"leonardo style, illustration, vector art, {prompt}"
299
- if model == 'Cyborg Style XL':
300
- API_URL = "https://api-inference.huggingface.co/models/goofyai/cyborg_style_xl"
301
- prompt = f"cyborg style, {prompt}"
302
- if model == 'Little Tinies':
303
- API_URL = "https://api-inference.huggingface.co/models/alvdansen/littletinies"
304
- if model == 'NSFW XL':
305
- API_URL = "https://api-inference.huggingface.co/models/Dremmar/nsfw-xl"
306
- if model == 'Analog Redmond':
307
- API_URL = "https://api-inference.huggingface.co/models/artificialguybr/analogredmond"
308
- prompt = f"timeless style, {prompt}"
309
- if model == 'Pixel Art Redmond':
310
- API_URL = "https://api-inference.huggingface.co/models/artificialguybr/PixelArtRedmond"
311
- prompt = f"Pixel Art, {prompt}"
312
- if model == 'Ascii Art':
313
- API_URL = "https://api-inference.huggingface.co/models/CiroN2022/ascii-art"
314
- prompt = f"ascii art, {prompt}"
315
- if model == 'Analog':
316
- API_URL = "https://api-inference.huggingface.co/models/Yntec/Analog"
317
- if model == 'Maple Syrup':
318
- API_URL = "https://api-inference.huggingface.co/models/Yntec/MapleSyrup"
319
- if model == 'Perfect Lewd Fantasy':
320
- API_URL = "https://api-inference.huggingface.co/models/digiplay/perfectLewdFantasy_v1.01"
321
- if model == 'AbsoluteReality 1.8.1':
322
- API_URL = "https://api-inference.huggingface.co/models/digiplay/AbsoluteReality_v1.8.1"
323
- if model == 'Disney':
324
- API_URL = "https://api-inference.huggingface.co/models/goofyai/disney_style_xl"
325
- prompt = f"Disney style, {prompt}"
326
- if model == 'Redmond SDXL':
327
- API_URL = "https://api-inference.huggingface.co/models/artificialguybr/LogoRedmond-LogoLoraForSDXL-V2"
328
- if model == 'epiCPhotoGasm':
329
- API_URL = "https://api-inference.huggingface.co/models/Yntec/epiCPhotoGasm"
330
- print(f"API URL set to: {API_URL}") # Debug log
331
-
332
- # Define the payload for the request
333
- payload = {
334
- "inputs": prompt,
335
- "is_negative": is_negative, # Whether to use a negative prompt
336
- "steps": steps, # Number of sampling steps
337
- "cfg_scale": cfg_scale, # Scale for controlling adherence to prompt
338
- "seed": seed if seed != -1 else random.randint(1, 1000000000), # Random seed for reproducibility
339
- "strength": strength, # How strongly the model should transform the image
340
- "parameters": {
341
- "width": width, # Width of the generated image
342
- "height": height # Height of the generated image
343
- }
344
- }
345
- print(f"Payload: {json.dumps(payload, indent=2)}") # Debug log
346
 
347
- # Make a request to the API to generate the image
348
  try:
349
- response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
350
- print(f"Response status code: {response.status_code}") # Debug log
351
- except requests.exceptions.RequestException as e:
352
- # Log any request exceptions and raise an error for the user
353
- print(f"Request failed: {e}") # Debug log
354
- raise gr.Error(f"Request failed: {e}")
355
-
356
- # Check if the response status is not successful
357
- if response.status_code != 200:
358
- print(f"Error: Failed to retrieve image. Response status: {response.status_code}") # Debug log
359
- print(f"Response content: {response.text}") # Debug log
360
- if response.status_code == 400:
361
- raise gr.Error(f"{response.status_code}: Bad Request - There might be an issue with the input parameters.")
362
- elif response.status_code == 401:
363
- raise gr.Error(f"{response.status_code}: Unauthorized - Please check your API token.")
364
- elif response.status_code == 403:
365
- raise gr.Error(f"{response.status_code}: Forbidden - You do not have permission to access this model.")
366
- elif response.status_code == 404:
367
- raise gr.Error(f"{response.status_code}: Not Found - The requested model could not be found.")
368
- elif response.status_code == 503:
369
- raise gr.Error(f"{response.status_code}: The model is being loaded. Please try again later.")
370
  else:
371
- raise gr.Error(f"{response.status_code}: An unexpected error occurred.")
372
-
373
- try:
374
- # Attempt to read the image from the response content
375
- image_bytes = response.content
376
- image = Image.open(io.BytesIO(image_bytes))
377
- print(f'Generation {key} completed! ({prompt})') # Debug log
 
 
 
 
 
 
 
 
 
 
 
378
  return image
 
379
  except Exception as e:
380
- # Handle any errors that occur when opening the image
381
- print(f"Error while trying to open image: {e}") # Debug log
382
- return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
 
384
  # Custom CSS to hide the footer in the interface
385
  css = """
@@ -644,9 +600,9 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme') as dalle:
644
  with gr.Row():
645
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
646
 
647
- # Set up button click event to call the query function
648
  text_button.click(query, inputs=[text_prompt, model, custom_lora, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
649
 
650
  print("Launching Gradio interface...") # Debug log
651
  # Launch the Gradio interface without showing the API or sharing externally
652
- dalle.launch(show_api=True, share=False)
 
1
+ import gradio as gr # type: ignore
2
+ import requests # type: ignore
3
  import io
4
  import random
5
  import os
6
  import time
7
  from PIL import Image
8
  import json
9
+ from huggingface_hub import InferenceClient
10
 
11
  # Project by Nymbo
12
 
13
+ def query_with_auto_routing(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, width=1024, height=1024):
14
+ """
15
+ Generate images using HF's automatic provider routing
16
+ """
17
+ print(f"Starting query with automatic provider routing")
 
 
 
 
 
 
 
18
  print(f"Prompt: {prompt}")
19
  print(f"Model: {model}")
20
  print(f"Custom LoRA: {custom_lora}")
 
22
 
23
  # Check if the prompt is empty or None
24
  if prompt == "" or prompt is None:
25
+ print("Prompt is empty or None. Exiting query function.")
26
  return None
27
 
28
  # Generate a unique key for tracking the generation process
29
  key = random.randint(0, 999)
30
+ print(f"Generated key: {key}")
 
 
 
 
 
31
 
32
  # Enhance the prompt with additional details for better quality
33
+ enhanced_prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
34
+ print(f'Generation {key}: {enhanced_prompt}')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
 
36
  try:
37
+ # Use automatic provider routing
38
+ api_key = os.getenv("HF_READ_TOKEN")
39
+ if not api_key:
40
+ raise gr.Error("HF_READ_TOKEN not found. Please set your Hugging Face API token.")
41
+
42
+ # Initialize client with automatic provider selection (default is "auto")
43
+ client = InferenceClient(api_key=api_key)
44
+
45
+ # Determine the model to use
46
+ if custom_lora.strip() != "":
47
+ model_id = custom_lora.strip()
48
+ print(f"Using custom LoRA: {model_id}")
 
 
 
 
 
 
 
 
 
49
  else:
50
+ model_id = get_model_id_from_name(model)
51
+ print(f"Using model: {model_id}")
52
+
53
+ # Apply model-specific prompt enhancements
54
+ enhanced_prompt = apply_model_prompt_enhancements(model, enhanced_prompt)
55
+
56
+ # Generate image using automatic provider routing
57
+ image = client.text_to_image(
58
+ prompt=enhanced_prompt,
59
+ model=model_id,
60
+ width=width,
61
+ height=height,
62
+ num_inference_steps=steps,
63
+ guidance_scale=cfg_scale,
64
+ seed=seed if seed != -1 else None,
65
+ )
66
+
67
+ print(f'Generation {key} completed with automatic routing!')
68
  return image
69
+
70
  except Exception as e:
71
+ print(f"Error with automatic routing: {e}")
72
+ raise gr.Error(f"Failed to generate image: {str(e)}")
73
+
74
+ def get_model_id_from_name(model_name):
75
+ """
76
+ Convert user-friendly model names to actual HuggingFace model IDs
77
+ """
78
+ model_mapping = {
79
+ 'FLUX.1 [Dev]': "black-forest-labs/FLUX.1-dev",
80
+ 'FLUX.1 [Schnell]': "black-forest-labs/FLUX.1-schnell",
81
+ 'Stable Diffusion XL': "stabilityai/stable-diffusion-xl-base-1.0",
82
+ 'Stable Diffusion 3.5 Large': "stabilityai/stable-diffusion-3.5-large",
83
+ 'Stable Diffusion 3.5 Large Turbo': "stabilityai/stable-diffusion-3.5-large-turbo",
84
+ 'Stable Diffusion 3 Medium': "stabilityai/stable-diffusion-3-medium-diffusers",
85
+ 'HiDream-I1-Full': "HiDream-ai/HiDream-I1-Full",
86
+ 'HiDream-I1-Dev': "HiDream-ai/HiDream-I1-Dev",
87
+ 'HiDream-I1-Fast': "HiDream-ai/HiDream-I1-Fast",
88
+ 'Animagine 4.0': "cagliostrolab/animagine-xl-4.0",
89
+ 'Flux Icon Kit': "strangerzonehf/Flux-Icon-Kit-LoRA",
90
+ 'Pixel Background': "strangerzonehf/Flux-Pixel-Background-LoRA",
91
+ 'Meme XD': "prithivMLmods/Flux-Meme-Xd-LoRA",
92
+ 'Chill Guy': "prithivMLmods/Flux-Chill-Guy-Zone",
93
+ 'Pepe': "openfree/pepe",
94
+ 'NSFWmodel': "lexa862/NSFWmodel",
95
+ 'Claude Art': "strangerzonehf/Flux-Claude-Art",
96
+ 'Open Genmoji': "EvanZhouDev/open-genmoji",
97
+ 'EBook Creative Cover': "prithivMLmods/EBook-Creative-Cover-Flux-LoRA",
98
+ 'Flux Logo Design 2': "prithivMLmods/Logo-Design-Flux-LoRA",
99
+ 'Isometric 3D': "strangerzonehf/Flux-Isometric-3D-LoRA",
100
+ 'Flux Condensation': "fofr/flux-condensation",
101
+ 'Flux Handwriting': "fofr/flux-handwriting",
102
+ 'Shou Xin': "Datou1111/shou_xin",
103
+ 'Sketch Smudge': "strangerzonehf/Flux-Sketch-Smudge-LoRA",
104
+ '80s Cyberpunk': "fofr/flux-80s-cyberpunk",
105
+ 'Coloring Book Flux': "renderartist/coloringbookflux",
106
+ 'Flux Miniature LoRA': "gokaygokay/Flux-Miniature-LoRA",
107
+ 'Sketch Paint': "strangerzonehf/Sketch-Paint",
108
+ 'Flux UltraRealism 2.0': "prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0",
109
+ 'Midjourney Mix': "strangerzonehf/Flux-Midjourney-Mix-LoRA",
110
+ 'Midjourney Mix 2': "strangerzonehf/Flux-Midjourney-Mix2-LoRA",
111
+ 'Flux Logo Design': "Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design",
112
+ 'Flux Uncensored': "enhanceaiteam/Flux-uncensored",
113
+ 'Flux Uncensored V2': "enhanceaiteam/Flux-Uncensored-V2",
114
+ 'Flux Tarot Cards': "prithivMLmods/Ton618-Tarot-Cards-Flux-LoRA",
115
+ 'Pixel Art Sprites': "sWizad/pokemon-trainer-sprites-pixelart-flux",
116
+ '3D Sketchfab': "prithivMLmods/Castor-3D-Sketchfab-Flux-LoRA",
117
+ 'Retro Comic Flux': "renderartist/retrocomicflux",
118
+ 'Caricature': "TheAwakenOne/caricature",
119
+ 'Huggieverse': "Chunte/flux-lora-Huggieverse",
120
+ 'Propaganda Poster': "AlekseyCalvin/Propaganda_Poster_Schnell_by_doctor_diffusion",
121
+ 'Flux Game Assets V2': "gokaygokay/Flux-Game-Assets-LoRA-v2",
122
+ 'SDXL HS Card Style': "Norod78/sdxl-hearthstone-card-style-lora",
123
+ 'SLDR FLUX NSFW v2 Studio': "xey/sldr_flux_nsfw_v2-studio",
124
+ 'SoftPasty Flux': "alvdansen/softpasty-flux-dev",
125
+ 'Flux Stickers': "diabolic6045/Flux_Sticker_Lora",
126
+ 'Flux Animex V2': "strangerzonehf/Flux-Animex-v2-LoRA",
127
+ 'Flux Animeo V1': "strangerzonehf/Flux-Animeo-v1-LoRA",
128
+ 'Movie Board': "prithivMLmods/Flux.1-Dev-Movie-Boards-LoRA",
129
+ 'Purple Dreamy': "prithivMLmods/Purple-Dreamy-Flux-LoRA",
130
+ 'PS1 Style Flux': "veryVANYA/ps1-style-flux",
131
+ 'Softserve Anime': "alvdansen/softserve_anime",
132
+ 'Flux Tarot v1': "multimodalart/flux-tarot-v1",
133
+ 'Half Illustration': "davisbro/half_illustration",
134
+ 'OpenDalle v1.1': "dataautogpt3/OpenDalleV1.1",
135
+ 'Flux Ghibsky Illustration': "aleksa-codes/flux-ghibsky-illustration",
136
+ 'Flux Koda': "alvdansen/flux-koda",
137
+ 'Soviet Diffusion XL': "openskyml/soviet-diffusion-xl",
138
+ 'Flux Realism LoRA': "XLabs-AI/flux-RealismLora",
139
+ 'Frosting Lane Flux': "alvdansen/frosting_lane_flux",
140
+ 'Phantasma Anime': "alvdansen/phantasma-anime",
141
+ 'Boreal': "kudzueye/Boreal",
142
+ 'How2Draw': "glif/how2draw",
143
+ 'Flux AestheticAnime': "dataautogpt3/FLUX-AestheticAnime",
144
+ 'Fashion Hut Modeling LoRA': "prithivMLmods/Fashion-Hut-Modeling-LoRA",
145
+ 'Flux SyntheticAnime': "dataautogpt3/FLUX-SyntheticAnime",
146
+ 'Flux Midjourney Anime': "brushpenbob/flux-midjourney-anime",
147
+ 'Coloring Book Generator': "robert123231/coloringbookgenerator",
148
+ 'Collage Flux': "prithivMLmods/Castor-Collage-Dim-Flux-LoRA",
149
+ 'Flux Product Ad Backdrop': "prithivMLmods/Flux-Product-Ad-Backdrop",
150
+ 'Product Design': "multimodalart/product-design",
151
+ '90s Anime Art': "glif/90s-anime-art",
152
+ 'Brain Melt Acid Art': "glif/Brain-Melt-Acid-Art",
153
+ 'Lustly Flux Uncensored v1': "lustlyai/Flux_Lustly.ai_Uncensored_nsfw_v1",
154
+ 'NSFW Master Flux': "Keltezaa/NSFW_MASTER_FLUX",
155
+ 'Flux Outfit Generator': "tryonlabs/FLUX.1-dev-LoRA-Outfit-Generator",
156
+ 'Midjourney': "Jovie/Midjourney",
157
+ 'DreamPhotoGASM': "Yntec/DreamPhotoGASM",
158
+ 'Flux Super Realism LoRA': "strangerzonehf/Flux-Super-Realism-LoRA",
159
+ 'Stable Diffusion 2-1': "stabilityai/stable-diffusion-2-1-base",
160
+ 'Duchaiten Real3D NSFW XL': "stablediffusionapi/duchaiten-real3d-nsfw-xl",
161
+ 'Pixel Art XL': "nerijs/pixel-art-xl",
162
+ 'Character Design': "KappaNeuro/character-design",
163
+ 'Sketched Out Manga': "alvdansen/sketchedoutmanga",
164
+ 'Archfey Anime': "alvdansen/archfey_anime",
165
+ 'Lofi Cuties': "alvdansen/lofi-cuties",
166
+ 'YiffyMix': "Yntec/YiffyMix",
167
+ 'Analog Madness Realistic v7': "digiplay/AnalogMadness-realistic-model-v7",
168
+ 'Selfie Photography': "artificialguybr/selfiephotographyredmond-selfie-photography-lora-for-sdxl",
169
+ 'Filmgrain': "artificialguybr/filmgrain-redmond-filmgrain-lora-for-sdxl",
170
+ 'Leonardo AI Style Illustration': "goofyai/Leonardo_Ai_Style_Illustration",
171
+ 'Cyborg Style XL': "goofyai/cyborg_style_xl",
172
+ 'Little Tinies': "alvdansen/littletinies",
173
+ 'NSFW XL': "Dremmar/nsfw-xl",
174
+ 'Analog Redmond': "artificialguybr/analogredmond",
175
+ 'Pixel Art Redmond': "artificialguybr/PixelArtRedmond",
176
+ 'Ascii Art': "CiroN2022/ascii-art",
177
+ 'Analog': "Yntec/Analog",
178
+ 'Maple Syrup': "Yntec/MapleSyrup",
179
+ 'Perfect Lewd Fantasy': "digiplay/perfectLewdFantasy_v1.01",
180
+ 'AbsoluteReality 1.8.1': "digiplay/AbsoluteReality_v1.8.1",
181
+ 'Disney': "goofyai/disney_style_xl",
182
+ 'Redmond SDXL': "artificialguybr/LogoRedmond-LogoLoraForSDXL-V2",
183
+ 'epiCPhotoGasm': "Yntec/epiCPhotoGasm"
184
+ }
185
+
186
+ # Return the mapped model ID or default to FLUX.1 Schnell
187
+ return model_mapping.get(model_name, "black-forest-labs/FLUX.1-schnell")
188
+
189
+ def apply_model_prompt_enhancements(model_name, prompt):
190
+ """
191
+ Apply model-specific prompt enhancements
192
+ """
193
+ if model_name == 'Animagine 4.0':
194
+ return f"masterpiece, high score, great score, absurdres, {prompt}"
195
+ elif model_name == 'Flux Icon Kit':
196
+ return f"Icon Kit, {prompt}"
197
+ elif model_name == 'Pixel Background':
198
+ return f"Pixel Background, {prompt}"
199
+ elif model_name == 'Meme XD':
200
+ return f"meme, {prompt}"
201
+ elif model_name == 'Chill Guy':
202
+ return f"chill guy, {prompt}"
203
+ elif model_name == 'Pepe':
204
+ return f"pepe, {prompt}"
205
+ elif model_name == 'NSFWmodel':
206
+ return f"nude, {prompt}"
207
+ elif model_name == 'Claude Art':
208
+ return f"claude art, {prompt}"
209
+ elif model_name == 'Open Genmoji':
210
+ return f"emoji, {prompt}"
211
+ elif model_name == 'EBook Creative Cover':
212
+ return f"EBook Cover, {prompt}"
213
+ elif model_name == 'Flux Logo Design 2':
214
+ return f"Logo Design, {prompt}"
215
+ elif model_name == 'Isometric 3D':
216
+ return f"Isometric 3D, {prompt}"
217
+ elif model_name == 'Flux Condensation':
218
+ return f"CONDENSATION, {prompt}"
219
+ elif model_name == 'Flux Handwriting':
220
+ return f"HWRIT handwriting, {prompt}"
221
+ elif model_name == 'Shou Xin':
222
+ return f"shou_xin, pencil sketch, {prompt}"
223
+ elif model_name == 'Sketch Smudge':
224
+ return f"Sketch Smudge, {prompt}"
225
+ elif model_name == '80s Cyberpunk':
226
+ return f"80s cyberpunk, {prompt}"
227
+ elif model_name == 'Coloring Book Flux':
228
+ return f"c0l0ringb00k, coloring book, coloring book page, {prompt}"
229
+ elif model_name == 'Flux Miniature LoRA':
230
+ return f"MNTR, miniature drawing, {prompt}"
231
+ elif model_name == 'Sketch Paint':
232
+ return f"Sketch paint, {prompt}"
233
+ elif model_name == 'Flux UltraRealism 2.0':
234
+ return f"Ultra realistic, {prompt}"
235
+ elif model_name == 'Midjourney Mix':
236
+ return f"midjourney mix, {prompt}"
237
+ elif model_name == 'Midjourney Mix 2':
238
+ return f"MJ v6, {prompt}"
239
+ elif model_name == 'Flux Logo Design':
240
+ return f"wablogo, logo, Minimalist, {prompt}"
241
+ elif model_name == 'Flux Tarot Cards':
242
+ return f"Tarot card, {prompt}"
243
+ elif model_name == 'Pixel Art Sprites':
244
+ return f"a pixel image, {prompt}"
245
+ elif model_name == '3D Sketchfab':
246
+ return f"3D Sketchfab, {prompt}"
247
+ elif model_name == 'Retro Comic Flux':
248
+ return f"c0m1c, comic book panel, {prompt}"
249
+ elif model_name == 'Caricature':
250
+ return f"CCTUR3, {prompt}"
251
+ elif model_name == 'Huggieverse':
252
+ return f"HGGRE, {prompt}"
253
+ elif model_name == 'Stable Diffusion 3 Medium':
254
+ return f"A, {prompt}"
255
+ elif model_name == 'Propaganda Poster':
256
+ return f"propaganda poster, {prompt}"
257
+ elif model_name == 'Flux Game Assets V2':
258
+ return f"wbgmsst, white background, {prompt}"
259
+ elif model_name == 'SDXL HS Card Style':
260
+ return f"Hearthstone Card, {prompt}"
261
+ elif model_name == 'SoftPasty Flux':
262
+ return f"araminta_illus illustration style, {prompt}"
263
+ elif model_name == 'Flux Stickers':
264
+ return f"5t1cker 5ty1e, {prompt}"
265
+ elif model_name == 'Flux Animex V2':
266
+ return f"Animex, {prompt}"
267
+ elif model_name == 'Flux Animeo V1':
268
+ return f"Animeo, {prompt}"
269
+ elif model_name == 'Movie Board':
270
+ return f"movieboard, {prompt}"
271
+ elif model_name == 'Purple Dreamy':
272
+ return f"Purple Dreamy, {prompt}"
273
+ elif model_name == 'PS1 Style Flux':
274
+ return f"ps1 game screenshot, {prompt}"
275
+ elif model_name == 'Softserve Anime':
276
+ return f"sftsrv style illustration, {prompt}"
277
+ elif model_name == 'Flux Tarot v1':
278
+ return f"in the style of TOK a trtcrd tarot style, {prompt}"
279
+ elif model_name == 'Half Illustration':
280
+ return f"in the style of TOK, {prompt}"
281
+ elif model_name == 'Flux Ghibsky Illustration':
282
+ return f"GHIBSKY style, {prompt}"
283
+ elif model_name == 'Flux Koda':
284
+ return f"flmft style, {prompt}"
285
+ elif model_name == 'Soviet Diffusion XL':
286
+ return f"soviet poster, {prompt}"
287
+ elif model_name == 'Frosting Lane Flux':
288
+ return f"frstingln illustration, {prompt}"
289
+ elif model_name == 'Boreal':
290
+ return f"photo, {prompt}"
291
+ elif model_name == 'How2Draw':
292
+ return f"How2Draw, {prompt}"
293
+ elif model_name == 'Fashion Hut Modeling LoRA':
294
+ return f"Modeling of, {prompt}"
295
+ elif model_name == 'Flux SyntheticAnime':
296
+ return f"1980s anime screengrab, VHS quality, syntheticanime, {prompt}"
297
+ elif model_name == 'Flux Midjourney Anime':
298
+ return f"egmid, {prompt}"
299
+ elif model_name == 'Collage Flux':
300
+ return f"collage, {prompt}"
301
+ elif model_name == 'Flux Product Ad Backdrop':
302
+ return f"Product Ad, {prompt}"
303
+ elif model_name == 'Product Design':
304
+ return f"product designed by prdsgn, {prompt}"
305
+ elif model_name == 'Brain Melt Acid Art':
306
+ return f"maximalism, in an acid surrealism style, {prompt}"
307
+ elif model_name == 'NSFW Master Flux':
308
+ return f"NSFW, {prompt}"
309
+ elif model_name == 'Pixel Art XL':
310
+ return f"pixel art, {prompt}"
311
+ elif model_name == 'Character Design':
312
+ return f"Character Design, {prompt}"
313
+ elif model_name == 'Sketched Out Manga':
314
+ return f"daiton, {prompt}"
315
+ elif model_name == 'Selfie Photography':
316
+ return f"instagram model, discord profile picture, {prompt}"
317
+ elif model_name == 'Filmgrain':
318
+ return f"Film Grain, FilmGrainAF, {prompt}"
319
+ elif model_name == 'Leonardo AI Style Illustration':
320
+ return f"leonardo style, illustration, vector art, {prompt}"
321
+ elif model_name == 'Cyborg Style XL':
322
+ return f"cyborg style, {prompt}"
323
+ elif model_name == 'Analog Redmond':
324
+ return f"timeless style, {prompt}"
325
+ elif model_name == 'Pixel Art Redmond':
326
+ return f"Pixel Art, {prompt}"
327
+ elif model_name == 'Ascii Art':
328
+ return f"ascii art, {prompt}"
329
+ elif model_name == 'Disney':
330
+ return f"Disney style, {prompt}"
331
+
332
+ return prompt
333
+
334
+ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, width=1024, height=1024):
335
+ """
336
+ Main query function - now uses automatic provider routing
337
+ """
338
+ return query_with_auto_routing(prompt, model, custom_lora, is_negative, steps, cfg_scale, sampler, seed, strength, width, height)
339
 
340
  # Custom CSS to hide the footer in the interface
341
  css = """
 
600
  with gr.Row():
601
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
602
 
603
+ # Set up button click event to call the main query function
604
  text_button.click(query, inputs=[text_prompt, model, custom_lora, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
605
 
606
  print("Launching Gradio interface...") # Debug log
607
  # Launch the Gradio interface without showing the API or sharing externally
608
+ dalle.launch(show_api=False, share=False)