Sebastiankay commited on
Commit
bb17d08
1 Parent(s): 0a29319

24. Sept. 2024, 19:47

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -25,13 +25,12 @@ RES = os.path.join(os.path.dirname(__file__), "_res")
25
 
26
  gr.set_static_paths(paths=["_res/assets/", "_res/assets/emojis/", "_res/assets/favicons/"])
27
 
28
- fontawesome_css = "file=_res/assets/fontawesome.all.min.css"
29
- catppuccin_css = "file=_res/assets/bootstrap-catppuccin-mocha.min.css"
30
  custom_css = RES + "/_custom.css"
31
  custom_js = RES + "/_custom.js"
32
 
33
  custom_head = f"""
34
- <link rel="stylesheet" href="{fontawesome_css}">
 
35
  <link rel="apple-touch-icon" sizes="180x180" href="file=_res/assets/favicons/apple-touch-icon.png">
36
  <link rel="icon" type="image/png" sizes="32x32" href="file=_res/assets/favicons/favicon-32x32.png">
37
  <link rel="icon" type="image/png" sizes="16x16" href="file=_res/assets/favicons/favicon-16x16.png">
@@ -136,7 +135,7 @@ def process(Prompt, image_width, image_height, image_seed, randomize_seed):
136
 
137
  used_seed = random.randint(0, MAX_SEED) if image_seed == 0 or randomize_seed else image_seed
138
  used_model = "turbo" if int(image_width) > 1024 or int(image_height) > 1024 else "flux" # turbo, flux
139
-
140
  timestamp = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
141
  filename_prompt = re.sub(r"[^\w\s-]", "", Prompt).strip().replace(" ", "_")
142
  filename = timestamp + "_" + filename_prompt[:100] + ".png"
@@ -163,7 +162,7 @@ with gr.Blocks(theme=theme, head=custom_head, css=custom_css, js=custom_js, titl
163
  gr.Markdown(""" """)
164
  with gr.Tab("Image Generator"):
165
  with gr.Row():
166
- with gr.Column(scale=2): # min_width=420,
167
  with gr.Row():
168
  placeholder_text = "[???] Generiert dir einen zufälligen Prompt.\n[STERN] optimiert deinen eignen Prompt.\n[RUN] generiert dein Bild."
169
  text_prompt = gr.Textbox(label="Prompt", show_label=False, lines=12, max_lines=18, placeholder=placeholder_text, elem_id="prompt_input", elem_classes="prompt-input hide-progress", autofocus=True)
@@ -183,7 +182,7 @@ with gr.Blocks(theme=theme, head=custom_head, css=custom_css, js=custom_js, titl
183
  image_seed = gr.Slider(label="Seed", info="Jeder Seed generiert ein anderes Bild mit dem selben Prompt", minimum=0, step=1, value=42, maximum=MAX_SEED, elem_id="image_seed", elem_classes="image-seed hide-progress")
184
  randomize_seed = gr.Checkbox(label="Randomize seed", value=False)
185
 
186
- with gr.Column(scale=4): # min_width=600,
187
  with gr.Row():
188
  with gr.Column(scale=1):
189
  with gr.Row():
@@ -247,7 +246,9 @@ with gr.Blocks(theme=theme, head=custom_head, css=custom_css, js=custom_js, titl
247
 
248
  image_ratio_buttons.input(fn=calculate_ratio_values, inputs=[image_ratio_buttons, image_width, image_height], outputs=[image_width, image_height], show_progress="hidden")
249
 
250
- run_button.click(fn=lambda: {"interactive": False, "__type__": "update"}, outputs=[run_button]).then(fn=process, inputs=[text_prompt, image_width, image_height, image_seed, randomize_seed], outputs=[text_prompt, output_image, output_url, outpu_image_comment, image_informations, image_info_tb_prompt, image_info_tb_width, image_info_tb_height, image_info_tb_seed, image_download_button, output_dominant_image_color, image_seed]).then(fn=lambda: {"interactive": True, "__type__": "update"}, outputs=[run_button])
 
 
251
 
252
  enhance_prompt_button.click(fn=groq_enhance_process, inputs=[text_prompt], outputs=[text_prompt])
253
  random_prompt_button.click(fn=groq_enhance_process, inputs=None, outputs=[text_prompt])
 
25
 
26
  gr.set_static_paths(paths=["_res/assets/", "_res/assets/emojis/", "_res/assets/favicons/"])
27
 
 
 
28
  custom_css = RES + "/_custom.css"
29
  custom_js = RES + "/_custom.js"
30
 
31
  custom_head = f"""
32
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css"/>
33
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/js/all.min.js"></script>
34
  <link rel="apple-touch-icon" sizes="180x180" href="file=_res/assets/favicons/apple-touch-icon.png">
35
  <link rel="icon" type="image/png" sizes="32x32" href="file=_res/assets/favicons/favicon-32x32.png">
36
  <link rel="icon" type="image/png" sizes="16x16" href="file=_res/assets/favicons/favicon-16x16.png">
 
135
 
136
  used_seed = random.randint(0, MAX_SEED) if image_seed == 0 or randomize_seed else image_seed
137
  used_model = "turbo" if int(image_width) > 1024 or int(image_height) > 1024 else "flux" # turbo, flux
138
+
139
  timestamp = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
140
  filename_prompt = re.sub(r"[^\w\s-]", "", Prompt).strip().replace(" ", "_")
141
  filename = timestamp + "_" + filename_prompt[:100] + ".png"
 
162
  gr.Markdown(""" """)
163
  with gr.Tab("Image Generator"):
164
  with gr.Row():
165
+ with gr.Column(scale=2): # min_width=420,
166
  with gr.Row():
167
  placeholder_text = "[???] Generiert dir einen zufälligen Prompt.\n[STERN] optimiert deinen eignen Prompt.\n[RUN] generiert dein Bild."
168
  text_prompt = gr.Textbox(label="Prompt", show_label=False, lines=12, max_lines=18, placeholder=placeholder_text, elem_id="prompt_input", elem_classes="prompt-input hide-progress", autofocus=True)
 
182
  image_seed = gr.Slider(label="Seed", info="Jeder Seed generiert ein anderes Bild mit dem selben Prompt", minimum=0, step=1, value=42, maximum=MAX_SEED, elem_id="image_seed", elem_classes="image-seed hide-progress")
183
  randomize_seed = gr.Checkbox(label="Randomize seed", value=False)
184
 
185
+ with gr.Column(scale=4): # min_width=600,
186
  with gr.Row():
187
  with gr.Column(scale=1):
188
  with gr.Row():
 
246
 
247
  image_ratio_buttons.input(fn=calculate_ratio_values, inputs=[image_ratio_buttons, image_width, image_height], outputs=[image_width, image_height], show_progress="hidden")
248
 
249
+ run_button.click(fn=lambda: {"interactive": False, "__type__": "update"}, outputs=[run_button]).then(fn=process, inputs=[text_prompt, image_width, image_height, image_seed, randomize_seed], outputs=[text_prompt, output_image, output_url, outpu_image_comment, image_informations, image_info_tb_prompt, image_info_tb_width, image_info_tb_height, image_info_tb_seed, image_download_button, output_dominant_image_color, image_seed]).then(
250
+ fn=lambda: {"interactive": True, "__type__": "update"}, outputs=[run_button]
251
+ )
252
 
253
  enhance_prompt_button.click(fn=groq_enhance_process, inputs=[text_prompt], outputs=[text_prompt])
254
  random_prompt_button.click(fn=groq_enhance_process, inputs=None, outputs=[text_prompt])