tu11p commited on
Commit
2c8378d
β€’
1 Parent(s): 93f1f28

gradio interface to gr.blocks

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -103,18 +103,25 @@ def sepia(input_img):
103
  fig = draw_plot(pred_img, seg)
104
  return fig
105
 
106
- demo = gr.Interface(title='Semantic Segmentation with Cityscape',
107
- description='예제 이미지에 λŒ€ν•΄ 19가지 클래슀둜 의미적 λΆ„ν• (Semantic segmentaion)을 μˆ˜ν–‰ν•˜λŠ” Gradio 기반 νŽ˜μ΄μ§€μž…λ‹ˆλ‹€.',
108
- layout='vertical',
109
- theme='huggingface',
110
- examples_per_page=6,
111
- fn=sepia,
112
- inputs=gr.Image(shape=(400, 600)),
113
- outputs=['plot'],
114
- examples=["city_1.jpg", "city_2.jpg", "city_3.jpg",
115
- "city_4.jpg", "city_5.jpg", "city_6.jpg",
116
- "city_7.jpg", "city_8.jpg"],
117
- allow_flagging='never')
 
 
 
 
 
 
 
118
 
119
 
120
  demo.launch()
 
103
  fig = draw_plot(pred_img, seg)
104
  return fig
105
 
106
+
107
+ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
108
+ with gr.Tab("Semantic Segmentation with Cityscape Image"):
109
+ with gr.Row():
110
+ with gr.Column(scale=1):
111
+ input_image = gr.Image(label="Upload Image")
112
+ process_button = gr.Button("Process Image")
113
+ with gr.Column(scale=2):
114
+ output_plot = gr.Plot(label="Segmented Image")
115
+ examples_gallery = gr.Gallery(
116
+ ["city_1.jpg", "city_2.jpg", "city_3.jpg",
117
+ "city_4.jpg", "city_5.jpg", "city_6.jpg",
118
+ "city_7.jpg", "city_8.jpg"]
119
+ ).style(grid=3)
120
+ examples_gallery.click(sepia, inputs=input_image, outputs=output_plot)
121
+ process_button.click(sepia, inputs=input_image, outputs=output_plot)
122
+
123
+ with gr.Accordion("Details and Information"):
124
+ gr.Markdown("A Gradio-based page which performs Semantic Segmentation into 19 classes for an example image")
125
 
126
 
127
  demo.launch()