DamarJati commited on
Commit
fcb87f2
·
verified ·
1 Parent(s): c8b0cc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -34
app.py CHANGED
@@ -3,20 +3,12 @@ import os
3
  import torch
4
  import modules.wdtagger
5
 
6
- from modules.model import get_model_and_vae_options
7
- from modules.text2img import generate_image_wrapper
8
-
9
- # Mendapatkan daftar model dan VAE untuk dropdown
10
- all_models, all_vaes = get_model_and_vae_options()
11
-
12
-
13
  # Daftar model dan ControlNet
14
  models = ["Model A", "Model B", "Model C"]
15
  vae = ["VAE A", "VAE B", "VAE C"]
16
  controlnet_types = ["Canny", "Depth", "Normal", "Pose"]
17
  schedulers = ["Euler", "LMS", "DDIM"]
18
 
19
-
20
  # Fungsi placeholder
21
  def load_model(selected_model):
22
  return f"Model {selected_model} telah dimuat."
@@ -50,58 +42,56 @@ def intpaint_func (image, controlnet_type, model):
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():
59
  with gr.Column(scale=1):
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():
85
- upscaler = gr.Dropdown(choices=schedulers, label="Upscaler", value=schedulers[0])
86
- upscale_by = gr.Slider(minimum=1, maximum=8, step=1, label="Upscale by", value=2)
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
 
3
  import torch
4
  import modules.wdtagger
5
 
 
 
 
 
 
 
 
6
  # Daftar model dan ControlNet
7
  models = ["Model A", "Model B", "Model C"]
8
  vae = ["VAE A", "VAE B", "VAE C"]
9
  controlnet_types = ["Canny", "Depth", "Normal", "Pose"]
10
  schedulers = ["Euler", "LMS", "DDIM"]
11
 
 
12
  # Fungsi placeholder
13
  def load_model(selected_model):
14
  return f"Model {selected_model} telah dimuat."
 
42
  with gr.Blocks(css="style.css") as app:
43
  # Dropdown untuk memilih model di luar tab dengan lebar kecil
44
  with gr.Row():
45
+ checkpoint = gr.Dropdown(choices=all_models, label="Model", value=all_models[0])
46
+ vae = gr.Dropdown(choices=all_vaes, label="VAE", value=all_vaes[0])
47
+ load = gr.Button("Load")
48
 
49
  # Tab untuk Text-to-Image
50
  with gr.Tab("Text-to-Image"):
51
  with gr.Row():
52
  with gr.Column(scale=1):
53
+ prompt_t2i = gr.Textbox(label="Prompt", placeholder="Enter Prompt", lines=2, elem_id="prompt-input")
54
+ neg_prompt_t2i = gr.Textbox(label="Negative prompt", placeholder="Enter Negative Prompt (optional)", lines=2, elem_id="neg-prompt-input")
55
+ generate_t2i = gr.Button("Generate", elem_id="generate-button", scale=0.13)
56
 
57
  with gr.Row():
58
  with gr.Column():
59
  with gr.Row():
60
+ scheduler_t2i = gr.Dropdown(choices=schedulers, label="Sampling method", value=schedulers[0])
61
+ seed_t2i = gr.Number(label="Seed", value=-1)
62
 
63
  with gr.Row():
64
+ width_t2i = gr.Slider(minimum=128, maximum=2048, step=128, label="Width", value=1024)
65
+ batch_size_t2i = gr.Slider(minimum=1, maximum=24, step=1, label="Batch size", value=1)
66
 
67
  with gr.Row():
68
+ height_t2i = gr.Slider(minimum=128, maximum=2048, step=128, label="Height", value=1024)
69
+ batch_count_t2i = gr.Slider(minimum=1, maximum=24, step=1, label="Batch Count", value=1)
70
 
71
  with gr.Row():
72
+ num_steps_t2i = gr.Slider(minimum=1, maximum=100, step=1, label="Sampling steps", value=20)
73
+ cfg_scale_t2i = gr.Slider(minimum=1, maximum=20, step=1, label="CFG Scale", value=7)
74
 
75
  with gr.Accordion("Hires. fix", open=False):
76
+ use_hires_t2i = gr.Checkbox(label="Use Hires?", value=False, scale=0)
77
  with gr.Row():
78
+ upscaler_t2i = gr.Dropdown(choices=schedulers, label="Upscaler", value=schedulers[0])
79
+ upscale_by_t2i = gr.Slider(minimum=1, maximum=8, step=1, label="Upscale by", value=2)
80
  with gr.Row():
81
+ hires_steps_t2i = gr.Slider(minimum=1, maximum=50, step=1, label="Hires Steps", value=20)
82
+ denois_strength_t2i = gr.Slider(minimum=0, maximum=1, step=0.02, label="Denoising Strength", value=2)
83
 
84
  with gr.Column():
85
  # Gallery untuk output gambar
86
+ output_gallery_t2i = gr.Gallery(label="Image Results")
87
  # Output teks JSON di bawah gallery
88
+ output_text_t2i = gr.Textbox(label="Metadata", placeholder="Results are in Json format", lines=2)
 
 
 
 
89
 
90
+
91
  generate_button.click(
92
  fn=update_images,
93
+ inputs=[prompt_t2i, neg_prompt_t2i, width_t2i, height_t2i, scheduler_t2i, num_steps_t2i, batch_size_t2i, batch_count_t2i, cfg_scale_t2i, seed_t2i, use_hires_t2i, upscaler_t2i, upscale_by_t2i, hires_steps_t2i, denois_strength_t2i],
94
+ outputs=[output_gallery_t2i, output_text_t2i]
95
  )
96
 
97
  # Tab untuk Image-to-Image