aaurelions commited on
Commit
abdd93e
·
verified ·
1 Parent(s): 0f2ddd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -12,7 +12,7 @@ def image_to_svg(image, colormode, hierarchical, filter_speckle, color_precision
12
  return None, "Upload an image to begin.", None
13
 
14
  # Use a temporary file to handle the image path
15
- input_path = image.name
16
 
17
  # Use a temporary directory for the output to ensure a clean file system
18
  with tempfile.TemporaryDirectory() as temp_dir:
@@ -82,7 +82,6 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
82
  with gr.TabItem("SVG Preview"):
83
  svg_image_output = gr.Image(label="SVG Preview", interactive=False)
84
  with gr.TabItem("SVG Code"):
85
- # The traceback error is fixed here by using 'html' which supports XML syntax highlighting.
86
  svg_text_output = gr.Code(label="SVG Code", language="html", interactive=False)
87
 
88
  svg_file_output = gr.File(label="Download SVG")
@@ -109,11 +108,11 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
109
 
110
  outputs = [svg_file_output, svg_text_output, svg_image_output]
111
 
112
- # Connect all input controls to the conversion function.
113
  # The 'debounce' parameter adds a 1-second delay after the user stops changing a value
114
- # before the function is called, improving performance and user experience.
115
  for component in inputs:
116
- component.change(fn=image_to_svg, inputs=inputs, outputs=outputs, every=1)
117
 
118
  # To launch the application
119
- demo.launch(debug=True)
 
12
  return None, "Upload an image to begin.", None
13
 
14
  # Use a temporary file to handle the image path
15
+ input_path = image
16
 
17
  # Use a temporary directory for the output to ensure a clean file system
18
  with tempfile.TemporaryDirectory() as temp_dir:
 
82
  with gr.TabItem("SVG Preview"):
83
  svg_image_output = gr.Image(label="SVG Preview", interactive=False)
84
  with gr.TabItem("SVG Code"):
 
85
  svg_text_output = gr.Code(label="SVG Code", language="html", interactive=False)
86
 
87
  svg_file_output = gr.File(label="Download SVG")
 
108
 
109
  outputs = [svg_file_output, svg_text_output, svg_image_output]
110
 
111
+ # **FIX:** Connect all input controls to the conversion function.
112
  # The 'debounce' parameter adds a 1-second delay after the user stops changing a value
113
+ # before the function is called, which is the correct way to implement this.
114
  for component in inputs:
115
+ component.change(fn=image_to_svg, inputs=inputs, outputs=outputs, debounce=1)
116
 
117
  # To launch the application
118
+ demo.launch()