han-byeol commited on
Commit
d12c30e
1 Parent(s): cc7bbe2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -100,19 +100,19 @@ def sepia(input_img):
100
  color_seg[seg.numpy() == label, :] = color
101
 
102
  seg_text = segmentation_to_text(seg)
103
-
104
- # Show image + mask
105
- pred_img = np.array(input_img) * 0.5 + color_seg * 0.5
106
- pred_img = pred_img.astype(np.uint8)
107
 
108
- fig = draw_plot(pred_img, seg)
109
- plt.text(0, -20, seg_text, fontsize=12, color='black', ha='left', va='top', backgroundcolor='gray', wrap=True)
110
- return fig
 
 
 
 
111
 
112
 
113
  demo = gr.Interface(fn=sepia,
114
  inputs=gr.Image(shape=(400, 600)),
115
- outputs=['plot'],
116
  examples=["cityscapes-1.jpg", "cityscapes-2.jpg", "cityscapes-3.jpg"],
117
  allow_flagging='never')
118
 
 
100
  color_seg[seg.numpy() == label, :] = color
101
 
102
  seg_text = segmentation_to_text(seg)
 
 
 
 
103
 
104
+ pil_img = Image.fromarray(pred_img)
105
+
106
+ draw = ImageDraw.Draw(pil_img)
107
+ font = ImageFont.load_default()
108
+ draw.text((10,10), seg_text, font=font, fill="black")
109
+
110
+ return np.array(pil_img)
111
 
112
 
113
  demo = gr.Interface(fn=sepia,
114
  inputs=gr.Image(shape=(400, 600)),
115
+ outputs='image',
116
  examples=["cityscapes-1.jpg", "cityscapes-2.jpg", "cityscapes-3.jpg"],
117
  allow_flagging='never')
118