waloneai commited on
Commit
281aa21
·
verified ·
1 Parent(s): ce748a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -6,7 +6,6 @@ import os
6
  import time
7
  from PIL import Image
8
  from deep_translator import GoogleTranslator
9
- import json
10
 
11
  # Project by Nymbo
12
 
@@ -16,7 +15,7 @@ headers = {"Authorization": f"Bearer {API_TOKEN}"}
16
  timeout = 100
17
 
18
  def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7):
19
- if prompt == "" or prompt == None:
20
  return None, None # Return None for both image and file
21
 
22
  key = random.randint(0, 999)
@@ -91,21 +90,17 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
91
  with gr.Row():
92
  download_button = gr.File(label="Download Image", visible=False, elem_id="download-button")
93
 
94
- # Update the download button visibility and file when the image is generated
95
  def update_download_button(image, file):
96
  if image is not None:
97
  return gr.File.update(value=file, visible=True)
98
  return gr.File.update(visible=False)
99
 
 
100
  text_button.click(
101
  query,
102
  inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength],
103
  outputs=[image_output, download_button]
104
  )
105
- image_output.change(
106
- update_download_button,
107
- inputs=[image_output, download_button],
108
- outputs=[download_button]
109
- )
110
 
111
  app.launch(show_api=False, share=True)
 
6
  import time
7
  from PIL import Image
8
  from deep_translator import GoogleTranslator
 
9
 
10
  # Project by Nymbo
11
 
 
15
  timeout = 100
16
 
17
  def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7):
18
+ if prompt == "" or prompt is None:
19
  return None, None # Return None for both image and file
20
 
21
  key = random.randint(0, 999)
 
90
  with gr.Row():
91
  download_button = gr.File(label="Download Image", visible=False, elem_id="download-button")
92
 
93
+ # Update the download button when the image is generated
94
  def update_download_button(image, file):
95
  if image is not None:
96
  return gr.File.update(value=file, visible=True)
97
  return gr.File.update(visible=False)
98
 
99
+ # Trigger the query function and update the image and download button
100
  text_button.click(
101
  query,
102
  inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength],
103
  outputs=[image_output, download_button]
104
  )
 
 
 
 
 
105
 
106
  app.launch(show_api=False, share=True)