RageshAntony commited on
Commit
3295353
·
verified ·
1 Parent(s): 67389ac

global init

Browse files
Files changed (1) hide show
  1. check_app.py +25 -16
check_app.py CHANGED
@@ -23,6 +23,18 @@ MAX_SEED = np.iinfo(np.int32).max
23
  MAX_IMAGE_SIZE = 1024
24
  gallery : gr.Gallery = None
25
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  class ProgressPipeline(DiffusionPipeline):
27
  def __init__(self, original_pipeline):
28
  super().__init__()
@@ -200,6 +212,8 @@ def create_pipeline_logic(prompt_text, model_name, negative_prompt="", seed=42,
200
  )
201
  return f"Seed: {gen_seed}", image
202
  def main():
 
 
203
  with gr.Blocks() as app:
204
  gr.Markdown("# Dynamic Multiple Model Image Generation")
205
 
@@ -255,28 +269,23 @@ def main():
255
  )
256
 
257
  for model_name, config in MODEL_CONFIGS.items():
258
- global gallery
259
  with gr.Tab(model_name):
260
  button = gr.Button(f"Run {model_name}")
261
  output = gr.Textbox(label="Status")
262
  img = gr.Image(label=model_name, height=300)
263
 
264
  button.click(fn=create_pipeline_logic, inputs=[prompt_text, gr.Text(value= model_name,visible=False), negative_prompt,
265
- seed,
266
- randomize_seed,
267
- width,
268
- height,
269
- guidance_scale,
270
- num_inference_steps], outputs=[output, img, gallery])
271
-
272
- gallery = gr.Gallery(
273
- label="Image Gallery",
274
- show_label=True,
275
- columns=4,
276
- rows=3,
277
- height=600,
278
- object_fit="contain"
279
- )
280
 
281
  app.launch()
282
 
 
23
  MAX_IMAGE_SIZE = 1024
24
  gallery : gr.Gallery = None
25
 
26
+ def initialize_components():
27
+ global gallery
28
+
29
+ gallery = gr.Gallery(
30
+ label="Image Gallery",
31
+ show_label=True,
32
+ columns=4,
33
+ rows=3,
34
+ height=600,
35
+ object_fit="contain"
36
+ )
37
+
38
  class ProgressPipeline(DiffusionPipeline):
39
  def __init__(self, original_pipeline):
40
  super().__init__()
 
212
  )
213
  return f"Seed: {gen_seed}", image
214
  def main():
215
+ if gallery is None:
216
+ initialize_components()
217
  with gr.Blocks() as app:
218
  gr.Markdown("# Dynamic Multiple Model Image Generation")
219
 
 
269
  )
270
 
271
  for model_name, config in MODEL_CONFIGS.items():
272
+ #global gallery
273
  with gr.Tab(model_name):
274
  button = gr.Button(f"Run {model_name}")
275
  output = gr.Textbox(label="Status")
276
  img = gr.Image(label=model_name, height=300)
277
 
278
  button.click(fn=create_pipeline_logic, inputs=[prompt_text, gr.Text(value= model_name,visible=False), negative_prompt,
279
+ seed,
280
+ randomize_seed,
281
+ width,
282
+ height,
283
+ guidance_scale,
284
+ num_inference_steps], outputs=[output, img, gallery])
285
+
286
+ gallery.render()
287
+
288
+
 
 
 
 
 
289
 
290
  app.launch()
291