AdilEsset commited on
Commit
d474fd1
·
1 Parent(s): a621450

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -5,7 +5,6 @@ import pickle
5
  from PIL import Image, ImageDraw
6
  import numpy as np
7
  from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
8
-
9
  from scipy.ndimage import center_of_mass
10
 
11
  def combine_ims(im1, im2, val=128):
@@ -45,7 +44,7 @@ def get_out_image(image, predicted_semantic_map):
45
  extracted_tags = []
46
  for id, (y, x) in class_centers.items():
47
  class_name = str(class_names[id - 1])
48
- extracted_tags.append({"class_name": class_name, "coordinates": (x, y)})
49
  draw.text((x, y), class_name, fill='black')
50
 
51
  return image_mask, extracted_tags
@@ -74,7 +73,7 @@ model.eval()
74
  demo = gr.Interface(
75
  gradio_process,
76
  inputs=gr.inputs.Image(type="pil"),
77
- outputs=[gr.outputs.Image(type="pil"), gr.outputs.JSON()],
78
  title="Semantic Segmentation",
79
  examples=glob.glob('./examples/*.jpg'),
80
  allow_flagging="never",
 
5
  from PIL import Image, ImageDraw
6
  import numpy as np
7
  from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
 
8
  from scipy.ndimage import center_of_mass
9
 
10
  def combine_ims(im1, im2, val=128):
 
44
  extracted_tags = []
45
  for id, (y, x) in class_centers.items():
46
  class_name = str(class_names[id - 1])
47
+ extracted_tags.append(f"{class_name}: ({x}, {y})")
48
  draw.text((x, y), class_name, fill='black')
49
 
50
  return image_mask, extracted_tags
 
73
  demo = gr.Interface(
74
  gradio_process,
75
  inputs=gr.inputs.Image(type="pil"),
76
+ outputs=[gr.outputs.Image(type="pil"), gr.outputs.Text()],
77
  title="Semantic Segmentation",
78
  examples=glob.glob('./examples/*.jpg'),
79
  allow_flagging="never",