Spaces:
Running
Running
Upload 5 files
Browse files
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: ππ
|
|
4 |
colorFrom: blue
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
short_description: Text-to-Image
|
10 |
license: mit
|
|
|
4 |
colorFrom: blue
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.0.1
|
8 |
app_file: app.py
|
9 |
short_description: Text-to-Image
|
10 |
license: mit
|
app.py
CHANGED
@@ -16,68 +16,92 @@ css = """
|
|
16 |
"""
|
17 |
|
18 |
with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css) as demo:
|
19 |
-
with gr.
|
20 |
-
with gr.
|
21 |
-
with gr.
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
with gr.Row():
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
with gr.Row():
|
30 |
-
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
31 |
-
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
32 |
-
seed_rand = gr.Button("Randomize Seed π²", size="sm", variant="secondary")
|
33 |
-
recom_prompt_preset = gr.Radio(label="Set Presets", choices=get_recom_prompt_type(), value="Common")
|
34 |
-
with gr.Row():
|
35 |
-
positive_prefix = gr.CheckboxGroup(label="Use Positive Prefix", choices=get_positive_prefix(), value=[])
|
36 |
-
positive_suffix = gr.CheckboxGroup(label="Use Positive Suffix", choices=get_positive_suffix(), value=["Common"])
|
37 |
-
negative_prefix = gr.CheckboxGroup(label="Use Negative Prefix", choices=get_negative_prefix(), value=[])
|
38 |
-
negative_suffix = gr.CheckboxGroup(label="Use Negative Suffix", choices=get_negative_suffix(), value=["Common"])
|
39 |
-
with gr.Row():
|
40 |
-
image_num = gr.Slider(label="Number of images", minimum=1, maximum=max_images, value=1, step=1, interactive=True, scale=2)
|
41 |
-
trans_prompt = gr.Button(value="Translate π", variant="secondary", size="sm", scale=2)
|
42 |
-
clear_prompt = gr.Button(value="Clear ποΈ", variant="secondary", size="sm", scale=1)
|
43 |
-
with gr.Row():
|
44 |
-
run_button = gr.Button("Generate Image", variant="primary", scale=6)
|
45 |
-
random_button = gr.Button("Random Model π²", variant="secondary", scale=3)
|
46 |
-
#stop_button = gr.Button('Stop', interactive=False, variant="stop", scale=1)
|
47 |
-
with gr.Group():
|
48 |
-
model_name = gr.Dropdown(label="Select Model", choices=list(loaded_models.keys()), value=list(loaded_models.keys())[0], allow_custom_value=True)
|
49 |
-
model_info = gr.Markdown(value=get_model_info_md(list(loaded_models.keys())[0]), elem_classes="model_info")
|
50 |
-
with gr.Column(scale=10):
|
51 |
-
with gr.Group():
|
52 |
with gr.Row():
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
#gr.on(triggers=[run_button.click, prompt.submit, random_button.click], fn=lambda: gr.update(interactive=True), inputs=None, outputs=stop_button, show_api=False)
|
83 |
model_name.change(change_model, [model_name], [model_info], queue=False, show_api=False)\
|
@@ -98,7 +122,7 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css) as demo:
|
|
98 |
o.change(save_gallery, [o, results], [results, image_files], show_api=False)
|
99 |
#stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event, gen_event2], show_api=False)
|
100 |
|
101 |
-
clear_prompt.click(lambda: None, None, [prompt], queue=False, show_api=False)
|
102 |
clear_results.click(lambda: (None, None), None, [results, image_files], queue=False, show_api=False)
|
103 |
recom_prompt_preset.change(set_recom_prompt_preset, [recom_prompt_preset],
|
104 |
[positive_prefix, positive_suffix, negative_prefix, negative_suffix], queue=False, show_api=False)
|
@@ -106,6 +130,6 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css) as demo:
|
|
106 |
trans_prompt.click(translate_to_en, [prompt], [prompt], queue=False, show_api=False)\
|
107 |
.then(translate_to_en, [neg_prompt], [neg_prompt], queue=False, show_api=False)
|
108 |
|
109 |
-
demo.queue(default_concurrency_limit=200, max_size=200)
|
110 |
demo.launch(max_threads=400)
|
111 |
# https://github.com/gradio-app/gradio/issues/6339
|
|
|
16 |
"""
|
17 |
|
18 |
with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css) as demo:
|
19 |
+
with gr.Tab("Image Generator"):
|
20 |
+
with gr.Row():
|
21 |
+
with gr.Column(scale=10):
|
22 |
+
with gr.Group():
|
23 |
+
prompt = gr.Text(label="Prompt", lines=2, max_lines=8, placeholder="1girl, solo, ...", show_copy_button=True)
|
24 |
+
with gr.Accordion("Advanced options", open=False):
|
25 |
+
neg_prompt = gr.Text(label="Negative Prompt", lines=1, max_lines=8, placeholder="")
|
26 |
+
with gr.Row():
|
27 |
+
width = gr.Slider(label="Width", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
28 |
+
height = gr.Slider(label="Height", info="If 0, the default value is used.", maximum=1216, step=32, value=0)
|
29 |
+
steps = gr.Slider(label="Number of inference steps", info="If 0, the default value is used.", maximum=100, step=1, value=0)
|
30 |
+
with gr.Row():
|
31 |
+
cfg = gr.Slider(label="Guidance scale", info="If 0, the default value is used.", maximum=30.0, step=0.1, value=0)
|
32 |
+
seed = gr.Slider(label="Seed", info="Randomize Seed if -1.", minimum=-1, maximum=MAX_SEED, step=1, value=-1)
|
33 |
+
seed_rand = gr.Button("Randomize Seed π²", size="sm", variant="secondary")
|
34 |
+
recom_prompt_preset = gr.Radio(label="Set Presets", choices=get_recom_prompt_type(), value="Common")
|
35 |
+
with gr.Row():
|
36 |
+
positive_prefix = gr.CheckboxGroup(label="Use Positive Prefix", choices=get_positive_prefix(), value=[])
|
37 |
+
positive_suffix = gr.CheckboxGroup(label="Use Positive Suffix", choices=get_positive_suffix(), value=["Common"])
|
38 |
+
negative_prefix = gr.CheckboxGroup(label="Use Negative Prefix", choices=get_negative_prefix(), value=[])
|
39 |
+
negative_suffix = gr.CheckboxGroup(label="Use Negative Suffix", choices=get_negative_suffix(), value=["Common"])
|
40 |
with gr.Row():
|
41 |
+
image_num = gr.Slider(label="Number of images", minimum=1, maximum=max_images, value=1, step=1, interactive=True, scale=2)
|
42 |
+
trans_prompt = gr.Button(value="Translate π", variant="secondary", size="sm", scale=2)
|
43 |
+
clear_prompt = gr.Button(value="Clear ποΈ", variant="secondary", size="sm", scale=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
with gr.Row():
|
45 |
+
run_button = gr.Button("Generate Image", variant="primary", scale=6)
|
46 |
+
random_button = gr.Button("Random Model π²", variant="secondary", scale=3)
|
47 |
+
#stop_button = gr.Button('Stop', interactive=False, variant="stop", scale=1)
|
48 |
+
with gr.Group():
|
49 |
+
model_name = gr.Dropdown(label="Select Model", choices=list(loaded_models.keys()), value=list(loaded_models.keys())[0], allow_custom_value=True)
|
50 |
+
model_info = gr.Markdown(value=get_model_info_md(list(loaded_models.keys())[0]), elem_classes="model_info")
|
51 |
+
with gr.Column(scale=10):
|
52 |
+
with gr.Group():
|
53 |
+
with gr.Row():
|
54 |
+
output = [gr.Image(label='', elem_classes="output", type="filepath", format="png",
|
55 |
+
show_download_button=True, show_share_button=False, show_label=False,
|
56 |
+
interactive=False, min_width=80, visible=True, width=112, height=112) for _ in range(max_images)]
|
57 |
+
with gr.Group():
|
58 |
+
results = gr.Gallery(label="Gallery", elem_classes="gallery", interactive=False, show_download_button=True, show_share_button=False,
|
59 |
+
container=True, format="png", object_fit="cover", columns=2, rows=2)
|
60 |
+
image_files = gr.Files(label="Download", interactive=False)
|
61 |
+
clear_results = gr.Button("Clear Gallery / Download ποΈ", variant="secondary")
|
62 |
+
with gr.Column():
|
63 |
+
examples = gr.Examples(
|
64 |
+
examples = [
|
65 |
+
["souryuu asuka langley, 1girl, neon genesis evangelion, plugsuit, pilot suit, red bodysuit, sitting, crossing legs, black eye patch, cat hat, throne, symmetrical, looking down, from bottom, looking at viewer, outdoors"],
|
66 |
+
["sailor moon, magical girl transformation, sparkles and ribbons, soft pastel colors, crescent moon motif, starry night sky background, shoujo manga style"],
|
67 |
+
["kafuu chino, 1girl, solo"],
|
68 |
+
["1girl"],
|
69 |
+
["beautiful sunset"],
|
70 |
+
],
|
71 |
+
inputs=[prompt],
|
72 |
+
cache_examples=False,
|
73 |
+
)
|
74 |
+
with gr.Tab("PNG Info"):
|
75 |
+
def extract_exif_data(image):
|
76 |
+
if image is None: return ""
|
77 |
+
try:
|
78 |
+
metadata_keys = ['parameters', 'metadata', 'prompt', 'Comment']
|
79 |
+
for key in metadata_keys:
|
80 |
+
if key in image.info:
|
81 |
+
return image.info[key]
|
82 |
+
return str(image.info)
|
83 |
+
except Exception as e:
|
84 |
+
return f"Error extracting metadata: {str(e)}"
|
85 |
+
with gr.Row():
|
86 |
+
with gr.Column():
|
87 |
+
image_metadata = gr.Image(label="Image with metadata", type="pil", sources=["upload"])
|
88 |
+
with gr.Column():
|
89 |
+
result_metadata = gr.Textbox(label="Metadata", show_label=True, show_copy_button=True, interactive=False, container=True, max_lines=99)
|
90 |
+
|
91 |
+
image_metadata.change(
|
92 |
+
fn=extract_exif_data,
|
93 |
+
inputs=[image_metadata],
|
94 |
+
outputs=[result_metadata],
|
95 |
+
)
|
96 |
+
gr.Markdown(
|
97 |
+
f"""This demo was created in reference to the following demos.<br>
|
98 |
+
[Nymbo/Flood](https://huggingface.co/spaces/Nymbo/Flood),
|
99 |
+
[Yntec/ToyWorldXL](https://huggingface.co/spaces/Yntec/ToyWorldXL),
|
100 |
+
[Yntec/Diffusion80XX](https://huggingface.co/spaces/Yntec/Diffusion80XX).
|
101 |
+
"""
|
102 |
+
)
|
103 |
+
gr.DuplicateButton(value="Duplicate Space")
|
104 |
+
gr.Markdown(f"Just a few edits to *model.py* are all it takes to complete your own collection.")
|
105 |
|
106 |
#gr.on(triggers=[run_button.click, prompt.submit, random_button.click], fn=lambda: gr.update(interactive=True), inputs=None, outputs=stop_button, show_api=False)
|
107 |
model_name.change(change_model, [model_name], [model_info], queue=False, show_api=False)\
|
|
|
122 |
o.change(save_gallery, [o, results], [results, image_files], show_api=False)
|
123 |
#stop_button.click(lambda: gr.update(interactive=False), None, stop_button, cancels=[gen_event, gen_event2], show_api=False)
|
124 |
|
125 |
+
clear_prompt.click(lambda: (None, None), None, [prompt, neg_prompt], queue=False, show_api=False)
|
126 |
clear_results.click(lambda: (None, None), None, [results, image_files], queue=False, show_api=False)
|
127 |
recom_prompt_preset.change(set_recom_prompt_preset, [recom_prompt_preset],
|
128 |
[positive_prefix, positive_suffix, negative_prefix, negative_suffix], queue=False, show_api=False)
|
|
|
130 |
trans_prompt.click(translate_to_en, [prompt], [prompt], queue=False, show_api=False)\
|
131 |
.then(translate_to_en, [neg_prompt], [neg_prompt], queue=False, show_api=False)
|
132 |
|
133 |
+
#demo.queue(default_concurrency_limit=200, max_size=200)
|
134 |
demo.launch(max_threads=400)
|
135 |
# https://github.com/gradio-app/gradio/issues/6339
|
model.py
CHANGED
@@ -16,7 +16,7 @@ models = [
|
|
16 |
'Meina/MeinaMix_V11',
|
17 |
'KBlueLeaf/Kohaku-XL-Epsilon-rev3',
|
18 |
'KBlueLeaf/Kohaku-XL-Zeta',
|
19 |
-
'kayfahaarukku/UrangDiffusion-1.
|
20 |
'Eugeoter/artiwaifu-diffusion-2.0',
|
21 |
'Raelina/Rae-Diffusion-XL-V2',
|
22 |
'Raelina/Raemu-XL-V4',
|
|
|
16 |
'Meina/MeinaMix_V11',
|
17 |
'KBlueLeaf/Kohaku-XL-Epsilon-rev3',
|
18 |
'KBlueLeaf/Kohaku-XL-Zeta',
|
19 |
+
'kayfahaarukku/UrangDiffusion-1.4',
|
20 |
'Eugeoter/artiwaifu-diffusion-2.0',
|
21 |
'Raelina/Rae-Diffusion-XL-V2',
|
22 |
'Raelina/Raemu-XL-V4',
|