Alibrown commited on
Commit
7aab966
·
verified ·
1 Parent(s): 83ecbd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -34
app.py CHANGED
@@ -63,41 +63,45 @@ with vector_converter_interface:
63
  type='value'
64
  )
65
 
66
- interface = gr.Interface(
67
- fn=convert_image,
68
- inputs=[
69
- gr.Image(type="pil", label="Upload Image"),
70
- gr.Radio(choices=["Color", "Binary"], value="Color", label="Color Mode"),
71
- gr.Radio(choices=["Stacked", "Cutout"], value="Stacked", label="Hierarchical"),
72
- gr.Radio(choices=["Spline", "Polygon", "None"], value="Spline", label="Mode"),
73
- gr.Slider(minimum=1, maximum=10, value=4, step=1, label="Filter Speckle"),
74
- gr.Slider(minimum=1, maximum=8, value=6, step=1, label="Color Precision"),
75
- gr.Slider(minimum=1, maximum=32, value=16, step=1, label="Layer Difference"),
76
- gr.Slider(minimum=10, maximum=90, value=60, step=1, label="Corner Threshold"),
77
- gr.Slider(minimum=3.5, maximum=10, value=4.0, step=0.5, label="Length Threshold"),
78
- gr.Slider(minimum=1, maximum=20, value=10, step=1, label="Max Iterations"),
79
- gr.Slider(minimum=10, maximum=90, value=45, step=1, label="Splice Threshold"),
80
- gr.Slider(minimum=1, maximum=10, value=8, step=1, label="Path Precision"),
81
- language_dropdown
82
- ],
83
- outputs=[
84
- gr.HTML(label="SVG Output"),
85
- gr.File(label="Download SVG")
86
- ],
87
- title=gr.State(TRANSLATIONS['en']['title']),
88
- description=gr.State(TRANSLATIONS['en']['description'])
89
- )
90
 
91
- def update_language(language):
92
- return {
93
- interface.title: TRANSLATIONS[language]['title'],
94
- interface.description: TRANSLATIONS[language]['description']
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- language_dropdown.change(
98
- update_language,
99
- inputs=language_dropdown,
100
- outputs=[interface.title, interface.description]
101
- )
 
 
 
 
 
 
102
 
103
  vector_converter_interface.launch()
 
63
  type='value'
64
  )
65
 
66
+ with gr.Blocks() as interface:
67
+ title = gr.Textbox(value=TRANSLATIONS['en']['title'], visible=False)
68
+ description = gr.Textbox(value=TRANSLATIONS['en']['description'], visible=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ gr.Interface(
71
+ fn=convert_image,
72
+ inputs=[
73
+ gr.Image(type="pil", label="Upload Image"),
74
+ gr.Radio(choices=["Color", "Binary"], value="Color", label="Color Mode"),
75
+ gr.Radio(choices=["Stacked", "Cutout"], value="Stacked", label="Hierarchical"),
76
+ gr.Radio(choices=["Spline", "Polygon", "None"], value="Spline", label="Mode"),
77
+ gr.Slider(minimum=1, maximum=10, value=4, step=1, label="Filter Speckle"),
78
+ gr.Slider(minimum=1, maximum=8, value=6, step=1, label="Color Precision"),
79
+ gr.Slider(minimum=1, maximum=32, value=16, step=1, label="Layer Difference"),
80
+ gr.Slider(minimum=10, maximum=90, value=60, step=1, label="Corner Threshold"),
81
+ gr.Slider(minimum=3.5, maximum=10, value=4.0, step=0.5, label="Length Threshold"),
82
+ gr.Slider(minimum=1, maximum=20, value=10, step=1, label="Max Iterations"),
83
+ gr.Slider(minimum=10, maximum=90, value=45, step=1, label="Splice Threshold"),
84
+ gr.Slider(minimum=1, maximum=10, value=8, step=1, label="Path Precision"),
85
+ language_dropdown
86
+ ],
87
+ outputs=[
88
+ gr.HTML(label="SVG Output"),
89
+ gr.File(label="Download SVG")
90
+ ],
91
+ title=TRANSLATIONS['en']['title'],
92
+ description=TRANSLATIONS['en']['description']
93
+ )
94
 
95
+ def update_language(language):
96
+ return {
97
+ title: TRANSLATIONS[language]['title'],
98
+ description: TRANSLATIONS[language]['description']
99
+ }
100
+
101
+ language_dropdown.change(
102
+ update_language,
103
+ inputs=language_dropdown,
104
+ outputs=[title, description]
105
+ )
106
 
107
  vector_converter_interface.launch()