szk1ck commited on
Commit
3a0e570
·
1 Parent(s): be5d475

replace tabs

Browse files
Files changed (2) hide show
  1. app.py +53 -44
  2. assets/input_images.png +0 -0
app.py CHANGED
@@ -22,6 +22,7 @@ def clean(text_output):
22
  else:
23
  pass
24
 
 
25
  def clean_by_name(text_output):
26
  text_output, dir_name = text_output.split("+")
27
  if text_output=="complete":
@@ -90,9 +91,13 @@ def from_zip(inputs):
90
  return "objects.zip", complete()
91
 
92
 
93
- def from_image_files(images):
94
- dir_name = functions.get_random_name()
95
- os.makedirs(dir_name, exist_ok=True)
 
 
 
 
96
 
97
  for image in images:
98
  image_name = image.name
@@ -123,6 +128,51 @@ if __name__=="__main__":
123
 
124
  with gr.Blocks() as demo:
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  with gr.Tab("Zip"):
127
  gr.Markdown(
128
  """
@@ -198,47 +248,6 @@ if __name__=="__main__":
198
  )
199
 
200
 
201
-
202
- with gr.Tab("Images"):
203
- gr.Markdown(
204
- """
205
- <center><h1>Image Matting using U<sup>2</sup>-Net</h1></center>
206
- """
207
- )
208
- with gr.Row():
209
- gr.Markdown(
210
- """
211
- ### Input Image Files
212
- <img src='file/assets/input_zip.png' width="85%" height="85%">
213
- """
214
- )
215
- gr.Markdown(
216
- """
217
- ### Output Zip File
218
- <img src='file/assets/output_zip.png' width="85%" height="85%">
219
- """
220
- )
221
-
222
- with gr.Row():
223
- image_input = gr.File(file_count="multiple")
224
- image_output = gr.File()
225
- text_output = gr.Textbox(visible=False)
226
-
227
- btn = gr.Button("Run!")
228
-
229
- btn.click(
230
- fn=from_image_files,
231
- inputs=image_input,
232
- outputs=[image_output, text_output]
233
- )
234
- text_output.change(
235
- fn=clean_by_name,
236
- inputs=text_output,
237
- outputs=text_output
238
-
239
- )
240
-
241
-
242
 
243
 
244
  gr.Markdown(
 
22
  else:
23
  pass
24
 
25
+
26
  def clean_by_name(text_output):
27
  text_output, dir_name = text_output.split("+")
28
  if text_output=="complete":
 
91
  return "objects.zip", complete()
92
 
93
 
94
+ def from_image_files(images, text_class_name):
95
+
96
+ if not text_class_name=="":
97
+ dir_name = text_class_name
98
+ else:
99
+ dir_name = functions.get_random_name()
100
+ os.makedirs(dir_name, exist_ok=True)
101
 
102
  for image in images:
103
  image_name = image.name
 
128
 
129
  with gr.Blocks() as demo:
130
 
131
+
132
+ with gr.Tab("Images"):
133
+ gr.Markdown(
134
+ """
135
+ <center><h1>Image Matting using U<sup>2</sup>-Net</h1></center>
136
+ """
137
+ )
138
+ with gr.Row():
139
+ gr.Markdown(
140
+ """
141
+ ### Input Image Files
142
+ <img src='file/assets/input_images.png' width="90%" height="90%">
143
+ """
144
+ )
145
+ gr.Markdown(
146
+ """
147
+ ### Output Zip File
148
+ <img src='file/assets/output_zip.png' width="85%" height="85%">
149
+ """
150
+ )
151
+
152
+ with gr.Row():
153
+ with gr.Column():
154
+ text_class_name = gr.Textbox(label="Class Name", value="", placeholder="cat")
155
+ image_input = gr.File(file_count="multiple")
156
+ image_output = gr.File()
157
+ text_output = gr.Textbox(visible=False)
158
+
159
+ btn = gr.Button("Run!")
160
+
161
+ btn.click(
162
+ fn=from_image_files,
163
+ inputs=[image_input, text_class_name],
164
+ outputs=[image_output, text_output]
165
+ )
166
+ text_output.change(
167
+ fn=clean_by_name,
168
+ inputs=text_output,
169
+ outputs=text_output
170
+
171
+ )
172
+
173
+
174
+
175
+
176
  with gr.Tab("Zip"):
177
  gr.Markdown(
178
  """
 
248
  )
249
 
250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
252
 
253
  gr.Markdown(
assets/input_images.png ADDED