Spaces:
Runtime error
Runtime error
artificialguybr
commited on
Commit
•
af35943
1
Parent(s):
53c8204
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ import json
|
|
6 |
from image_processing import downscale_image, limit_colors, convert_to_grayscale, convert_to_black_and_white
|
7 |
import logging
|
8 |
|
9 |
-
|
10 |
class SomeClass:
|
11 |
def __init__(self):
|
12 |
self.images = []
|
@@ -23,12 +22,10 @@ def update_selection(selected_state: gr.SelectData):
|
|
23 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
24 |
return (
|
25 |
gr.update(placeholder=new_placeholder),
|
26 |
-
updated_text,
|
27 |
selected_state
|
28 |
)
|
29 |
|
30 |
-
|
31 |
-
|
32 |
def run_lora(prompt, selected_state, progress=gr.Progress(track_tqdm=True)):
|
33 |
selected_lora_index = selected_state.index
|
34 |
selected_lora = loras[selected_lora_index]
|
@@ -69,12 +66,24 @@ with gr.Blocks() as app:
|
|
69 |
result = gr.Image(interactive=False, label="Generated Image")
|
70 |
refined_result = gr.Image(interactive=False, label="Refined Generated Image")
|
71 |
post_processed_result = gr.Image(interactive=False, label="Post-Processed Image")
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
post_process_button = gr.Button("Apply Post-Processing")
|
|
|
78 |
gallery.select(update_selection, outputs=[prompt, selected_info, selected_state])
|
79 |
prompt.submit(fn=run_lora, inputs=[prompt, selected_state], outputs=[result, refined_result])
|
80 |
post_process_button.click(fn=apply_post_processing, inputs=[refined_result, downscale, limit_colors, grayscale, black_and_white], outputs=[post_processed_result])
|
|
|
6 |
from image_processing import downscale_image, limit_colors, convert_to_grayscale, convert_to_black_and_white
|
7 |
import logging
|
8 |
|
|
|
9 |
class SomeClass:
|
10 |
def __init__(self):
|
11 |
self.images = []
|
|
|
22 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✨"
|
23 |
return (
|
24 |
gr.update(placeholder=new_placeholder),
|
25 |
+
updated_text,
|
26 |
selected_state
|
27 |
)
|
28 |
|
|
|
|
|
29 |
def run_lora(prompt, selected_state, progress=gr.Progress(track_tqdm=True)):
|
30 |
selected_lora_index = selected_state.index
|
31 |
selected_lora = loras[selected_lora_index]
|
|
|
66 |
result = gr.Image(interactive=False, label="Generated Image")
|
67 |
refined_result = gr.Image(interactive=False, label="Refined Generated Image")
|
68 |
post_processed_result = gr.Image(interactive=False, label="Post-Processed Image")
|
69 |
+
|
70 |
+
with gr.Tabs():
|
71 |
+
with gr.TabItem("Color"):
|
72 |
+
enable_color_limit = gr.Checkbox(label="Enable", value=False)
|
73 |
+
number_of_colors = gr.Slider(label="Palette Size", minimum=1, maximum=256, step=1, value=16)
|
74 |
+
with gr.TabItem("Grayscale"):
|
75 |
+
is_grayscale = gr.Checkbox(label="Enable", value=False)
|
76 |
+
number_of_shades = gr.Slider(label="Palette Size", minimum=1, maximum=256, step=1, value=16)
|
77 |
+
with gr.TabItem("Black and white"):
|
78 |
+
is_black_and_white = gr.Checkbox(label="Enable", value=False)
|
79 |
+
black_and_white_threshold = gr.Slider(label="Threshold", minimum=1, maximum=256, step=1, value=128)
|
80 |
+
with gr.TabItem("Custom color palette"):
|
81 |
+
use_color_palette = gr.Checkbox(label="Enable", value=False)
|
82 |
+
palette_image = gr.Image(label="Color palette image", type="pil")
|
83 |
+
palette_colors = gr.Slider(label="Palette Size (only for complex images)", minimum=1, maximum=256, step=1, value=16)
|
84 |
+
|
85 |
post_process_button = gr.Button("Apply Post-Processing")
|
86 |
+
|
87 |
gallery.select(update_selection, outputs=[prompt, selected_info, selected_state])
|
88 |
prompt.submit(fn=run_lora, inputs=[prompt, selected_state], outputs=[result, refined_result])
|
89 |
post_process_button.click(fn=apply_post_processing, inputs=[refined_result, downscale, limit_colors, grayscale, black_and_white], outputs=[post_processed_result])
|