Uthar commited on
Commit
8848fec
1 Parent(s): c9acef2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -45
app.py CHANGED
@@ -113,51 +113,12 @@ def add_gallery(image, model_str, gallery):
113
  if image is not None: gallery.insert(0, (image, model_str))
114
  return gallery
115
 
116
- button_state=False
117
-
118
- async def buttonChecker():
119
- """Continuously check the button state and perform an action."""
120
- while True:
121
- if button_state:
122
- print("Button is ON - Triggering Event")
123
- # Here, you can define what happens when the button is ON.
124
- await asyncio.sleep(1) # Check every second
125
-
126
- def start_event_loop():
127
- """Start the event loop for the asynchronous task."""
128
- asyncio.create_task(buttonChecker())
129
-
130
- def toggle_button(butState):
131
- global button_state
132
- if butState == "Running":
133
- button_state=False
134
- return "Off", gr.Button(variant="secondary", value="Off", elem_classes=["off"])
135
- else:
136
- button_state=True
137
- return "Running", gr.Button(variant="primary", value="Running", elem_classes=["Running"])
138
-
139
-
140
-
141
  js="""
142
  <script>console.log("BOOOOOOOOOOOOOOOOBS");</script>
143
  """
144
 
145
- css="""
146
- .Running {
147
- background-color: green;
148
- color: white;
149
- }
150
- .off {
151
- background-color: red;
152
- color: white;
153
- }
154
- """
155
-
156
-
157
-
158
- with gr.Blocks(fill_width=True, head=js, css=css) as demo:
159
  with gr.Tab(str(num_models) + ' Models'):
160
- demo.load(start_event_loop)
161
  with gr.Column(scale=2):
162
  with gr.Group():
163
  txt_input = gr.Textbox(label='Your prompt:', value=preSetPrompt, lines=3, autofocus=1)
@@ -173,11 +134,7 @@ with gr.Blocks(fill_width=True, head=js, css=css) as demo:
173
  seed_rand = gr.Button("Randomize Seed 🎲", size="sm", variant="secondary")
174
  seed_rand.click(randomize_seed, None, [seed], queue=False)
175
  with gr.Row():
176
- # gen_button = gr.Button(f'Generate up to {int(num_models)} images', variant='primary', scale=3)
177
- butState = gr.State(value="Off")
178
- gen_button = gr.Button(value="Off", variant="secondary", elem_classes=["off"], scale=3)
179
- gen_button.click(fn=toggle_button, inputs=butState, outputs=[butState, gen_button])
180
-
181
  random_button = gr.Button(f'Randomize Models', variant='secondary', scale=1)
182
 
183
  with gr.Column(scale=1):
 
113
  if image is not None: gallery.insert(0, (image, model_str))
114
  return gallery
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  js="""
117
  <script>console.log("BOOOOOOOOOOOOOOOOBS");</script>
118
  """
119
 
120
+ with gr.Blocks(fill_width=True, head=js) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  with gr.Tab(str(num_models) + ' Models'):
 
122
  with gr.Column(scale=2):
123
  with gr.Group():
124
  txt_input = gr.Textbox(label='Your prompt:', value=preSetPrompt, lines=3, autofocus=1)
 
134
  seed_rand = gr.Button("Randomize Seed 🎲", size="sm", variant="secondary")
135
  seed_rand.click(randomize_seed, None, [seed], queue=False)
136
  with gr.Row():
137
+ gen_button = gr.Button(f'Generate up to {int(num_models)} images', variant='primary', scale=3)
 
 
 
 
138
  random_button = gr.Button(f'Randomize Models', variant='secondary', scale=1)
139
 
140
  with gr.Column(scale=1):