Spaces:
Runtime error
Runtime error
xinwei89
commited on
Commit
•
0639dc1
1
Parent(s):
008d1df
test datasets thing class
Browse files
backend.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
"""
|
2 |
-
|
3 |
Proof of concept showing effectiveness of a fine tuned instance segmentation model for detecting trees.
|
4 |
"""
|
5 |
import os
|
@@ -12,6 +12,7 @@ import numpy as np
|
|
12 |
import torch
|
13 |
import torchvision
|
14 |
import detectron2
|
|
|
15 |
|
16 |
# import some common detectron2 utilities
|
17 |
import itertools
|
@@ -96,6 +97,12 @@ def visualize_image(im, mode, tree_threshold:float, building_threshold:float, co
|
|
96 |
metadata = MetadataCatalog.get("urban-small_train")
|
97 |
category_names = metadata.get("thing_classes")
|
98 |
print(category_names)
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
# visualizer = Visualizer(im[:, :, ::-1],
|
100 |
# metadata=metadata,
|
101 |
# scale=0.5,
|
|
|
1 |
"""
|
2 |
+
aerial-segmentation
|
3 |
Proof of concept showing effectiveness of a fine tuned instance segmentation model for detecting trees.
|
4 |
"""
|
5 |
import os
|
|
|
12 |
import torch
|
13 |
import torchvision
|
14 |
import detectron2
|
15 |
+
import json
|
16 |
|
17 |
# import some common detectron2 utilities
|
18 |
import itertools
|
|
|
97 |
metadata = MetadataCatalog.get("urban-small_train")
|
98 |
category_names = metadata.get("thing_classes")
|
99 |
print(category_names)
|
100 |
+
with open("building_model_weight/_annotations.coco.json", "r") as f:
|
101 |
+
coco = json.load(f)
|
102 |
+
categories = coco["categories"]
|
103 |
+
print("categories", categories)
|
104 |
+
metadata.thing_classes = [c["name"] for c in categories]
|
105 |
+
print("metadata.thing_classes", metadata.thing_classes )
|
106 |
# visualizer = Visualizer(im[:, :, ::-1],
|
107 |
# metadata=metadata,
|
108 |
# scale=0.5,
|
building_model_weight/_annotations.coco.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|