Spaces:
Runtime error
Runtime error
xinwei89
commited on
Commit
•
45a81a5
1
Parent(s):
74373c9
get predict meta
Browse files- app.py +6 -6
- backend.py +7 -7
app.py
CHANGED
@@ -2,15 +2,15 @@ import gradio as gr
|
|
2 |
from backend import visualize_image
|
3 |
|
4 |
# gradio inputs
|
5 |
-
image_input = gr.
|
6 |
-
color_mode_select = gr.
|
7 |
-
mode_dropdown = gr.
|
8 |
|
9 |
-
tree_threshold_slider = gr.
|
10 |
-
building_threshold_slider = gr.
|
11 |
|
12 |
# gradio outputs
|
13 |
-
output_image = gr.
|
14 |
title = "Aerial Image Segmentation"
|
15 |
description = "An instance segmentation demo for identifying boundaries of buildings and trees in aerial images using DETR (End-to-End Object Detection) model with MaskRCNN-101 backbone"
|
16 |
|
|
|
2 |
from backend import visualize_image
|
3 |
|
4 |
# gradio inputs
|
5 |
+
image_input = gr.components.Image(type="pil", label="Input Image")
|
6 |
+
color_mode_select = gr.components.Radio(["Black/white", "Random", "Segmentation"], label="Color Mode", default="Segmentation")
|
7 |
+
mode_dropdown = gr.components.Dropdown(["Trees", "Buildings", "Both"], label="Detection Mode", default="Both")
|
8 |
|
9 |
+
tree_threshold_slider = gr.components.Slider(0, 1, 0.1, 0.7, label='Set confidence threshold "%" for trees')
|
10 |
+
building_threshold_slider = gr.components.Slider(0, 1, 0.1, 0.7, label='Set confidence threshold "%" for buildings')
|
11 |
|
12 |
# gradio outputs
|
13 |
+
output_image = gr.components.Image(type="pil", label="Output Image")
|
14 |
title = "Aerial Image Segmentation"
|
15 |
description = "An instance segmentation demo for identifying boundaries of buildings and trees in aerial images using DETR (End-to-End Object Detection) model with MaskRCNN-101 backbone"
|
16 |
|
backend.py
CHANGED
@@ -81,18 +81,18 @@ def visualize_image(im, mode="BOTH", tree_threshold=0.7, building_threshold=0.7,
|
|
81 |
building_instances = segment_building(im, building_threshold)
|
82 |
instances = Instances.cat([tree_instances, building_instances])
|
83 |
|
84 |
-
|
|
|
|
|
85 |
|
86 |
visualizer = Visualizer(im[:, :, ::-1],
|
87 |
-
metadata=
|
88 |
scale=0.5,
|
89 |
instance_mode=color_mode)
|
90 |
|
91 |
-
dataset_names = MetadataCatalog.list()
|
92 |
-
print(dataset_names)
|
93 |
-
|
94 |
-
print("metadata", type(metadata), metadata)
|
95 |
-
print('metadata.get("thing_classes")', type(metadata.get("thing_classes")), metadata.get("thing_classes"))
|
96 |
# category_names = metadata.get("thing_classes")
|
97 |
# visualizer = Visualizer(im[:, :, ::-1],
|
98 |
# metadata=metadata,
|
|
|
81 |
building_instances = segment_building(im, building_threshold)
|
82 |
instances = Instances.cat([tree_instances, building_instances])
|
83 |
|
84 |
+
metadata = MetadataCatalog.get("predict")
|
85 |
+
print("metadata", type(metadata), metadata)
|
86 |
+
print('metadata.get("thing_classes")', type(metadata.get("thing_classes")), metadata.get("thing_classes"))
|
87 |
|
88 |
visualizer = Visualizer(im[:, :, ::-1],
|
89 |
+
metadata=metadata,
|
90 |
scale=0.5,
|
91 |
instance_mode=color_mode)
|
92 |
|
93 |
+
# dataset_names = MetadataCatalog.list()
|
94 |
+
# print(dataset_names)
|
95 |
+
|
|
|
|
|
96 |
# category_names = metadata.get("thing_classes")
|
97 |
# visualizer = Visualizer(im[:, :, ::-1],
|
98 |
# metadata=metadata,
|