Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -28,15 +28,13 @@ API_TOKEN = os.getenv("HF_READ_TOKEN")
|
|
28 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
29 |
timeout = 100
|
30 |
|
31 |
-
NUM_IMAGES_PER_PROMPT = 2
|
32 |
-
|
33 |
def flip_image(x):
|
34 |
return np.fliplr(x)
|
35 |
|
36 |
def clear():
|
37 |
return None
|
38 |
|
39 |
-
def
|
40 |
if prompt == "" or prompt == None:
|
41 |
return None
|
42 |
|
@@ -70,7 +68,6 @@ def result(lora_id, prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler=
|
|
70 |
"cfg_scale": cfg_scale,
|
71 |
"seed": seed if seed != -1 else random.randint(1, 1000000000),
|
72 |
"strength": strength,
|
73 |
-
"num_images_per_prompt": NUM_IMAGES_PER_PROMPT,
|
74 |
"parameters": {
|
75 |
"width": width, # Pass the width to the API
|
76 |
"height": height # Pass the height to the API
|
@@ -115,80 +112,76 @@ with gr.Blocks(theme=theme, css=css, elem_id="app-container") as app:
|
|
115 |
with gr.Column(elem_id="app-container"):
|
116 |
with gr.Row():
|
117 |
with gr.Column(elem_id="prompt-container"):
|
118 |
-
with gr.
|
119 |
-
|
120 |
-
|
121 |
-
with gr.
|
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 |
-
with gr.
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
#seed_output = gr.Textbox(label="Seed Used", show_copy_button = True, elem_id="seed-output")
|
161 |
-
|
162 |
-
with gr.Group():
|
163 |
-
with gr.Row():
|
164 |
-
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
165 |
-
#result = gr.Gallery(label="Result", columns=1, preview=True)
|
166 |
-
clr_button =gr.Button("Clear Prompt",variant="primary", elem_id="clear_button")
|
167 |
-
clr_button.click(lambda: gr.Textbox(value=""), None, text_prompt)
|
168 |
-
|
169 |
-
with gr.Row():
|
170 |
-
image_output = gr.Image(type="pil", label="Image Output", format="png", show_share_button=False, elem_id="gallery")
|
171 |
-
with gr.Row():
|
172 |
-
clear_btn = gr.Button(value="Clear Image", variant="primary", elem_id="clear_button")
|
173 |
-
clear_btn.click(clear, inputs=[], outputs=[image_output])
|
174 |
-
|
175 |
-
gr.Examples(
|
176 |
-
examples = examples,
|
177 |
-
inputs = [text_prompt],
|
178 |
-
outputs=[result, seed],
|
179 |
-
)
|
180 |
-
|
181 |
-
text_button.click(result, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=[image_output, num_images_per_prompt, seed_output])
|
182 |
-
|
183 |
-
with gr.Tab("Flip Image"):
|
184 |
with gr.Row():
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
image_button = gr.Button("Run", variant='primary')
|
189 |
-
image_button.click(flip_image, inputs=image_input, outputs=image_output, concurrency_limit=2)
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
|
|
28 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
29 |
timeout = 100
|
30 |
|
|
|
|
|
31 |
def flip_image(x):
|
32 |
return np.fliplr(x)
|
33 |
|
34 |
def clear():
|
35 |
return None
|
36 |
|
37 |
+
def query(lora_id, prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="DPM++ 2M Karras", seed=-1, strength=100, width=896, height=1152):
|
38 |
if prompt == "" or prompt == None:
|
39 |
return None
|
40 |
|
|
|
68 |
"cfg_scale": cfg_scale,
|
69 |
"seed": seed if seed != -1 else random.randint(1, 1000000000),
|
70 |
"strength": strength,
|
|
|
71 |
"parameters": {
|
72 |
"width": width, # Pass the width to the API
|
73 |
"height": height # Pass the height to the API
|
|
|
112 |
with gr.Column(elem_id="app-container"):
|
113 |
with gr.Row():
|
114 |
with gr.Column(elem_id="prompt-container"):
|
115 |
+
with gr.Row():
|
116 |
+
text_prompt = gr.Textbox(label="Image Prompt", placeholder="Enter a prompt here", lines=2, show_copy_button = True, elem_id="prompt-text-input")
|
117 |
+
with gr.Row():
|
118 |
+
with gr.Accordion("🎨 Lora trigger words", open=False):
|
119 |
+
gr.Markdown("""
|
120 |
+
- **sdxl-realistic**: szn style
|
121 |
+
- **Flux-Realism-FineDetailed**: Fine Detailed
|
122 |
+
- **Fashion-Hut-Modeling-LoRA**: Modeling
|
123 |
+
- **SD3.5-Large-Turbo-HyperRealistic-LoRA**: hyper realistic
|
124 |
+
- **Flux-Fine-Detail-LoRA**: Super Detail
|
125 |
+
- **SD3.5-Turbo-Realism-2.0-LoRA**: Turbo Realism
|
126 |
+
- **Canopus-LoRA-Flux-UltraRealism-2.0**: Ultra realistic
|
127 |
+
- **extremely-detailed**: extremely detailed
|
128 |
+
- **SD3.5-Large-Photorealistic-LoRA**: photorealistic
|
129 |
+
- **Flux.1-Dev-LoRA-HDR-Realism**: HDR
|
130 |
+
- **prithivMLmods/Ton618-Epic-Realism-Flux-LoRA**: Epic Realism
|
131 |
+
- **john-singer-sargent-style**: John Singer Sargent Style
|
132 |
+
- **alphonse-mucha-style**: Alphonse Mucha Style
|
133 |
+
- **ultra-realistic-illustration**: ultra realistic illustration
|
134 |
+
- **eye-catching**: eye-catching
|
135 |
+
- **john-constable-style**: John Constable Style
|
136 |
+
- **film-noir**: in the style of FLMNR
|
137 |
+
- **flux-lora-pro-headshot**: PROHEADSHOT
|
138 |
+
""")
|
139 |
+
|
140 |
+
with gr.Row():
|
141 |
+
custom_lora = gr.Dropdown([" ", "jwu114/lora-sdxl-realistic", "prithivMLmods/Flux-Realism-FineDetailed", "prithivMLmods/Fashion-Hut-Modeling-LoRA", "prithivMLmods/SD3.5-Large-Turbo-HyperRealistic-LoRA", "prithivMLmods/Flux-Fine-Detail-LoRA", "prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA", "hugovntr/flux-schnell-realism", "fofr/sdxl-deep-down", "prithivMLmods/Canopus-LoRA-Flux-UltraRealism-2.0", "ntc-ai/SDXL-LoRA-slider.extremely-detailed", "prithivMLmods/Canopus-LoRA-Flux-FaceRealism", "prithivMLmods/SD3.5-Large-Photorealistic-LoRA", "prithivMLmods/Flux.1-Dev-LoRA-HDR-Realism", "prithivMLmods/Ton618-Epic-Realism-Flux-LoRA", "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", "dvyio/flux-lora-pro-headshot"], label="Custom LoRA",)
|
142 |
+
with gr.Row():
|
143 |
+
with gr.Accordion("⚙️ Advanced Settings", open=False, elem_id="settings-container"):
|
144 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", lines=5, placeholder="What should not be in the image", value=" (visible hand:1.3), (ugly:1.3), (duplicate:1.2), (morbid:1.1), (mutilated:1.1), out of frame, bad face, extra fingers, mutated hands, (poorly drawn hands:1.1), (poorly drawn face:1.3), (mutation:1.3), (deformed:1.3), blurry, (bad anatomy:1.1), (bad proportions:1.2), (extra limbs:1.1), cloned face, (disfigured:1.2), gross proportions, malformed limbs, (missing arms:1.1), (missing legs:1.1), (extra arms:1.2), (extra legs:1.2), fused fingers, too many fingers, (long neck:1.2), sketched by bad-artist, (bad-image-v2-39000:1.3) ")
|
145 |
+
with gr.Row():
|
146 |
+
width = gr.Slider(label="Image Width", value=896, minimum=64, maximum=1216, step=32)
|
147 |
+
height = gr.Slider(label="Image Height", value=1152, minimum=64, maximum=1216, step=32)
|
148 |
+
strength = gr.Slider(label="Prompt Strength", value=100, minimum=0, maximum=100, step=1)
|
149 |
+
steps = gr.Slider(label="Sampling steps", value=50, minimum=1, maximum=100, step=1)
|
150 |
+
cfg = gr.Slider(label="CFG Scale", value=3.5, minimum=1, maximum=20, step=0.5)
|
151 |
+
seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
|
152 |
+
method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "DEIS", "LMS", "DPM Adaptive", "DPM++ 2M", "DPM2 Ancestral", "DPM++ S", "DPM++ SDE", "DDPM", "DPM Fast", "dpmpp_2s_ancestral", "Euler", "Euler CFG PP", "Euler a", "Euler Ancestral", "Euler+beta", "Heun", "Heun PP2", "DDIM", "PLMS", "UniPC", "UniPC BH2"])
|
153 |
+
with gr.Row():
|
154 |
+
with gr.Accordion("🫘Seed", open=False):
|
155 |
+
seed_output = gr.Textbox(label="Seed Used", show_copy_button = True, elem_id="seed-output")
|
156 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
with gr.Row():
|
158 |
+
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
159 |
+
clr_button =gr.Button("Clear Prompt",variant="primary", elem_id="clear_button")
|
160 |
+
clr_button.click(lambda: gr.Textbox(value=""), None, text_prompt)
|
|
|
|
|
161 |
|
162 |
+
with gr.Row():
|
163 |
+
image_output = gr.Image(type="pil", label="Image Output", format="png", show_share_button=False, elem_id="gallery")
|
164 |
+
with gr.Row():
|
165 |
+
clear_btn = gr.Button(value="Clear Image", variant="primary", elem_id="clear_button")
|
166 |
+
clear_btn.click(clear, inputs=[], outputs=[image_output])
|
167 |
+
|
168 |
+
gr.Examples(
|
169 |
+
examples = examples,
|
170 |
+
inputs = [text_prompt],
|
171 |
+
)
|
172 |
+
|
173 |
+
text_button.click(query, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=[image_output, seed_output])
|
174 |
+
|
175 |
+
with gr.Tab("Flip Image"):
|
176 |
+
with gr.Row():
|
177 |
+
image_input = gr.Image()
|
178 |
+
image_output = gr.Image(format="png")
|
179 |
+
with gr.Row():
|
180 |
+
image_button = gr.Button("Run", variant='primary')
|
181 |
+
image_button.click(flip_image, inputs=image_input, outputs=image_output, concurrency_limit=2)
|
182 |
+
|
183 |
+
app.queue(default_concurrency_limit=200, max_size=200) # <-- Sets up a queue with default parameters
|
184 |
+
if __name__ == "__main__":
|
185 |
+
app.launch(show_api=False, share=False)
|
186 |
+
|
187 |
|