hlydecker commited on
Commit
59bd0c5
1 Parent(s): f38fd61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -30,30 +30,29 @@ cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
30
  cfg.MODEL.WEIGHTS = "model_weights/chatswood_buildings_poc.pth"
31
  cfg.MODEL.ROI_HEADS.NUM_CLASSES = 8
32
 
33
- def segment_buildings(input_image):
34
 
35
- im = cv2.imread(input_image)
36
  outputs = predictor(im)
37
  v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2)
38
  out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
39
  return Image.fromarray(np.uint8(out.get_image())).convert('RGB')
40
 
41
- # gradio components -inputs
42
- gr_image_input = gr.inputs.Image(type="pil")
43
  """
44
  gr_slider_confidence = gr.inputs.Slider(0,1,.1,.7,
45
  label='Set confidence threshold % for masks')
46
  """
47
  # gradio outputs
48
- gr_image_output = gr.outputs.Image(type="pil")
 
49
 
50
  title = "Building Segmentation"
51
  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"
52
 
53
  # Create user interface and launch
54
  gr.Interface(segment_buildings,
55
- inputs = gr_image_input,
56
- outputs = gr_image_output,
57
  title = title,
58
  enable_queue = True,
59
  description = description).launch()
 
30
  cfg.MODEL.WEIGHTS = "model_weights/chatswood_buildings_poc.pth"
31
  cfg.MODEL.ROI_HEADS.NUM_CLASSES = 8
32
 
33
+ def segment_buildings(im):
34
 
 
35
  outputs = predictor(im)
36
  v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2)
37
  out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
38
  return Image.fromarray(np.uint8(out.get_image())).convert('RGB')
39
 
40
+ # gradio components
 
41
  """
42
  gr_slider_confidence = gr.inputs.Slider(0,1,.1,.7,
43
  label='Set confidence threshold % for masks')
44
  """
45
  # gradio outputs
46
+ inputs = gr.inputs.Image(type="pil", label="Input Image")
47
+ outputs = gr.outputs.Image(type="pil", label="Output Image")
48
 
49
  title = "Building Segmentation"
50
  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"
51
 
52
  # Create user interface and launch
53
  gr.Interface(segment_buildings,
54
+ inputs = inputs,
55
+ outputs = outputs,
56
  title = title,
57
  enable_queue = True,
58
  description = description).launch()