xinwei89 commited on
Commit
d812008
1 Parent(s): cc6b299

change style

Browse files
Files changed (2) hide show
  1. app.py +11 -3
  2. backend.py +1 -1
app.py CHANGED
@@ -3,10 +3,18 @@ from backend import visualize_image
3
 
4
  # gradio inputs
5
  image_input = gr.inputs.Image(type="pil", label="Input Image")
6
- mode_dropdown = gr.inputs.Dropdown(["Trees", "Buildings", "Both"])
7
- tree_threshold_slider = gr.inputs.Slider(0, 1, 0.1, 0.7, label='Set confidence threshold % for trees')
8
- building_threshold_slider = gr.inputs.Slider(0, 1, 0.1, 0.7, label='Set confidence threshold % for buildings')
9
  color_mode_select = gr.inputs.Radio(["Black/white", "Random", "Segmentation"])
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  # gradio outputs
12
  output_image = gr.outputs.Image(type="pil", label="Output Image")
 
3
 
4
  # gradio inputs
5
  image_input = gr.inputs.Image(type="pil", label="Input Image")
 
 
 
6
  color_mode_select = gr.inputs.Radio(["Black/white", "Random", "Segmentation"])
7
+ mode_dropdown = gr.inputs.Dropdown(["Trees", "Buildings", "Both"])
8
+
9
+ tree_threshold_slider = gr.inputs.Slider(0, 1, 0.1, 0.7, label='Set confidence threshold "%" for trees')
10
+ building_threshold_slider = gr.inputs.Slider(0, 1, 0.1, 0.7, label='Set confidence threshold "%" for buildings')
11
+ if mode_dropdown == "Trees":
12
+ tree_threshold_slider.enable()
13
+ if mode_dropdown == "Buildings":
14
+ building_threshold_slider.enable()
15
+ if mode_dropdown == "Both":
16
+ tree_threshold_slider.enable()
17
+ building_threshold_slider.enable()
18
 
19
  # gradio outputs
20
  output_image = gr.outputs.Image(type="pil", label="Output Image")
backend.py CHANGED
@@ -68,7 +68,7 @@ def map_color_mode(color_mode):
68
  elif color_mode == "Segmentation":
69
  return ColorMode.SEGMENTATION
70
 
71
- def visualize_image(im, mode, tree_threshold, building_threshold, color_mode=ColorMode.SEGMENTATION):
72
  im = np.array(im)
73
  color_mode = map_color_mode(color_mode)
74
 
 
68
  elif color_mode == "Segmentation":
69
  return ColorMode.SEGMENTATION
70
 
71
+ def visualize_image(im, mode="BOTH", tree_threshold=0.7, building_threshold=0.7, color_mode=ColorMode.SEGMENTATION):
72
  im = np.array(im)
73
  color_mode = map_color_mode(color_mode)
74