DamarJati commited on
Commit
bc2fb74
·
verified ·
1 Parent(s): 342af12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -47,13 +47,12 @@ def intpaint_func (image, controlnet_type, model):
47
  return controlnet_process(image, controlnet_type, model)
48
 
49
 
50
-
51
- with gr.Blocks(css= "style.css") as app:
52
  # Dropdown untuk memilih model di luar tab dengan lebar kecil
53
  with gr.Row():
54
- checkpoint_dropdown = gr.Dropdown(choices=all_models, label="Model", value="Model B")
55
- vae_dropdown = gr.Dropdown(choices=all_vaes, label="VAE", value="VAE C")
56
-
57
  # Tab untuk Text-to-Image
58
  with gr.Tab("Text-to-Image"):
59
  with gr.Row():
@@ -61,25 +60,25 @@ with gr.Blocks(css= "style.css") as app:
61
  prompt_input = gr.Textbox(label="Prompt", placeholder="Enter Prompt", lines=2, elem_id="prompt-input")
62
  neg_prompt_input = gr.Textbox(label="Negative prompt", placeholder="Enter Negative Prompt (optional)", lines=2, elem_id="neg-prompt-input")
63
  generate_button = gr.Button("Generate", elem_id="generate-button", scale=0.13)
64
-
65
  with gr.Row():
66
  with gr.Column():
67
  with gr.Row():
68
  scheduler_input = gr.Dropdown(choices=schedulers, label="Sampling method", value=schedulers[0])
69
  seed_input = gr.Number(label="Seed", value=-1)
70
-
71
  with gr.Row():
72
  width_input = gr.Slider(minimum=128, maximum=2048, step=128, label="Width", value=1024)
73
  batch_size = gr.Slider(minimum=1, maximum=24, step=1, label="Batch size", value=1)
74
-
75
  with gr.Row():
76
  height_input = gr.Slider(minimum=128, maximum=2048, step=128, label="Height", value=1024)
77
  batch_count = gr.Slider(minimum=1, maximum=24, step=1, label="Batch Count", value=1)
78
-
79
  with gr.Row():
80
  num_steps_input = gr.Slider(minimum=1, maximum=100, step=1, label="Sampling steps", value=20)
81
  cfg_scale_input = gr.Slider(minimum=1, maximum=20, step=1, label="CFG Scale", value=7)
82
-
83
  with gr.Accordion("Hires. fix", open=False):
84
  use_hires = gr.Checkbox(label="Use Hires?", value=False, scale=0)
85
  with gr.Row():
@@ -88,20 +87,23 @@ with gr.Blocks(css= "style.css") as app:
88
  with gr.Row():
89
  hires_steps = gr.Slider(minimum=1, maximum=50, step=1, label="Hires Steps", value=20)
90
  denois_strength = gr.Slider(minimum=0, maximum=1, step=0.02, label="Denoising Strength", value=2)
91
-
92
-
93
  with gr.Column():
94
  # Gallery untuk output gambar
95
  output_gallery = gr.Gallery(label="Image Results")
96
  # Output teks JSON di bawah gallery
97
  output_text = gr.Textbox(label="Metadata", placeholder="Results are in Json format", lines=2)
98
 
99
- def update_images(prompt, neg_prompt, width, height, scheduler, num_steps, num_images, cfg_scale, seed, model):
100
  # Update fungsi sesuai kebutuhan
101
- return generate_image(prompt, neg_prompt, width, height, scheduler, num_steps, num_images, cfg_scale, seed, model)
102
-
103
- generate_button.click(fn=update_images, inputs=[prompt_input, neg_prompt_input, width_input, height_input, scheduler_input, num_steps_input, batch_size, batch_count, cfg_scale_input, seed_input, checkpoint_dropdown, vae_dropdown], outputs=[output_gallery, output_text])
104
 
 
 
 
 
 
 
105
  # Tab untuk Image-to-Image
106
  with gr.Tab("Image-to-Image"):
107
  with gr.Row():
 
47
  return controlnet_process(image, controlnet_type, model)
48
 
49
 
50
+ with gr.Blocks(css="style.css") as app:
 
51
  # Dropdown untuk memilih model di luar tab dengan lebar kecil
52
  with gr.Row():
53
+ checkpoint_dropdown = gr.Dropdown(choices=all_models, label="Model", value=all_models[0])
54
+ vae_dropdown = gr.Dropdown(choices=all_vaes, label="VAE", value=all_vaes[0])
55
+
56
  # Tab untuk Text-to-Image
57
  with gr.Tab("Text-to-Image"):
58
  with gr.Row():
 
60
  prompt_input = gr.Textbox(label="Prompt", placeholder="Enter Prompt", lines=2, elem_id="prompt-input")
61
  neg_prompt_input = gr.Textbox(label="Negative prompt", placeholder="Enter Negative Prompt (optional)", lines=2, elem_id="neg-prompt-input")
62
  generate_button = gr.Button("Generate", elem_id="generate-button", scale=0.13)
63
+
64
  with gr.Row():
65
  with gr.Column():
66
  with gr.Row():
67
  scheduler_input = gr.Dropdown(choices=schedulers, label="Sampling method", value=schedulers[0])
68
  seed_input = gr.Number(label="Seed", value=-1)
69
+
70
  with gr.Row():
71
  width_input = gr.Slider(minimum=128, maximum=2048, step=128, label="Width", value=1024)
72
  batch_size = gr.Slider(minimum=1, maximum=24, step=1, label="Batch size", value=1)
73
+
74
  with gr.Row():
75
  height_input = gr.Slider(minimum=128, maximum=2048, step=128, label="Height", value=1024)
76
  batch_count = gr.Slider(minimum=1, maximum=24, step=1, label="Batch Count", value=1)
77
+
78
  with gr.Row():
79
  num_steps_input = gr.Slider(minimum=1, maximum=100, step=1, label="Sampling steps", value=20)
80
  cfg_scale_input = gr.Slider(minimum=1, maximum=20, step=1, label="CFG Scale", value=7)
81
+
82
  with gr.Accordion("Hires. fix", open=False):
83
  use_hires = gr.Checkbox(label="Use Hires?", value=False, scale=0)
84
  with gr.Row():
 
87
  with gr.Row():
88
  hires_steps = gr.Slider(minimum=1, maximum=50, step=1, label="Hires Steps", value=20)
89
  denois_strength = gr.Slider(minimum=0, maximum=1, step=0.02, label="Denoising Strength", value=2)
90
+
 
91
  with gr.Column():
92
  # Gallery untuk output gambar
93
  output_gallery = gr.Gallery(label="Image Results")
94
  # Output teks JSON di bawah gallery
95
  output_text = gr.Textbox(label="Metadata", placeholder="Results are in Json format", lines=2)
96
 
97
+ def update_images(prompt, neg_prompt, width, height, scheduler, num_steps, batch_size, batch_count, cfg_scale, seed, model, vae):
98
  # Update fungsi sesuai kebutuhan
99
+ return generate_image_wrapper(prompt, neg_prompt, width, height, scheduler, num_steps, batch_size, batch_count, cfg_scale, seed, model, vae)
 
 
100
 
101
+ generate_button.click(
102
+ fn=update_images,
103
+ inputs=[prompt_input, neg_prompt_input, width_input, height_input, scheduler_input, num_steps_input, batch_size, batch_count, cfg_scale_input, seed_input, checkpoint_dropdown, vae_dropdown],
104
+ outputs=[output_gallery, output_text]
105
+ )
106
+
107
  # Tab untuk Image-to-Image
108
  with gr.Tab("Image-to-Image"):
109
  with gr.Row():