Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -51,21 +51,8 @@ API_TOKEN = os.getenv("HF_READ_TOKEN")
|
|
51 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
52 |
timeout = 100
|
53 |
|
54 |
-
article_text = """
|
55 |
-
<div style="text-align: center;">
|
56 |
-
<p>Enjoying the tool? Buy me a coffee and get exclusive prompt guides!</p>
|
57 |
-
<p><i>Instantly unlock helpful tips for creating better prompts!</i></p>
|
58 |
-
<div style="display: flex; justify-content: center;">
|
59 |
-
<a href="https://piczify.lemonsqueezy.com/buy/0f5206fa-68e8-42f6-9ca8-4f80c587c83e">
|
60 |
-
<img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png"
|
61 |
-
alt="Buy Me a Coffee"
|
62 |
-
style="height: 40px; width: auto; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); border-radius: 10px;">
|
63 |
-
</a>
|
64 |
-
</div>
|
65 |
-
</div>
|
66 |
-
"""
|
67 |
|
68 |
-
def query(lora_id, prompt, steps=28, cfg_scale=3.5,
|
69 |
if prompt == "" or prompt == None:
|
70 |
return None
|
71 |
|
@@ -86,14 +73,16 @@ def query(lora_id, prompt, steps=28, cfg_scale=3.5, randomize_seed=True, seed=-1
|
|
86 |
# print(f'\033[1mGeneration {key}:\033[0m {prompt}')
|
87 |
|
88 |
# If seed is -1, generate a random seed and use it
|
89 |
-
|
90 |
-
seed = random.randint(1,
|
91 |
-
|
92 |
-
|
93 |
"inputs": prompt,
|
|
|
94 |
"steps": steps,
|
95 |
"cfg_scale": cfg_scale,
|
96 |
-
"seed": seed,
|
|
|
97 |
"parameters": {
|
98 |
"width": width, # Pass the width to the API
|
99 |
"height": height # Pass the height to the API
|
@@ -119,48 +108,75 @@ def query(lora_id, prompt, steps=28, cfg_scale=3.5, randomize_seed=True, seed=-1
|
|
119 |
|
120 |
|
121 |
examples = [
|
122 |
-
"a
|
123 |
-
"a
|
124 |
-
"
|
125 |
]
|
126 |
|
127 |
css = """
|
128 |
#app-container {
|
129 |
-
max-width:
|
130 |
margin-left: auto;
|
131 |
margin-right: auto;
|
|
|
132 |
}
|
|
|
133 |
"""
|
134 |
|
135 |
-
with gr.Blocks(theme=theme, css=css) as app:
|
136 |
-
gr.HTML("<center><
|
137 |
-
with gr.
|
138 |
-
with gr.
|
139 |
-
with gr.
|
140 |
-
with gr.
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
steps = gr.Slider(label="Sampling steps", value=28, minimum=1, maximum=100, step=1)
|
153 |
cfg = gr.Slider(label="CFG Scale", value=3.5, minimum=1, maximum=20, step=0.5)
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
gr.Examples(
|
166 |
examples = examples,
|
@@ -168,6 +184,6 @@ with gr.Blocks(theme=theme, css=css) as app:
|
|
168 |
)
|
169 |
|
170 |
|
171 |
-
text_button.click(query, inputs=[custom_lora, text_prompt, steps, cfg,
|
172 |
|
173 |
app.launch(show_api=False, share=False)
|
|
|
51 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
52 |
timeout = 100
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
def query(lora_id, prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, width=1024, height=1024):
|
56 |
if prompt == "" or prompt == None:
|
57 |
return None
|
58 |
|
|
|
73 |
# print(f'\033[1mGeneration {key}:\033[0m {prompt}')
|
74 |
|
75 |
# If seed is -1, generate a random seed and use it
|
76 |
+
if seed == -1:
|
77 |
+
seed = random.randint(1, 1000000000)
|
78 |
+
|
79 |
+
payload = {
|
80 |
"inputs": prompt,
|
81 |
+
"is_negative": is_negative,
|
82 |
"steps": steps,
|
83 |
"cfg_scale": cfg_scale,
|
84 |
+
"seed": seed if seed != -1 else random.randint(1, 1000000000),
|
85 |
+
"strength": strength,
|
86 |
"parameters": {
|
87 |
"width": width, # Pass the width to the API
|
88 |
"height": height # Pass the height to the API
|
|
|
108 |
|
109 |
|
110 |
examples = [
|
111 |
+
"a beautiful woman with blonde hair and blue eyes",
|
112 |
+
"a beautiful woman with brown hair and grey eyes",
|
113 |
+
"a beautiful woman with black hair and brown eyes",
|
114 |
]
|
115 |
|
116 |
css = """
|
117 |
#app-container {
|
118 |
+
max-width: 896px;
|
119 |
margin-left: auto;
|
120 |
margin-right: auto;
|
121 |
+
body{background-image:"FLUX.Dev-LORA-Serverless/abstract.jpg";}
|
122 |
}
|
123 |
+
|
124 |
"""
|
125 |
|
126 |
+
with gr.Blocks(theme=theme, css=css, elem_id="app-container") as app:
|
127 |
+
gr.HTML("<center><h6>🎨 FLUX.1-Dev with LoRA ++ 🇬🇧</h6></center>")
|
128 |
+
with gr.Tab("Text to Image"):
|
129 |
+
with gr.Column(elem_id="app-container"):
|
130 |
+
with gr.Row():
|
131 |
+
with gr.Column(elem_id="prompt-container"):
|
132 |
+
with gr.Row():
|
133 |
+
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
134 |
+
with gr.Row():
|
135 |
+
with gr.Accordion("Lora trigger words", open=False):
|
136 |
+
gr.Markdown("""
|
137 |
+
- **sdxl-realistic**: szn style
|
138 |
+
- **stylesdxl-cyberpunk**: szn style
|
139 |
+
- **maxfield-parrish-stylee**: Maxfield Parrish Style
|
140 |
+
- **surreal-harmony**: Surreal Harmony
|
141 |
+
- **extremely-detailed**: extremely detailed
|
142 |
+
- **dark-fantasy**: Dark Fantasy
|
143 |
+
- **analogredmond**: AnalogRedmAF
|
144 |
+
- **jules-bastien-lepage-style**: Jules Bastien Lepage Style
|
145 |
+
- **john-singer-sargent-style**: John Singer Sargent Style
|
146 |
+
- **alphonse-mucha-style**: Alphonse Mucha Style
|
147 |
+
- **ultra-realistic-illustration**: ultra realistic illustration
|
148 |
+
- **eye-catching**: eye-catching
|
149 |
+
- **john-constable-style**: John Constable Style
|
150 |
+
- **film-noir**: in the style of FLMNR
|
151 |
+
- **director-sofia-coppola-style**: Director Sofia Coppola Style
|
152 |
+
""",
|
153 |
+
label="Trigger words")
|
154 |
+
|
155 |
+
with gr.Row():
|
156 |
+
custom_lora = gr.Dropdown([" ", "jwu114/lora-sdxl-realistic", "issaccyj/lora-sdxl-cyberpunk", "KappaNeuro/maxfield-parrish-style", "fofr/sdxl-deep-down", "KappaNeuro/surreal-harmony", "ntc-ai/SDXL-LoRA-slider.extremely-detailed", "prithivMLmods/Canopus-LoRA-Flux-FaceRealism", "KappaNeuro/dark-fantasy", "artificialguybr/analogredmond", "KappaNeuro/jules-bastien-lepage-style", "KappaNeuro/john-singer-sargent-style", "KappaNeuro/alphonse-mucha-style", "ntc-ai/SDXL-LoRA-slider.ultra-realistic-illustration", "ntc-ai/SDXL-LoRA-slider.eye-catching", "KappaNeuro/john-constable-style", "dvyio/flux-lora-film-noir", "KappaNeuro/director-sofia-coppola-style"], label="Custom LoRA (Please select)",)
|
157 |
+
with gr.Row():
|
158 |
+
with gr.Accordion("⚙️ Advanced Settings", open=False, elem_id="settings-container"):
|
159 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="((((out of frame))), 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")
|
160 |
+
with gr.Row():
|
161 |
+
width = gr.Slider(label="Width", value=1024, minimum=64, maximum=1216, step=32)
|
162 |
+
height = gr.Slider(label="Height", value=1024, minimum=64, maximum=1216, step=32)
|
163 |
steps = gr.Slider(label="Sampling steps", value=28, minimum=1, maximum=100, step=1)
|
164 |
cfg = gr.Slider(label="CFG Scale", value=3.5, minimum=1, maximum=20, step=0.5)
|
165 |
+
method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "DPM Fast" "Euler", "Euler a", "Euler+beta", "Heun", "DDIM", "PLMS", "UniPC"])
|
166 |
+
strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
|
167 |
+
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
|
168 |
+
with gr.Row():
|
169 |
+
with gr.Accordion("🫘Seed", open=False):
|
170 |
+
seed_output = gr.Textbox(label="Seed Used", show_copy_button = True, elem_id="seed-output")
|
171 |
+
|
172 |
+
with gr.Row():
|
173 |
+
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
174 |
+
with gr.Row():
|
175 |
+
clr_button =gr.Button("Clear",variant="primary", elem_id="clear_button")
|
176 |
+
clr_button.click(lambda: gr.Textbox(value=""), None, text_prompt)
|
177 |
+
|
178 |
+
with gr.Row():
|
179 |
+
image_output = gr.Image(type="pil", label="Image Output", format="png", elem_id="gallery")
|
180 |
|
181 |
gr.Examples(
|
182 |
examples = examples,
|
|
|
184 |
)
|
185 |
|
186 |
|
187 |
+
text_button.click(query, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=[image_output, seed_output])
|
188 |
|
189 |
app.launch(show_api=False, share=False)
|