hlydecker commited on
Commit
c2f4d83
·
1 Parent(s): bca0412

patch: documentation upgrade

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,6 +1,6 @@
1
  """
2
- building-segmentation
3
- Proof of concept showing effectiveness of a fine tuned instance segmentation model for deteting buildings.
4
  """
5
  import os
6
  import cv2
@@ -32,7 +32,7 @@ cfg.MODEL.WEIGHTS = "model_weights/tree_model.pth"
32
  cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2
33
  predictor = DefaultPredictor(cfg)
34
 
35
- def segment_buildings(im):
36
 
37
  im = np.array(im)
38
  outputs = predictor(im)
@@ -40,7 +40,7 @@ def segment_buildings(im):
40
  scale=0.5,
41
  instance_mode=ColorMode.IMAGE_BW
42
  )
43
- print(len(outputs["instances"])," buildings detected.")
44
  out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
45
 
46
  return Image.fromarray(out.get_image()[:, :, ::-1])
@@ -54,11 +54,11 @@ gr_slider_confidence = gr.inputs.Slider(0,1,.1,.7,
54
  inputs = gr.inputs.Image(type="pil", label="Input Image")
55
  outputs = gr.outputs.Image(type="pil", label="Output Image")
56
 
57
- title = "Building Segmentation"
58
- description = "An instance segmentation demo for identifying boundaries of buildings in aerial images using DETR (End-to-End Object Detection) model with MaskRCNN-101 backbone"
59
 
60
  # Create user interface and launch
61
- gr.Interface(segment_buildings,
62
  inputs = inputs,
63
  outputs = outputs,
64
  title = title,
 
1
  """
2
+ tree-segmentation
3
+ Proof of concept showing effectiveness of a fine tuned instance segmentation model for detecting trees.
4
  """
5
  import os
6
  import cv2
 
32
  cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2
33
  predictor = DefaultPredictor(cfg)
34
 
35
+ def segment_image(im):
36
 
37
  im = np.array(im)
38
  outputs = predictor(im)
 
40
  scale=0.5,
41
  instance_mode=ColorMode.IMAGE_BW
42
  )
43
+ print(len(outputs["instances"])," trees detected.")
44
  out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
45
 
46
  return Image.fromarray(out.get_image()[:, :, ::-1])
 
54
  inputs = gr.inputs.Image(type="pil", label="Input Image")
55
  outputs = gr.outputs.Image(type="pil", label="Output Image")
56
 
57
+ title = "Tree Segmentation"
58
+ description = "An instance segmentation demo for identifying trees in aerial images using DETR (End-to-End Object Detection) model with MaskRCNN-101 backbone"
59
 
60
  # Create user interface and launch
61
+ gr.Interface(segment_image,
62
  inputs = inputs,
63
  outputs = outputs,
64
  title = title,