kmc0003a commited on
Commit
718484d
1 Parent(s): ba9dc0d

Upload 6 files

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -1,5 +1,3 @@
1
- def sepia(input_img, intensity):
2
-
3
  import gradio as gr
4
 
5
  from matplotlib import gridspec
@@ -10,10 +8,10 @@ import tensorflow as tf
10
  from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
11
 
12
  feature_extractor = SegformerFeatureExtractor.from_pretrained(
13
- "nvidia/segformer-b5-finetuned-cityscapes-1024-1024"
14
  )
15
  model = TFSegformerForSemanticSegmentation.from_pretrained(
16
- "nvidia/segformer-b5-finetuned-cityscapes-1024-1024"
17
  )
18
 
19
  def ade_palette():
@@ -228,21 +226,17 @@ def sepia(input_img):
228
  color_seg[seg.numpy() == label, :] = color
229
 
230
  # Show image + mask
231
- pred_img = np.array(input_img) * (1 - intensity) + color_seg * intensity
232
  pred_img = pred_img.astype(np.uint8)
233
 
234
  fig = draw_plot(pred_img, seg)
235
  return fig
236
 
 
 
 
 
 
237
 
238
- demo = gr.Interface(
239
- fn=sepia,
240
- inputs=[gr.inputs.Image(shape=(400, 600)), gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=0.5)],
241
- outputs='plot',
242
- examples=[["cheonggyecheon_stream_in_seoul_city.jpg", 0.5], ["Incheon_stadium.jpg", 0.7],
243
- ["Incheon_city.jpg", 0.3]],
244
- title="Semantic Segmentation",
245
- description="This is a demo of semantic segmentation using Segformer.",
246
- allow_flagging=False,
247
- )
248
- demo.launch()
 
 
 
1
  import gradio as gr
2
 
3
  from matplotlib import gridspec
 
8
  from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
9
 
10
  feature_extractor = SegformerFeatureExtractor.from_pretrained(
11
+ "mattmdjaga/segformer_b2_clothes"
12
  )
13
  model = TFSegformerForSemanticSegmentation.from_pretrained(
14
+ "mattmdjaga/segformer_b2_clothes"
15
  )
16
 
17
  def ade_palette():
 
226
  color_seg[seg.numpy() == label, :] = color
227
 
228
  # Show image + mask
229
+ pred_img = np.array(input_img) * 0.5 + color_seg * 0.5
230
  pred_img = pred_img.astype(np.uint8)
231
 
232
  fig = draw_plot(pred_img, seg)
233
  return fig
234
 
235
+ demo = gr.Interface(fn=sepia,
236
+ inputs=gr.Image(shape=(400, 600)),
237
+ outputs=['plot'],
238
+ examples=["person-1.jpg", "person-2.jpg", "person-3.jpg", "person-4.jpg", "person-5.jpg"],
239
+ allow_flagging='never')
240
 
241
+
242
+ demo.launch()