Update app.py
Browse fileschanged launch() share=True, changed default cfg to 12, changed a comment and title on page.
app.py
CHANGED
@@ -8,7 +8,7 @@ from PIL import Image
|
|
8 |
from deep_translator import GoogleTranslator
|
9 |
import json
|
10 |
|
11 |
-
# Project by Nymbo
|
12 |
|
13 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
14 |
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
@@ -16,7 +16,7 @@ headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
|
16 |
timeout = 100
|
17 |
|
18 |
# Function to query the API and return the generated image
|
19 |
-
def query(prompt, is_negative=False, steps=30, cfg_scale=
|
20 |
if prompt == "" or prompt is None:
|
21 |
return None
|
22 |
|
@@ -75,10 +75,12 @@ css = """
|
|
75 |
}
|
76 |
"""
|
77 |
|
|
|
|
|
78 |
# Build the Gradio UI with Blocks
|
79 |
with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
80 |
# Add a title to the app
|
81 |
-
gr.HTML("<center><h1>FLUX.1
|
82 |
|
83 |
# Container for all the UI elements
|
84 |
with gr.Column(elem_id="app-container"):
|
@@ -88,15 +90,21 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
88 |
with gr.Row():
|
89 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
# Accordion for advanced settings
|
92 |
with gr.Row():
|
93 |
-
with gr.Accordion("Advanced Settings", open=
|
94 |
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")
|
95 |
with gr.Row():
|
96 |
width = gr.Slider(label="Width", value=1024, minimum=64, maximum=1216, step=32)
|
97 |
height = gr.Slider(label="Height", value=1024, minimum=64, maximum=1216, step=32)
|
98 |
-
steps = gr.Slider(label="Sampling steps", value=
|
99 |
-
cfg = gr.Slider(label="CFG Scale", value=
|
100 |
strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
|
101 |
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1) # Setting the seed to -1 will make it random
|
102 |
method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
|
@@ -113,4 +121,4 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
113 |
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
|
114 |
|
115 |
# Launch the Gradio app
|
116 |
-
app.launch(show_api=False, share=
|
|
|
8 |
from deep_translator import GoogleTranslator
|
9 |
import json
|
10 |
|
11 |
+
# Project by Nymbo, dubious alterations by Twinwaffle
|
12 |
|
13 |
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
14 |
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
|
|
16 |
timeout = 100
|
17 |
|
18 |
# Function to query the API and return the generated image
|
19 |
+
def query(prompt, is_negative=False, steps=30, cfg_scale=12, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, width=1024, height=1024):
|
20 |
if prompt == "" or prompt is None:
|
21 |
return None
|
22 |
|
|
|
75 |
}
|
76 |
"""
|
77 |
|
78 |
+
|
79 |
+
|
80 |
# Build the Gradio UI with Blocks
|
81 |
with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
82 |
# Add a title to the app
|
83 |
+
gr.HTML("<center><h1>Serverless FLUX.1 Schnell Copy</h1></center>")
|
84 |
|
85 |
# Container for all the UI elements
|
86 |
with gr.Column(elem_id="app-container"):
|
|
|
90 |
with gr.Row():
|
91 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
92 |
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
# Accordion for advanced settings
|
100 |
with gr.Row():
|
101 |
+
with gr.Accordion("Advanced Settings", open=True):
|
102 |
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")
|
103 |
with gr.Row():
|
104 |
width = gr.Slider(label="Width", value=1024, minimum=64, maximum=1216, step=32)
|
105 |
height = gr.Slider(label="Height", value=1024, minimum=64, maximum=1216, step=32)
|
106 |
+
steps = gr.Slider(label="Sampling steps", value=8, minimum=1, maximum=100, step=1)
|
107 |
+
cfg = gr.Slider(label="CFG Scale", value=12, minimum=1, maximum=20, step=1)
|
108 |
strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
|
109 |
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1) # Setting the seed to -1 will make it random
|
110 |
method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
|
|
|
121 |
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
|
122 |
|
123 |
# Launch the Gradio app
|
124 |
+
app.launch(show_api=False, share=True)
|