Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,12 +66,12 @@ model_path = "./model_final.pth"
|
|
| 66 |
|
| 67 |
# cfg = get_cfg()
|
| 68 |
# cfg.merge_from_file("./configs/detectron2/faster_rcnn_R_50_FPN_3x.yaml")
|
| 69 |
-
|
| 70 |
# cfg.MODEL.WEIGHTS = model_path
|
| 71 |
|
| 72 |
-
|
| 73 |
# Fiber_metadata.thing_classes = ["Fiber", "Fiber","Fiber"]
|
| 74 |
-
|
| 75 |
cfg = get_cfg()
|
| 76 |
cfg.merge_from_file("./configs/detectron2/mask_rcnn_R_50_FPN_3x.yaml")
|
| 77 |
cfg.MODEL.WEIGHTS = model_path #os.path.join(cfg.OUTPUT_DIR, "model_final.pth")
|
|
@@ -121,7 +121,7 @@ def inference(image_url, image, min_score):
|
|
| 121 |
# im = cv2.imread(d["file_name"])
|
| 122 |
# outputs = predictor(im)
|
| 123 |
v = Visualizer(im[:, :, ::-1],
|
| 124 |
-
metadata=Fiber_metadata,
|
| 125 |
scale=1,
|
| 126 |
instance_mode=ColorMode.IMAGE_BW # remove the colors of unsegmented pixels
|
| 127 |
)
|
|
|
|
| 66 |
|
| 67 |
# cfg = get_cfg()
|
| 68 |
# cfg.merge_from_file("./configs/detectron2/faster_rcnn_R_50_FPN_3x.yaml")
|
| 69 |
+
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2
|
| 70 |
# cfg.MODEL.WEIGHTS = model_path
|
| 71 |
|
| 72 |
+
my_metadata = MetadataCatalog.get("dbmdz_coco_all")
|
| 73 |
# Fiber_metadata.thing_classes = ["Fiber", "Fiber","Fiber"]
|
| 74 |
+
my_metadata.thing_classes = ["Fiber", "Fiber";]
|
| 75 |
cfg = get_cfg()
|
| 76 |
cfg.merge_from_file("./configs/detectron2/mask_rcnn_R_50_FPN_3x.yaml")
|
| 77 |
cfg.MODEL.WEIGHTS = model_path #os.path.join(cfg.OUTPUT_DIR, "model_final.pth")
|
|
|
|
| 121 |
# im = cv2.imread(d["file_name"])
|
| 122 |
# outputs = predictor(im)
|
| 123 |
v = Visualizer(im[:, :, ::-1],
|
| 124 |
+
metadata=my_metadata , #Fiber_metadata,
|
| 125 |
scale=1,
|
| 126 |
instance_mode=ColorMode.IMAGE_BW # remove the colors of unsegmented pixels
|
| 127 |
)
|