Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 4 |
"""
|
| 5 |
import os
|
| 6 |
import cv2
|
|
@@ -25,14 +25,16 @@ from detectron2.data import MetadataCatalog, DatasetCatalog
|
|
| 25 |
from detectron2.checkpoint import DetectionCheckpointer
|
| 26 |
|
| 27 |
cfg = get_cfg()
|
| 28 |
-
cfg.merge_from_file("model_weights/
|
| 29 |
cfg.MODEL.DEVICE='cpu'
|
| 30 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.25
|
| 31 |
-
cfg.MODEL.WEIGHTS = "model_weights/model_final.pth"
|
| 32 |
-
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 8
|
|
|
|
|
|
|
| 33 |
predictor = DefaultPredictor(cfg)
|
| 34 |
|
| 35 |
-
def
|
| 36 |
|
| 37 |
im = np.array(im)
|
| 38 |
outputs = predictor(im)
|
|
@@ -58,7 +60,7 @@ 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(
|
| 62 |
inputs = inputs,
|
| 63 |
outputs = outputs,
|
| 64 |
title = title,
|
|
|
|
| 1 |
"""
|
| 2 |
building-segmentation
|
| 3 |
+
Proof of concept showing effectiveness of a fine tuned instance segmentation model for detecting buildings.
|
| 4 |
"""
|
| 5 |
import os
|
| 6 |
import cv2
|
|
|
|
| 25 |
from detectron2.checkpoint import DetectionCheckpointer
|
| 26 |
|
| 27 |
cfg = get_cfg()
|
| 28 |
+
cfg.merge_from_file("model_weights/lczs_cfg.yml")
|
| 29 |
cfg.MODEL.DEVICE='cpu'
|
| 30 |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.25
|
| 31 |
+
#cfg.MODEL.WEIGHTS = "model_weights/model_final.pth"
|
| 32 |
+
#cfg.MODEL.ROI_HEADS.NUM_CLASSES = 8
|
| 33 |
+
cfg.MODEL.WEIGHTS = "model_weights/lczs_v2.pth"
|
| 34 |
+
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 14
|
| 35 |
predictor = DefaultPredictor(cfg)
|
| 36 |
|
| 37 |
+
def segment(im):
|
| 38 |
|
| 39 |
im = np.array(im)
|
| 40 |
outputs = predictor(im)
|
|
|
|
| 60 |
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"
|
| 61 |
|
| 62 |
# Create user interface and launch
|
| 63 |
+
gr.Interface(segment,
|
| 64 |
inputs = inputs,
|
| 65 |
outputs = outputs,
|
| 66 |
title = title,
|