Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -81,7 +81,9 @@ with gr.Blocks(css=css) as app:
|
|
| 81 |
max_iterations = gr.Slider(1, 20, value=10, step=1, label="Max Iterations", visible=False)
|
| 82 |
path_precision = gr.Slider(1, 10, value=3, step=1, label="Path Precision", visible=False)
|
| 83 |
output_text = gr.Textbox(label="Selected Mode", visible=False)
|
| 84 |
-
|
|
|
|
|
|
|
| 85 |
|
| 86 |
with gr.Column():
|
| 87 |
html = gr.HTML(label="SVG Output") # container=True, show_label=True
|
|
@@ -95,6 +97,10 @@ with gr.Blocks(css=css) as app:
|
|
| 95 |
"layer_difference": 16
|
| 96 |
}
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
def update_interactivity_and_visibility(colormode, color_precision_value, layer_difference_value):
|
| 99 |
is_color_mode = colormode == "color"
|
| 100 |
return (
|
|
@@ -123,6 +129,24 @@ with gr.Blocks(css=css) as app:
|
|
| 123 |
outputs=[corner_threshold,length_threshold,splice_threshold]
|
| 124 |
)
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
convert_button.click(
|
| 127 |
convert_to_vector,
|
| 128 |
inputs=[
|
|
|
|
| 81 |
max_iterations = gr.Slider(1, 20, value=10, step=1, label="Max Iterations", visible=False)
|
| 82 |
path_precision = gr.Slider(1, 10, value=3, step=1, label="Path Precision", visible=False)
|
| 83 |
output_text = gr.Textbox(label="Selected Mode", visible=False)
|
| 84 |
+
with gr.Row():
|
| 85 |
+
clear_button = gr.Button("Clear")
|
| 86 |
+
convert_button = gr.Button("✨ Convert to SVG", variant='primary', elem_classes=["generate-btn"])
|
| 87 |
|
| 88 |
with gr.Column():
|
| 89 |
html = gr.HTML(label="SVG Output") # container=True, show_label=True
|
|
|
|
| 97 |
"layer_difference": 16
|
| 98 |
}
|
| 99 |
|
| 100 |
+
def clear_inputs():
|
| 101 |
+
return gr.Image(value=None), gr.Radio(value="color"), gr.Radio(value="stacked"), gr.Radio(value="spline"), gr.Slider(value=4), gr.Slider(value=6), gr.Slider(value=16), gr.Slider(value=60), gr.Slider(value=4.0), gr.Slider(value=10), gr.Slider(value=45), gr.Slider(value=3)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
def update_interactivity_and_visibility(colormode, color_precision_value, layer_difference_value):
|
| 105 |
is_color_mode = colormode == "color"
|
| 106 |
return (
|
|
|
|
| 129 |
outputs=[corner_threshold,length_threshold,splice_threshold]
|
| 130 |
)
|
| 131 |
|
| 132 |
+
clear_button.click(
|
| 133 |
+
clear_inputs,
|
| 134 |
+
outputs=[
|
| 135 |
+
image_input,
|
| 136 |
+
colormode,
|
| 137 |
+
hierarchical,
|
| 138 |
+
mode,
|
| 139 |
+
filter_speckle,
|
| 140 |
+
color_precision,
|
| 141 |
+
layer_difference,
|
| 142 |
+
corner_threshold,
|
| 143 |
+
length_threshold,
|
| 144 |
+
max_iterations,
|
| 145 |
+
splice_threshold,
|
| 146 |
+
path_precision
|
| 147 |
+
]
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
convert_button.click(
|
| 151 |
convert_to_vector,
|
| 152 |
inputs=[
|