xinwei89 commited on
Commit
cc6b299
1 Parent(s): d4def87
Files changed (1) hide show
  1. backend.py +1 -2
backend.py CHANGED
@@ -46,7 +46,6 @@ building_predictor = DefaultPredictor(building_cfg)
46
  # A function that runs the buildings model on an given image and confidence threshold
47
  def segment_building(im, confidence_threshold):
48
  building_cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = confidence_threshold
49
- im = np.array(im)
50
  outputs = building_predictor(im)
51
  building_instances = outputs["instances"].to("cpu")
52
 
@@ -55,7 +54,6 @@ def segment_building(im, confidence_threshold):
55
  # A function that runs the trees model on an given image and confidence threshold
56
  def segment_tree(im, confidence_threshold):
57
  tree_cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = confidence_threshold
58
- im = np.array(im)
59
  outputs = tree_predictor(im)
60
  tree_instances = outputs["instances"].to("cpu")
61
 
@@ -71,6 +69,7 @@ def map_color_mode(color_mode):
71
  return ColorMode.SEGMENTATION
72
 
73
  def visualize_image(im, mode, tree_threshold, building_threshold, color_mode=ColorMode.SEGMENTATION):
 
74
  color_mode = map_color_mode(color_mode)
75
 
76
  if mode == "Trees":
 
46
  # A function that runs the buildings model on an given image and confidence threshold
47
  def segment_building(im, confidence_threshold):
48
  building_cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = confidence_threshold
 
49
  outputs = building_predictor(im)
50
  building_instances = outputs["instances"].to("cpu")
51
 
 
54
  # A function that runs the trees model on an given image and confidence threshold
55
  def segment_tree(im, confidence_threshold):
56
  tree_cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = confidence_threshold
 
57
  outputs = tree_predictor(im)
58
  tree_instances = outputs["instances"].to("cpu")
59
 
 
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
 
75
  if mode == "Trees":