Update app.py
Browse files
app.py
CHANGED
|
@@ -4,20 +4,50 @@ 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 |
-
#
|
| 13 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
# Debug log to indicate function start
|
| 22 |
print("Starting query function...")
|
| 23 |
# Print the parameters for debugging purposes
|
|
@@ -25,6 +55,7 @@ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7,
|
|
| 25 |
print(f"Model: {model}")
|
| 26 |
print(f"Custom LoRA: {custom_lora}")
|
| 27 |
print(f"Parameters - Steps: {steps}, CFG Scale: {cfg_scale}, Seed: {seed}, Strength: {strength}, Width: {width}, Height: {height}")
|
|
|
|
| 28 |
print(f"Custom API Key provided: {bool(custom_api_key.strip())}") # Log whether a custom key was provided without printing the key
|
| 29 |
|
| 30 |
# Check if the prompt is empty or None
|
|
@@ -41,9 +72,16 @@ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7,
|
|
| 41 |
print("USING CUSTOM API KEY: BYOK token provided by user is being used for authentication")
|
| 42 |
API_TOKEN = custom_api_key.strip()
|
| 43 |
else:
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
| 49 |
|
|
@@ -51,290 +89,200 @@ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7,
|
|
| 51 |
prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
| 52 |
print(f'Generation {key}: {prompt}') # Debug log
|
| 53 |
|
| 54 |
-
# Set the
|
| 55 |
if custom_lora.strip() != "":
|
| 56 |
-
|
| 57 |
else:
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
if model == 'Product Design':
|
| 249 |
-
API_URL = "https://api-inference.huggingface.co/models/multimodalart/product-design"
|
| 250 |
-
prompt = f"product designed by prdsgn, {prompt}"
|
| 251 |
-
if model == '90s Anime Art':
|
| 252 |
-
API_URL = "https://api-inference.huggingface.co/models/glif/90s-anime-art"
|
| 253 |
-
if model == 'Brain Melt Acid Art':
|
| 254 |
-
API_URL = "https://api-inference.huggingface.co/models/glif/Brain-Melt-Acid-Art"
|
| 255 |
-
prompt = f"maximalism, in an acid surrealism style, {prompt}"
|
| 256 |
-
if model == 'Lustly Flux Uncensored v1':
|
| 257 |
-
API_URL = "https://api-inference.huggingface.co/models/lustlyai/Flux_Lustly.ai_Uncensored_nsfw_v1"
|
| 258 |
-
if model == 'NSFW Master Flux':
|
| 259 |
-
API_URL = "https://api-inference.huggingface.co/models/Keltezaa/NSFW_MASTER_FLUX"
|
| 260 |
-
prompt = f"NSFW, {prompt}"
|
| 261 |
-
if model == 'Flux Outfit Generator':
|
| 262 |
-
API_URL = "https://api-inference.huggingface.co/models/tryonlabs/FLUX.1-dev-LoRA-Outfit-Generator"
|
| 263 |
-
if model == 'Midjourney':
|
| 264 |
-
API_URL = "https://api-inference.huggingface.co/models/Jovie/Midjourney"
|
| 265 |
-
if model == 'DreamPhotoGASM':
|
| 266 |
-
API_URL = "https://api-inference.huggingface.co/models/Yntec/DreamPhotoGASM"
|
| 267 |
-
if model == 'Flux Super Realism LoRA':
|
| 268 |
-
API_URL = "https://api-inference.huggingface.co/models/strangerzonehf/Flux-Super-Realism-LoRA"
|
| 269 |
-
if model == 'Stable Diffusion 2-1':
|
| 270 |
-
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2-1-base"
|
| 271 |
-
if model == 'Stable Diffusion 3.5 Large':
|
| 272 |
-
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3.5-large"
|
| 273 |
-
if model == 'Stable Diffusion 3.5 Large Turbo':
|
| 274 |
-
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3.5-large-turbo"
|
| 275 |
-
if model == 'Stable Diffusion 3 Medium':
|
| 276 |
-
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3-medium-diffusers"
|
| 277 |
-
prompt = f"A, {prompt}"
|
| 278 |
-
if model == 'Duchaiten Real3D NSFW XL':
|
| 279 |
-
API_URL = "https://api-inference.huggingface.co/models/stablediffusionapi/duchaiten-real3d-nsfw-xl"
|
| 280 |
-
if model == 'Pixel Art XL':
|
| 281 |
-
API_URL = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
|
| 282 |
-
prompt = f"pixel art, {prompt}"
|
| 283 |
-
if model == 'Character Design':
|
| 284 |
-
API_URL = "https://api-inference.huggingface.co/models/KappaNeuro/character-design"
|
| 285 |
-
prompt = f"Character Design, {prompt}"
|
| 286 |
-
if model == 'Sketched Out Manga':
|
| 287 |
-
API_URL = "https://api-inference.huggingface.co/models/alvdansen/sketchedoutmanga"
|
| 288 |
-
prompt = f"daiton, {prompt}"
|
| 289 |
-
if model == 'Archfey Anime':
|
| 290 |
-
API_URL = "https://api-inference.huggingface.co/models/alvdansen/archfey_anime"
|
| 291 |
-
if model == 'Lofi Cuties':
|
| 292 |
-
API_URL = "https://api-inference.huggingface.co/models/alvdansen/lofi-cuties"
|
| 293 |
-
if model == 'YiffyMix':
|
| 294 |
-
API_URL = "https://api-inference.huggingface.co/models/Yntec/YiffyMix"
|
| 295 |
-
if model == 'Analog Madness Realistic v7':
|
| 296 |
-
API_URL = "https://api-inference.huggingface.co/models/digiplay/AnalogMadness-realistic-model-v7"
|
| 297 |
-
if model == 'Selfie Photography':
|
| 298 |
-
API_URL = "https://api-inference.huggingface.co/models/artificialguybr/selfiephotographyredmond-selfie-photography-lora-for-sdxl"
|
| 299 |
-
prompt = f"instagram model, discord profile picture, {prompt}"
|
| 300 |
-
if model == 'Filmgrain':
|
| 301 |
-
API_URL = "https://api-inference.huggingface.co/models/artificialguybr/filmgrain-redmond-filmgrain-lora-for-sdxl"
|
| 302 |
-
prompt = f"Film Grain, FilmGrainAF, {prompt}"
|
| 303 |
-
if model == 'Leonardo AI Style Illustration':
|
| 304 |
-
API_URL = "https://api-inference.huggingface.co/models/goofyai/Leonardo_Ai_Style_Illustration"
|
| 305 |
-
prompt = f"leonardo style, illustration, vector art, {prompt}"
|
| 306 |
-
if model == 'Cyborg Style XL':
|
| 307 |
-
API_URL = "https://api-inference.huggingface.co/models/goofyai/cyborg_style_xl"
|
| 308 |
-
prompt = f"cyborg style, {prompt}"
|
| 309 |
-
if model == 'Little Tinies':
|
| 310 |
-
API_URL = "https://api-inference.huggingface.co/models/alvdansen/littletinies"
|
| 311 |
-
if model == 'NSFW XL':
|
| 312 |
-
API_URL = "https://api-inference.huggingface.co/models/Dremmar/nsfw-xl"
|
| 313 |
-
if model == 'Analog Redmond':
|
| 314 |
-
API_URL = "https://api-inference.huggingface.co/models/artificialguybr/analogredmond"
|
| 315 |
-
prompt = f"timeless style, {prompt}"
|
| 316 |
-
if model == 'Pixel Art Redmond':
|
| 317 |
-
API_URL = "https://api-inference.huggingface.co/models/artificialguybr/PixelArtRedmond"
|
| 318 |
-
prompt = f"Pixel Art, {prompt}"
|
| 319 |
-
if model == 'Ascii Art':
|
| 320 |
-
API_URL = "https://api-inference.huggingface.co/models/CiroN2022/ascii-art"
|
| 321 |
-
prompt = f"ascii art, {prompt}"
|
| 322 |
-
if model == 'Analog':
|
| 323 |
-
API_URL = "https://api-inference.huggingface.co/models/Yntec/Analog"
|
| 324 |
-
if model == 'Maple Syrup':
|
| 325 |
-
API_URL = "https://api-inference.huggingface.co/models/Yntec/MapleSyrup"
|
| 326 |
-
if model == 'Perfect Lewd Fantasy':
|
| 327 |
-
API_URL = "https://api-inference.huggingface.co/models/digiplay/perfectLewdFantasy_v1.01"
|
| 328 |
-
if model == 'AbsoluteReality 1.8.1':
|
| 329 |
-
API_URL = "https://api-inference.huggingface.co/models/digiplay/AbsoluteReality_v1.8.1"
|
| 330 |
-
if model == 'Disney':
|
| 331 |
-
API_URL = "https://api-inference.huggingface.co/models/goofyai/disney_style_xl"
|
| 332 |
-
prompt = f"Disney style, {prompt}"
|
| 333 |
-
if model == 'Redmond SDXL':
|
| 334 |
-
API_URL = "https://api-inference.huggingface.co/models/artificialguybr/LogoRedmond-LogoLoraForSDXL-V2"
|
| 335 |
-
if model == 'epiCPhotoGasm':
|
| 336 |
-
API_URL = "https://api-inference.huggingface.co/models/Yntec/epiCPhotoGasm"
|
| 337 |
-
print(f"API URL set to: {API_URL}") # Debug log
|
| 338 |
|
| 339 |
# Define the payload for the request
|
| 340 |
payload = {
|
|
@@ -351,9 +299,21 @@ def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7,
|
|
| 351 |
}
|
| 352 |
print(f"Payload: {json.dumps(payload, indent=2)}") # Debug log
|
| 353 |
|
| 354 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
try:
|
| 356 |
-
response =
|
| 357 |
print(f"Response status code: {response.status_code}") # Debug log
|
| 358 |
except requests.exceptions.RequestException as e:
|
| 359 |
# Log any request exceptions and raise an error for the user
|
|
@@ -535,18 +495,26 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme_5') as dalle:
|
|
| 535 |
# Tab for advanced settings
|
| 536 |
with gr.Tab("Advanced Settings"):
|
| 537 |
with gr.Row():
|
| 538 |
-
#
|
| 539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
with gr.Row():
|
| 541 |
-
#
|
| 542 |
byok_textbox = gr.Textbox(
|
| 543 |
value="",
|
| 544 |
label="BYOK (Bring Your Own Key)",
|
| 545 |
-
info="Enter a custom
|
| 546 |
-
placeholder="Enter your
|
| 547 |
type="password", # Hide the API key for security
|
| 548 |
elem_id="byok-input"
|
| 549 |
)
|
|
|
|
|
|
|
|
|
|
| 550 |
with gr.Row():
|
| 551 |
# Slider for selecting the image width
|
| 552 |
width = gr.Slider(label="Width", value=1024, minimum=64, maximum=1216, step=32)
|
|
@@ -568,6 +536,23 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme_5') as dalle:
|
|
| 568 |
# Radio buttons for selecting the sampling method
|
| 569 |
method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
|
| 570 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 571 |
# Tab for image editing options
|
| 572 |
with gr.Tab("Image Editor"):
|
| 573 |
# Function to simulate a delay for processing
|
|
@@ -625,16 +610,46 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme_5') as dalle:
|
|
| 625 |
"""
|
| 626 |
)
|
| 627 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 628 |
# Accordion providing an overview of advanced settings
|
| 629 |
with gr.Accordion("Advanced Settings Overview", open=False):
|
| 630 |
gr.Markdown(
|
| 631 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 632 |
## Negative Prompt
|
| 633 |
###### This box is for telling the AI what you don't want in your images. Think of it as a way to avoid certain elements. For instance, if you don't want blurry images or extra limbs showing up, this is where you'd mention it.
|
| 634 |
|
| 635 |
-
## BYOK (Bring Your Own Key)
|
| 636 |
-
###### This allows you to use your own Hugging Face API key instead of the default keys. Enter your key here for direct access to models using your account's permissions and rate limits.
|
| 637 |
-
|
| 638 |
## Width & Height
|
| 639 |
###### These sliders allow you to specify the resolution of your image. Default value is 1024x1024, and maximum output is 1216x1216.
|
| 640 |
|
|
@@ -664,8 +679,8 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme_5') as dalle:
|
|
| 664 |
with gr.Row():
|
| 665 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
| 666 |
|
| 667 |
-
# Set up button click event to call the query function with the
|
| 668 |
-
text_button.click(query, inputs=[text_prompt, model, custom_lora, negative_prompt, steps, cfg, method, seed, strength, width, height, byok_textbox], outputs=image_output)
|
| 669 |
|
| 670 |
print("Launching Gradio interface...") # Debug log
|
| 671 |
# Launch the Gradio interface without showing the API or sharing externally
|
|
|
|
| 4 |
import random
|
| 5 |
import os
|
| 6 |
import time
|
|
|
|
| 7 |
import json
|
| 8 |
+
from PIL import Image
|
| 9 |
|
| 10 |
# Project by Nymbo
|
| 11 |
|
| 12 |
+
# Retrieve the default API token from environment variables
|
| 13 |
+
HF_TOKEN = os.getenv("HF_READ_TOKEN")
|
|
|
|
|
|
|
|
|
|
| 14 |
# Timeout for requests
|
| 15 |
timeout = 100
|
| 16 |
|
| 17 |
+
# Provider-specific API handlers
|
| 18 |
+
def query_hf_inference(prompt, model_path, headers, payload, timeout):
|
| 19 |
+
"""Handler for Hugging Face Inference API requests"""
|
| 20 |
+
api_url = f"https://api-inference.huggingface.co/models/{model_path}"
|
| 21 |
+
print(f"Making request to HF Inference API: {api_url}")
|
| 22 |
+
return requests.post(api_url, headers=headers, json=payload, timeout=timeout)
|
| 23 |
+
|
| 24 |
+
def query_fal_ai(prompt, model_path, headers, payload, timeout):
|
| 25 |
+
"""Handler for Fal AI API requests"""
|
| 26 |
+
api_url = f"https://live.fal.ai/hugging-face/{model_path}"
|
| 27 |
+
print(f"Making request to Fal AI: {api_url}")
|
| 28 |
+
return requests.post(api_url, headers=headers, json=payload, timeout=timeout)
|
| 29 |
+
|
| 30 |
+
def query_nebius(prompt, model_path, headers, payload, timeout):
|
| 31 |
+
"""Handler for Nebius API requests"""
|
| 32 |
+
api_url = f"https://router.huggingface.co/nebius/v1/text-to-image/{model_path}"
|
| 33 |
+
print(f"Making request to Nebius: {api_url}")
|
| 34 |
+
return requests.post(api_url, headers=headers, json=payload, timeout=timeout)
|
| 35 |
+
|
| 36 |
+
def query_replicate(prompt, model_path, headers, payload, timeout):
|
| 37 |
+
"""Handler for Replicate API requests"""
|
| 38 |
+
api_url = f"https://router.huggingface.co/replicate/v1/text-to-image/{model_path}"
|
| 39 |
+
print(f"Making request to Replicate: {api_url}")
|
| 40 |
+
return requests.post(api_url, headers=headers, json=payload, timeout=timeout)
|
| 41 |
+
|
| 42 |
+
def query_together(prompt, model_path, headers, payload, timeout):
|
| 43 |
+
"""Handler for Together API requests"""
|
| 44 |
+
api_url = f"https://router.huggingface.co/together/v1/text-to-image/{model_path}"
|
| 45 |
+
print(f"Making request to Together: {api_url}")
|
| 46 |
+
return requests.post(api_url, headers=headers, json=payload, timeout=timeout)
|
| 47 |
+
|
| 48 |
+
# Main query function
|
| 49 |
+
def query(prompt, model, custom_lora, is_negative=False, steps=35, cfg_scale=7, sampler="DPM++ 2M Karras",
|
| 50 |
+
seed=-1, strength=0.7, width=1024, height=1024, custom_api_key="", provider="hf-inference"):
|
| 51 |
# Debug log to indicate function start
|
| 52 |
print("Starting query function...")
|
| 53 |
# Print the parameters for debugging purposes
|
|
|
|
| 55 |
print(f"Model: {model}")
|
| 56 |
print(f"Custom LoRA: {custom_lora}")
|
| 57 |
print(f"Parameters - Steps: {steps}, CFG Scale: {cfg_scale}, Seed: {seed}, Strength: {strength}, Width: {width}, Height: {height}")
|
| 58 |
+
print(f"Provider: {provider}")
|
| 59 |
print(f"Custom API Key provided: {bool(custom_api_key.strip())}") # Log whether a custom key was provided without printing the key
|
| 60 |
|
| 61 |
# Check if the prompt is empty or None
|
|
|
|
| 72 |
print("USING CUSTOM API KEY: BYOK token provided by user is being used for authentication")
|
| 73 |
API_TOKEN = custom_api_key.strip()
|
| 74 |
else:
|
| 75 |
+
if provider == "hf-inference":
|
| 76 |
+
# Randomly select an API token from available options to distribute the load for HF Inference
|
| 77 |
+
API_TOKEN = random.choice([os.getenv("HF_READ_TOKEN"), os.getenv("HF_READ_TOKEN_2"),
|
| 78 |
+
os.getenv("HF_READ_TOKEN_3"), os.getenv("HF_READ_TOKEN_4"),
|
| 79 |
+
os.getenv("HF_READ_TOKEN_5")])
|
| 80 |
+
print("USING DEFAULT API KEY: Random environment variable token is being used for authentication")
|
| 81 |
+
else:
|
| 82 |
+
# For other providers, use the default HF token
|
| 83 |
+
API_TOKEN = HF_TOKEN
|
| 84 |
+
print("USING DEFAULT HF TOKEN: Environment variable HF_TOKEN is being used for authentication")
|
| 85 |
|
| 86 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
| 87 |
|
|
|
|
| 89 |
prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
| 90 |
print(f'Generation {key}: {prompt}') # Debug log
|
| 91 |
|
| 92 |
+
# Set the model path based on the selected model or custom LoRA
|
| 93 |
if custom_lora.strip() != "":
|
| 94 |
+
model_path = custom_lora.strip()
|
| 95 |
else:
|
| 96 |
+
# Map to select the appropriate model path
|
| 97 |
+
model_mapping = {
|
| 98 |
+
'Stable Diffusion XL': "stabilityai/stable-diffusion-xl-base-1.0",
|
| 99 |
+
'FLUX.1 [Dev]': "black-forest-labs/FLUX.1-dev",
|
| 100 |
+
'FLUX.1 [Schnell]': "black-forest-labs/FLUX.1-schnell",
|
| 101 |
+
'HiDream-I1-Full': "HiDream-ai/HiDream-I1-Full",
|
| 102 |
+
'HiDream-I1-Dev': "HiDream-ai/HiDream-I1-Dev",
|
| 103 |
+
'HiDream-I1-Fast': "HiDream-ai/HiDream-I1-Fast",
|
| 104 |
+
'Animagine 4.0': "cagliostrolab/animagine-xl-4.0",
|
| 105 |
+
'Flux Icon Kit': "strangerzonehf/Flux-Icon-Kit-LoRA",
|
| 106 |
+
'Pixel Background': "strangerzonehf/Flux-Pixel-Background-LoRA",
|
| 107 |
+
'Meme XD': "prithivMLmods/Flux-Meme-Xd-LoRA",
|
| 108 |
+
'Chill Guy': "prithivMLmods/Flux-Chill-Guy-Zone",
|
| 109 |
+
'Pepe': "openfree/pepe",
|
| 110 |
+
'NSFWmodel': "lexa862/NSFWmodel",
|
| 111 |
+
'Claude Art': "strangerzonehf/Flux-Claude-Art",
|
| 112 |
+
'Open Genmoji': "EvanZhouDev/open-genmoji",
|
| 113 |
+
'EBook Creative Cover': "prithivMLmods/EBook-Creative-Cover-Flux-LoRA",
|
| 114 |
+
'Flux Logo Design 2': "prithivMLmods/Logo-Design-Flux-LoRA",
|
| 115 |
+
'Isometric 3D': "strangerzonehf/Flux-Isometric-3D-LoRA",
|
| 116 |
+
'Flux Condensation': "fofr/flux-condensation",
|
| 117 |
+
'Flux Handwriting': "fofr/flux-handwriting",
|
| 118 |
+
'Shou Xin': "Datou1111/shou_xin",
|
| 119 |
+
'Sketch Smudge': "strangerzonehf/Flux-Sketch-Smudge-LoRA",
|
| 120 |
+
'80s Cyberpunk': "fofr/flux-80s-cyberpunk",
|
| 121 |
+
'Coloring Book Flux': "renderartist/coloringbookflux",
|
| 122 |
+
'Flux Miniature LoRA': "gokaygokay/Flux-Miniature-LoRA",
|
| 123 |
+
'Sketch Paint': "strangerzonehf/Sketch-Paint",
|
| 124 |
+
'Flux UltraRealism 2.0': "prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0",
|
| 125 |
+
'Midjourney Mix': "strangerzonehf/Flux-Midjourney-Mix-LoRA",
|
| 126 |
+
'Midjourney Mix 2': "strangerzonehf/Flux-Midjourney-Mix2-LoRA",
|
| 127 |
+
'Flux Logo Design': "Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design",
|
| 128 |
+
'Flux Uncensored': "enhanceaiteam/Flux-uncensored",
|
| 129 |
+
'Flux Uncensored V2': "enhanceaiteam/Flux-Uncensored-V2",
|
| 130 |
+
'Flux Tarot Cards': "prithivMLmods/Ton618-Tarot-Cards-Flux-LoRA",
|
| 131 |
+
'Pixel Art Sprites': "sWizad/pokemon-trainer-sprites-pixelart-flux",
|
| 132 |
+
'3D Sketchfab': "prithivMLmods/Castor-3D-Sketchfab-Flux-LoRA",
|
| 133 |
+
'Retro Comic Flux': "renderartist/retrocomicflux",
|
| 134 |
+
'Caricature': "TheAwakenOne/caricature",
|
| 135 |
+
'Huggieverse': "Chunte/flux-lora-Huggieverse",
|
| 136 |
+
'Propaganda Poster': "AlekseyCalvin/Propaganda_Poster_Schnell_by_doctor_diffusion",
|
| 137 |
+
'Flux Game Assets V2': "gokaygokay/Flux-Game-Assets-LoRA-v2",
|
| 138 |
+
'SDXL HS Card Style': "Norod78/sdxl-hearthstone-card-style-lora",
|
| 139 |
+
'SLDR FLUX NSFW v2 Studio': "xey/sldr_flux_nsfw_v2-studio",
|
| 140 |
+
'SoftPasty Flux': "alvdansen/softpasty-flux-dev",
|
| 141 |
+
'Flux Stickers': "diabolic6045/Flux_Sticker_Lora",
|
| 142 |
+
'Flux Animex V2': "strangerzonehf/Flux-Animex-v2-LoRA",
|
| 143 |
+
'Flux Animeo V1': "strangerzonehf/Flux-Animeo-v1-LoRA",
|
| 144 |
+
'Movie Board': "prithivMLmods/Flux.1-Dev-Movie-Boards-LoRA",
|
| 145 |
+
'Purple Dreamy': "prithivMLmods/Purple-Dreamy-Flux-LoRA",
|
| 146 |
+
'PS1 Style Flux': "veryVANYA/ps1-style-flux",
|
| 147 |
+
'Softserve Anime': "alvdansen/softserve_anime",
|
| 148 |
+
'Flux Tarot v1': "multimodalart/flux-tarot-v1",
|
| 149 |
+
'Half Illustration': "davisbro/half_illustration",
|
| 150 |
+
'OpenDalle v1.1': "dataautogpt3/OpenDalleV1.1",
|
| 151 |
+
'Flux Ghibsky Illustration': "aleksa-codes/flux-ghibsky-illustration",
|
| 152 |
+
'Flux Koda': "alvdansen/flux-koda",
|
| 153 |
+
'Soviet Diffusion XL': "openskyml/soviet-diffusion-xl",
|
| 154 |
+
'Flux Realism LoRA': "XLabs-AI/flux-RealismLora",
|
| 155 |
+
'Frosting Lane Flux': "alvdansen/frosting_lane_flux",
|
| 156 |
+
'Phantasma Anime': "alvdansen/phantasma-anime",
|
| 157 |
+
'Boreal': "kudzueye/Boreal",
|
| 158 |
+
'How2Draw': "glif/how2draw",
|
| 159 |
+
'Flux AestheticAnime': "dataautogpt3/FLUX-AestheticAnime",
|
| 160 |
+
'Fashion Hut Modeling LoRA': "prithivMLmods/Fashion-Hut-Modeling-LoRA",
|
| 161 |
+
'Flux SyntheticAnime': "dataautogpt3/FLUX-SyntheticAnime",
|
| 162 |
+
'Flux Midjourney Anime': "brushpenbob/flux-midjourney-anime",
|
| 163 |
+
'Coloring Book Generator': "robert123231/coloringbookgenerator",
|
| 164 |
+
'Collage Flux': "prithivMLmods/Castor-Collage-Dim-Flux-LoRA",
|
| 165 |
+
'Flux Product Ad Backdrop': "prithivMLmods/Flux-Product-Ad-Backdrop",
|
| 166 |
+
'Product Design': "multimodalart/product-design",
|
| 167 |
+
'90s Anime Art': "glif/90s-anime-art",
|
| 168 |
+
'Brain Melt Acid Art': "glif/Brain-Melt-Acid-Art",
|
| 169 |
+
'Lustly Flux Uncensored v1': "lustlyai/Flux_Lustly.ai_Uncensored_nsfw_v1",
|
| 170 |
+
'NSFW Master Flux': "Keltezaa/NSFW_MASTER_FLUX",
|
| 171 |
+
'Flux Outfit Generator': "tryonlabs/FLUX.1-dev-LoRA-Outfit-Generator",
|
| 172 |
+
'Midjourney': "Jovie/Midjourney",
|
| 173 |
+
'DreamPhotoGASM': "Yntec/DreamPhotoGASM",
|
| 174 |
+
'Flux Super Realism LoRA': "strangerzonehf/Flux-Super-Realism-LoRA",
|
| 175 |
+
'Stable Diffusion 2-1': "stabilityai/stable-diffusion-2-1-base",
|
| 176 |
+
'Stable Diffusion 3.5 Large': "stabilityai/stable-diffusion-3.5-large",
|
| 177 |
+
'Stable Diffusion 3.5 Large Turbo': "stabilityai/stable-diffusion-3.5-large-turbo",
|
| 178 |
+
'Stable Diffusion 3 Medium': "stabilityai/stable-diffusion-3-medium-diffusers",
|
| 179 |
+
'Duchaiten Real3D NSFW XL': "stablediffusionapi/duchaiten-real3d-nsfw-xl",
|
| 180 |
+
'Pixel Art XL': "nerijs/pixel-art-xl",
|
| 181 |
+
'Character Design': "KappaNeuro/character-design",
|
| 182 |
+
'Sketched Out Manga': "alvdansen/sketchedoutmanga",
|
| 183 |
+
'Archfey Anime': "alvdansen/archfey_anime",
|
| 184 |
+
'Lofi Cuties': "alvdansen/lofi-cuties",
|
| 185 |
+
'YiffyMix': "Yntec/YiffyMix",
|
| 186 |
+
'Analog Madness Realistic v7': "digiplay/AnalogMadness-realistic-model-v7",
|
| 187 |
+
'Selfie Photography': "artificialguybr/selfiephotographyredmond-selfie-photography-lora-for-sdxl",
|
| 188 |
+
'Filmgrain': "artificialguybr/filmgrain-redmond-filmgrain-lora-for-sdxl",
|
| 189 |
+
'Leonardo AI Style Illustration': "goofyai/Leonardo_Ai_Style_Illustration",
|
| 190 |
+
'Cyborg Style XL': "goofyai/cyborg_style_xl",
|
| 191 |
+
'Little Tinies': "alvdansen/littletinies",
|
| 192 |
+
'NSFW XL': "Dremmar/nsfw-xl",
|
| 193 |
+
'Analog Redmond': "artificialguybr/analogredmond",
|
| 194 |
+
'Pixel Art Redmond': "artificialguybr/PixelArtRedmond",
|
| 195 |
+
'Ascii Art': "CiroN2022/ascii-art",
|
| 196 |
+
'Analog': "Yntec/Analog",
|
| 197 |
+
'Maple Syrup': "Yntec/MapleSyrup",
|
| 198 |
+
'Perfect Lewd Fantasy': "digiplay/perfectLewdFantasy_v1.01",
|
| 199 |
+
'AbsoluteReality 1.8.1': "digiplay/AbsoluteReality_v1.8.1",
|
| 200 |
+
'Disney': "goofyai/disney_style_xl",
|
| 201 |
+
'Redmond SDXL': "artificialguybr/LogoRedmond-LogoLoraForSDXL-V2",
|
| 202 |
+
'epiCPhotoGasm': "Yntec/epiCPhotoGasm"
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
# Add special prompt prefixes for certain models
|
| 206 |
+
prompt_prefixes = {
|
| 207 |
+
'Animagine 4.0': "masterpiece, high score, great score, absurdres, ",
|
| 208 |
+
'Flux Icon Kit': "Icon Kit, ",
|
| 209 |
+
'Pixel Background': "Pixel Background, ",
|
| 210 |
+
'Meme XD': "meme, ",
|
| 211 |
+
'Chill Guy': "chill guy, ",
|
| 212 |
+
'Pepe': "pepe, ",
|
| 213 |
+
'NSFWmodel': "nude, ",
|
| 214 |
+
'Claude Art': "claude art, ",
|
| 215 |
+
'Open Genmoji': "emoji, ",
|
| 216 |
+
'EBook Creative Cover': "EBook Cover, ",
|
| 217 |
+
'Flux Logo Design 2': "Logo Design, ",
|
| 218 |
+
'Isometric 3D': "Isometric 3D, ",
|
| 219 |
+
'Flux Condensation': "CONDENSATION, ",
|
| 220 |
+
'Flux Handwriting': "HWRIT handwriting, ",
|
| 221 |
+
'Shou Xin': "shou_xin, pencil sketch, ",
|
| 222 |
+
'Sketch Smudge': "Sketch Smudge, ",
|
| 223 |
+
'80s Cyberpunk': "80s cyberpunk, ",
|
| 224 |
+
'Coloring Book Flux': "c0l0ringb00k, coloring book, coloring book page, ",
|
| 225 |
+
'Flux Miniature LoRA': "MNTR, miniature drawing, ",
|
| 226 |
+
'Sketch Paint': "Sketch paint, ",
|
| 227 |
+
'Flux UltraRealism 2.0': "Ultra realistic, ",
|
| 228 |
+
'Midjourney Mix': "midjourney mix, ",
|
| 229 |
+
'Midjourney Mix 2': "MJ v6, ",
|
| 230 |
+
'Flux Logo Design': "wablogo, logo, Minimalist, ",
|
| 231 |
+
'Flux Tarot Cards': "Tarot card, ",
|
| 232 |
+
'Pixel Art Sprites': "a pixel image, ",
|
| 233 |
+
'3D Sketchfab': "3D Sketchfab, ",
|
| 234 |
+
'Retro Comic Flux': "c0m1c, comic book panel, ",
|
| 235 |
+
'Caricature': "CCTUR3, ",
|
| 236 |
+
'Huggieverse': "HGGRE, ",
|
| 237 |
+
'Propaganda Poster': "propaganda poster, ",
|
| 238 |
+
'Flux Game Assets V2': "wbgmsst, white background, ",
|
| 239 |
+
'SDXL HS Card Style': "Hearthstone Card, ",
|
| 240 |
+
'SoftPasty Flux': "araminta_illus illustration style, ",
|
| 241 |
+
'Flux Stickers': "5t1cker 5ty1e, ",
|
| 242 |
+
'Flux Animex V2': "Animex, ",
|
| 243 |
+
'Flux Animeo V1': "Animeo, ",
|
| 244 |
+
'Movie Board': "movieboard, ",
|
| 245 |
+
'Purple Dreamy': "Purple Dreamy, ",
|
| 246 |
+
'PS1 Style Flux': "ps1 game screenshot, ",
|
| 247 |
+
'Softserve Anime': "sftsrv style illustration, ",
|
| 248 |
+
'Flux Tarot v1': "in the style of TOK a trtcrd tarot style, ",
|
| 249 |
+
'Half Illustration': "in the style of TOK, ",
|
| 250 |
+
'Flux Ghibsky Illustration': "GHIBSKY style, ",
|
| 251 |
+
'Flux Koda': "flmft style, ",
|
| 252 |
+
'Soviet Diffusion XL': "soviet poster, ",
|
| 253 |
+
'Frosting Lane Flux': "frstingln illustration, ",
|
| 254 |
+
'Boreal': "photo, ",
|
| 255 |
+
'How2Draw': "How2Draw, ",
|
| 256 |
+
'Fashion Hut Modeling LoRA': "Modeling of, ",
|
| 257 |
+
'Flux SyntheticAnime': "1980s anime screengrab, VHS quality, syntheticanime, ",
|
| 258 |
+
'Flux Midjourney Anime': "egmid, ",
|
| 259 |
+
'Collage Flux': "collage, ",
|
| 260 |
+
'Flux Product Ad Backdrop': "Product Ad, ",
|
| 261 |
+
'Product Design': "product designed by prdsgn, ",
|
| 262 |
+
'Brain Melt Acid Art': "maximalism, in an acid surrealism style, ",
|
| 263 |
+
'NSFW Master Flux': "NSFW, ",
|
| 264 |
+
'Stable Diffusion 3 Medium': "A, ",
|
| 265 |
+
'Pixel Art XL': "pixel art, ",
|
| 266 |
+
'Character Design': "Character Design, ",
|
| 267 |
+
'Sketched Out Manga': "daiton, ",
|
| 268 |
+
'Selfie Photography': "instagram model, discord profile picture, ",
|
| 269 |
+
'Filmgrain': "Film Grain, FilmGrainAF, ",
|
| 270 |
+
'Leonardo AI Style Illustration': "leonardo style, illustration, vector art, ",
|
| 271 |
+
'Cyborg Style XL': "cyborg style, ",
|
| 272 |
+
'Analog Redmond': "timeless style, ",
|
| 273 |
+
'Pixel Art Redmond': "Pixel Art, ",
|
| 274 |
+
'Ascii Art': "ascii art, ",
|
| 275 |
+
'Disney': "Disney style, "
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
# Get the model path from the mapping
|
| 279 |
+
model_path = model_mapping.get(model, "black-forest-labs/FLUX.1-schnell") # Default to FLUX.1 Schnell if not found
|
| 280 |
+
|
| 281 |
+
# Add model-specific prefixes to prompt if needed
|
| 282 |
+
if model in prompt_prefixes:
|
| 283 |
+
prompt = f"{prompt_prefixes[model]}{prompt}"
|
| 284 |
+
|
| 285 |
+
print(f"Model path: {model_path}") # Debug log
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
# Define the payload for the request
|
| 288 |
payload = {
|
|
|
|
| 299 |
}
|
| 300 |
print(f"Payload: {json.dumps(payload, indent=2)}") # Debug log
|
| 301 |
|
| 302 |
+
# Select the appropriate API handler based on the provider
|
| 303 |
+
provider_handlers = {
|
| 304 |
+
"hf-inference": query_hf_inference,
|
| 305 |
+
"fal-ai": query_fal_ai,
|
| 306 |
+
"nebius": query_nebius,
|
| 307 |
+
"replicate": query_replicate,
|
| 308 |
+
"together": query_together
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
# Get the appropriate handler for the selected provider
|
| 312 |
+
handler = provider_handlers.get(provider, query_hf_inference)
|
| 313 |
+
|
| 314 |
+
# Make a request to the API to generate the image using the selected handler
|
| 315 |
try:
|
| 316 |
+
response = handler(prompt, model_path, headers, payload, timeout)
|
| 317 |
print(f"Response status code: {response.status_code}") # Debug log
|
| 318 |
except requests.exceptions.RequestException as e:
|
| 319 |
# Log any request exceptions and raise an error for the user
|
|
|
|
| 495 |
# Tab for advanced settings
|
| 496 |
with gr.Tab("Advanced Settings"):
|
| 497 |
with gr.Row():
|
| 498 |
+
# Provider selection
|
| 499 |
+
provider_radio = gr.Radio(
|
| 500 |
+
choices=["hf-inference", "fal-ai", "nebius", "replicate", "together"],
|
| 501 |
+
value="hf-inference",
|
| 502 |
+
label="Inference Provider",
|
| 503 |
+
info="Select the provider to use for image generation"
|
| 504 |
+
)
|
| 505 |
with gr.Row():
|
| 506 |
+
# BYOK (Bring Your Own Key) textbox
|
| 507 |
byok_textbox = gr.Textbox(
|
| 508 |
value="",
|
| 509 |
label="BYOK (Bring Your Own Key)",
|
| 510 |
+
info="Enter a custom API key here. When provided, this key will be used instead of the default keys.",
|
| 511 |
+
placeholder="Enter your API token",
|
| 512 |
type="password", # Hide the API key for security
|
| 513 |
elem_id="byok-input"
|
| 514 |
)
|
| 515 |
+
with gr.Row():
|
| 516 |
+
# Textbox for specifying elements to exclude from the image
|
| 517 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")
|
| 518 |
with gr.Row():
|
| 519 |
# Slider for selecting the image width
|
| 520 |
width = gr.Slider(label="Width", value=1024, minimum=64, maximum=1216, step=32)
|
|
|
|
| 536 |
# Radio buttons for selecting the sampling method
|
| 537 |
method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
|
| 538 |
|
| 539 |
+
# Function to validate provider selection
|
| 540 |
+
def validate_provider(api_key, provider):
|
| 541 |
+
# If custom key is provided, any provider can be used
|
| 542 |
+
if api_key.strip():
|
| 543 |
+
return gr.update(value=provider, interactive=True)
|
| 544 |
+
# If no custom key is provided, only HF Inference is allowed
|
| 545 |
+
elif provider != "hf-inference":
|
| 546 |
+
return gr.update(value="hf-inference", interactive=True)
|
| 547 |
+
return gr.update(value=provider, interactive=True)
|
| 548 |
+
|
| 549 |
+
# Connect the BYOK textbox to validate provider selection
|
| 550 |
+
byok_textbox.change(
|
| 551 |
+
fn=validate_provider,
|
| 552 |
+
inputs=[byok_textbox, provider_radio],
|
| 553 |
+
outputs=provider_radio
|
| 554 |
+
)
|
| 555 |
+
|
| 556 |
# Tab for image editing options
|
| 557 |
with gr.Tab("Image Editor"):
|
| 558 |
# Function to simulate a delay for processing
|
|
|
|
| 610 |
"""
|
| 611 |
)
|
| 612 |
|
| 613 |
+
# Accordion providing an overview of providers
|
| 614 |
+
with gr.Accordion("Providers Information", open=False):
|
| 615 |
+
gr.Markdown(
|
| 616 |
+
"""
|
| 617 |
+
## Inference Providers
|
| 618 |
+
|
| 619 |
+
This application supports multiple inference providers for image generation:
|
| 620 |
+
|
| 621 |
+
### HF Inference
|
| 622 |
+
###### The default Hugging Face Inference API. This is a serverless solution that allows you to run model inference on Hugging Face's infrastructure. Free to use with limitations.
|
| 623 |
+
|
| 624 |
+
### Fal AI
|
| 625 |
+
###### Fal AI provides optimized inference for image generation models. May offer better performance for certain model types.
|
| 626 |
+
|
| 627 |
+
### Nebius
|
| 628 |
+
###### Nebius AI is a technology company specializing in AI-centric cloud platforms, offering scalable GPU clusters for inference.
|
| 629 |
+
|
| 630 |
+
### Replicate
|
| 631 |
+
###### Replicate's API makes it easy to run machine learning models in the cloud with a simple API.
|
| 632 |
+
|
| 633 |
+
### Together
|
| 634 |
+
###### Together AI offers high-performance inference for various AI models.
|
| 635 |
+
|
| 636 |
+
When no custom API key is provided, only HF Inference can be used. For other providers, you must bring your own API key.
|
| 637 |
+
"""
|
| 638 |
+
)
|
| 639 |
+
|
| 640 |
# Accordion providing an overview of advanced settings
|
| 641 |
with gr.Accordion("Advanced Settings Overview", open=False):
|
| 642 |
gr.Markdown(
|
| 643 |
"""
|
| 644 |
+
## Inference Provider
|
| 645 |
+
###### Select which provider to use for image generation. Each provider has different performance characteristics and model availability.
|
| 646 |
+
|
| 647 |
+
## BYOK (Bring Your Own Key)
|
| 648 |
+
###### This allows you to use your own API key instead of the default keys. Enter your key here for direct access to models using your account's permissions and rate limits.
|
| 649 |
+
|
| 650 |
## Negative Prompt
|
| 651 |
###### This box is for telling the AI what you don't want in your images. Think of it as a way to avoid certain elements. For instance, if you don't want blurry images or extra limbs showing up, this is where you'd mention it.
|
| 652 |
|
|
|
|
|
|
|
|
|
|
| 653 |
## Width & Height
|
| 654 |
###### These sliders allow you to specify the resolution of your image. Default value is 1024x1024, and maximum output is 1216x1216.
|
| 655 |
|
|
|
|
| 679 |
with gr.Row():
|
| 680 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
| 681 |
|
| 682 |
+
# Set up button click event to call the query function with the provider and BYOK parameters
|
| 683 |
+
text_button.click(query, inputs=[text_prompt, model, custom_lora, negative_prompt, steps, cfg, method, seed, strength, width, height, byok_textbox, provider_radio], outputs=image_output)
|
| 684 |
|
| 685 |
print("Launching Gradio interface...") # Debug log
|
| 686 |
# Launch the Gradio interface without showing the API or sharing externally
|