Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
54 |
-
|
|
|
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 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
with gr.Row():
|
65 |
with gr.Column():
|
66 |
with gr.Row():
|
67 |
-
|
68 |
-
|
69 |
|
70 |
with gr.Row():
|
71 |
-
|
72 |
-
|
73 |
|
74 |
with gr.Row():
|
75 |
-
|
76 |
-
|
77 |
|
78 |
with gr.Row():
|
79 |
-
|
80 |
-
|
81 |
|
82 |
with gr.Accordion("Hires. fix", open=False):
|
83 |
-
|
84 |
with gr.Row():
|
85 |
-
|
86 |
-
|
87 |
with gr.Row():
|
88 |
-
|
89 |
-
|
90 |
|
91 |
with gr.Column():
|
92 |
# Gallery untuk output gambar
|
93 |
-
|
94 |
# Output teks JSON di bawah gallery
|
95 |
-
|
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=[
|
104 |
-
outputs=[
|
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
|