Thiago Hersan commited on
Commit
7e0a636
1 Parent(s): 7f17661

output dataframe

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -23,10 +23,13 @@ def visualize_instance_seg_mask(mask, id2label):
23
 
24
  image = image / 255
25
 
26
- label2count = {id2label[id]: id2count[id] / image_total_pixels for id in label_ids}
27
- print(label2count)
 
 
 
28
 
29
- return image
30
 
31
 
32
  def query_image(img):
@@ -41,8 +44,8 @@ def query_image(img):
41
  demo = gr.Interface(
42
  query_image,
43
  inputs=[gr.Image()],
44
- outputs="image",
45
- title="maskformer-swin-large-coco results",
46
  allow_flagging="never",
47
  analytics_enabled=None
48
  )
 
23
 
24
  image = image / 255
25
 
26
+ dataframe = [[
27
+ f"{id2label[id]}",
28
+ f"{(100 * id2count[id] / image_total_pixels):.2f} %",
29
+ f"{np.sqrt(id2count[id] / image_total_pixels):.2f} m"
30
+ ] for id in label_ids if 'tree' in id2label[id]]
31
 
32
+ return image, dataframe
33
 
34
 
35
  def query_image(img):
 
44
  demo = gr.Interface(
45
  query_image,
46
  inputs=[gr.Image()],
47
+ outputs=["image", gr.DataFrame(headers=None, default_value=None, label="Area Info")],
48
+ title="maskformer-swin-large-coco",
49
  allow_flagging="never",
50
  analytics_enabled=None
51
  )