DigiP-AI commited on
Commit
bd6d12d
·
verified ·
1 Parent(s): 3eb3ca8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -95
app.py CHANGED
@@ -8,44 +8,6 @@ from PIL import Image
8
  from deep_translator import GoogleTranslator
9
  import json
10
 
11
- from fastapi import FastAPI
12
-
13
- app = FastAPI()
14
-
15
- #----------Start of theme----------
16
- theme = gr.themes.Soft(
17
- primary_hue="zinc",
18
- secondary_hue="stone",
19
- font=[gr.themes.GoogleFont('Kavivanar'), gr.themes.GoogleFont('Kavivanar'), 'system-ui', 'sans-serif'],
20
- font_mono=[gr.themes.GoogleFont('Source Code Pro'), gr.themes.GoogleFont('Inconsolata'), gr.themes.GoogleFont('Inconsolata'), 'monospace'],
21
- ).set(
22
- body_background_fill='*primary_100',
23
- body_text_color='secondary_600',
24
- body_text_color_subdued='*primary_500',
25
- body_text_weight='500',
26
- background_fill_primary='*primary_100',
27
- background_fill_secondary='*secondary_200',
28
- color_accent='*primary_300',
29
- border_color_accent_subdued='*primary_400',
30
- border_color_primary='*primary_400',
31
- block_background_fill='*primary_300',
32
- block_border_width='*panel_border_width',
33
- block_info_text_color='*primary_700',
34
- block_info_text_size='*text_md',
35
- panel_background_fill='*primary_200',
36
- accordion_text_color='*primary_600',
37
- table_text_color='*primary_600',
38
- input_background_fill='*primary_50',
39
- input_background_fill_focus='*primary_100',
40
- button_primary_background_fill='*primary_500',
41
- button_primary_background_fill_hover='*primary_400',
42
- button_primary_text_color='*primary_50',
43
- button_primary_text_color_hover='*primary_100',
44
- button_cancel_background_fill='*primary_500',
45
- button_cancel_background_fill_hover='*primary_400'
46
- )
47
- #----------End of theme----------
48
-
49
 
50
  API_TOKEN = os.getenv("HF_READ_TOKEN")
51
  headers = {"Authorization": f"Bearer {API_TOKEN}"}
@@ -126,71 +88,48 @@ examples = [
126
 
127
  css = """
128
  #app-container {
129
- max-width: 896px;
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><h1>FLUX.1-Dev with LoRA support</h1></center>")
137
  with gr.Column(elem_id="app-container"):
138
- with gr.Row():
139
- with gr.Column(elem_id="prompt-container"):
140
- with gr.Row():
141
- text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
142
- with gr.Row():
143
- with gr.Accordion("Lora trigger words", open=False):
144
- gr.Markdown("""
145
- - **sdxl-realistic**: szn style
146
- - **stylesdxl-cyberpunk**: szn style
147
- - **maxfield-parrish-stylee**: Maxfield Parrish Style
148
- - **surreal-harmony**: Surreal Harmony
149
- - **extremely-detailed**: extremely detailed
150
- - **dark-fantasy**: Dark Fantasy
151
- - **analogredmond**: AnalogRedmAF
152
- - **jules-bastien-lepage-style**: Jules Bastien Lepage Style
153
- - **john-singer-sargent-style**: John Singer Sargent Style
154
- - **alphonse-mucha-style**: Alphonse Mucha Style
155
- - **ultra-realistic-illustration**: ultra realistic illustration
156
- - **eye-catching**: eye-catching
157
- - **john-constable-style**: John Constable Style
158
- - **film-noir**: in the style of FLMNR
159
- - **director-sofia-coppola-style**: Director Sofia Coppola Style
160
- """,
161
- label="Trigger words")
162
-
163
- with gr.Row():
164
- 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)",)
165
- with gr.Row():
166
- with gr.Accordion("⚙️ Advanced Settings", open=False, elem_id="settings-container"):
167
- 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")
168
- with gr.Row():
169
- width = gr.Slider(label="Width", value=1024, minimum=64, maximum=1216, step=32)
170
- height = gr.Slider(label="Height", value=1024, minimum=64, maximum=1216, step=32)
171
  steps = gr.Slider(label="Sampling steps", value=28, minimum=1, maximum=100, step=1)
172
  cfg = gr.Slider(label="CFG Scale", value=3.5, minimum=1, maximum=20, step=0.5)
173
- 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"])
174
- strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
175
- seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=1000000000, step=1)
176
- with gr.Row():
177
- with gr.Accordion("🫘Seed", open=False):
178
- seed_output = gr.Textbox(label="Seed Used", show_copy_button = True, elem_id="seed-output")
179
-
180
- with gr.Row():
181
- text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
182
- with gr.Row():
183
- clr_button =gr.Button("Clear",variant="primary", elem_id="clear_button")
184
- clr_button.click(lambda: gr.Textbox(value=""), None, text_prompt)
185
-
186
- with gr.Row():
187
- image_output = gr.Image(type="pil", label="Image Output", format="png", elem_id="gallery")
188
-
189
- gr.Examples(
190
- examples = examples,
191
- inputs = [text_prompt],
192
- )
193
-
194
- text_button.click(query, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=[image_output, seed_output])
195
 
196
  app.launch(show_api=False, share=False)
 
8
  from deep_translator import GoogleTranslator
9
  import json
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  API_TOKEN = os.getenv("HF_READ_TOKEN")
13
  headers = {"Authorization": f"Bearer {API_TOKEN}"}
 
88
 
89
  css = """
90
  #app-container {
91
+ max-width: 600px;
92
  margin-left: auto;
93
  margin-right: auto;
94
  }
95
  """
96
 
97
+ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
98
  gr.HTML("<center><h1>FLUX.1-Dev with LoRA support</h1></center>")
99
  with gr.Column(elem_id="app-container"):
100
+ with gr.Row():
101
+ with gr.Column(elem_id="prompt-container"):
102
+ with gr.Row():
103
+ text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
104
+ with gr.Row():
105
+ custom_lora = gr.Textbox(label="Custom LoRA", info="LoRA Hugging Face path (optional)", placeholder="multimodalart/vintage-ads-flux")
106
+ with gr.Row():
107
+ with gr.Accordion("Advanced Settings", open=False):
108
+ with gr.Row():
109
+ width = gr.Slider(label="Width", value=1024, minimum=64, maximum=1216, step=8)
110
+ height = gr.Slider(label="Height", value=1024, minimum=64, maximum=1216, step=8)
111
+ seed = gr.Slider(label="Seed", value=-1, minimum=-1, maximum=4294967296, step=1)
112
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
113
+ with gr.Row():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  steps = gr.Slider(label="Sampling steps", value=28, minimum=1, maximum=100, step=1)
115
  cfg = gr.Slider(label="CFG Scale", value=3.5, minimum=1, maximum=20, step=0.5)
116
+ # method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
117
+
118
+ with gr.Row():
119
+ text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
120
+ with gr.Row():
121
+ image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
122
+ with gr.Row():
123
+ seed_output = gr.Textbox(label="Seed Used", show_copy_button = True, elem_id="seed-output")
124
+
125
+ gr.Markdown(article_text)
126
+
127
+ gr.Examples(
128
+ examples = examples,
129
+ inputs = [text_prompt],
130
+ )
131
+
132
+
133
+ text_button.click(query, inputs=[custom_lora, text_prompt, steps, cfg, randomize_seed, seed, width, height], outputs=[image_output,seed_output, seed])
 
 
 
 
134
 
135
  app.launch(show_api=False, share=False)