Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -212,6 +212,7 @@ footer {display: none}
|
|
212 |
}
|
213 |
"""
|
214 |
|
|
|
215 |
# Gradio UI
|
216 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
217 |
gr.HTML("""
|
@@ -222,6 +223,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
222 |
""")
|
223 |
|
224 |
with gr.Tabs() as tabs:
|
|
|
225 |
with gr.Tab("โจ Extract by Text", id="tab_prompt"):
|
226 |
with gr.Row(equal_height=True):
|
227 |
with gr.Column(scale=1, min_width=400):
|
@@ -255,27 +257,21 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
255 |
"๐พ Download Result",
|
256 |
interactive=False
|
257 |
)
|
258 |
-
|
259 |
with gr.Accordion("๐ Examples", open=False):
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
"boxes": [{"xmin": 51, "ymin": 511, "xmax": 639, "ymax": 1255}]
|
264 |
-
},
|
265 |
-
{
|
266 |
-
"image": "examples/black-lamp.jpg",
|
267 |
-
"boxes": [{"xmin": 88, "ymin": 148, "xmax": 700, "ymax": 1414}]
|
268 |
-
}
|
269 |
]
|
270 |
-
|
271 |
-
examples=
|
272 |
-
inputs=[
|
273 |
-
outputs=[
|
274 |
-
fn=
|
275 |
cache_examples=True
|
276 |
)
|
277 |
|
278 |
-
|
279 |
with gr.Tab("๐ Extract by Box", id="tab_bb"):
|
280 |
with gr.Row(equal_height=True):
|
281 |
with gr.Column(scale=1, min_width=400):
|
@@ -305,6 +301,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
305 |
interactive=False
|
306 |
)
|
307 |
|
|
|
308 |
with gr.Accordion("๐ Examples", open=False):
|
309 |
examples_bb = [
|
310 |
{
|
@@ -318,13 +315,12 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
318 |
]
|
319 |
ex_bb = gr.Examples(
|
320 |
examples=examples_bb,
|
321 |
-
inputs=[annotator],
|
322 |
outputs=[oimg_bb, dlbt_bb],
|
323 |
fn=process_bbox,
|
324 |
cache_examples=True
|
325 |
)
|
326 |
|
327 |
-
|
328 |
# Event handlers
|
329 |
btn.add(oimg)
|
330 |
for inp in [iimg, prompt]:
|
@@ -360,4 +356,5 @@ demo.launch(
|
|
360 |
server_name="0.0.0.0",
|
361 |
server_port=7860,
|
362 |
show_error=True
|
363 |
-
)
|
|
|
|
212 |
}
|
213 |
"""
|
214 |
|
215 |
+
# Gradio UI
|
216 |
# Gradio UI
|
217 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
218 |
gr.HTML("""
|
|
|
223 |
""")
|
224 |
|
225 |
with gr.Tabs() as tabs:
|
226 |
+
# Text ํญ
|
227 |
with gr.Tab("โจ Extract by Text", id="tab_prompt"):
|
228 |
with gr.Row(equal_height=True):
|
229 |
with gr.Column(scale=1, min_width=400):
|
|
|
257 |
"๐พ Download Result",
|
258 |
interactive=False
|
259 |
)
|
260 |
+
|
261 |
with gr.Accordion("๐ Examples", open=False):
|
262 |
+
examples = [
|
263 |
+
["examples/text.jpg", "text", "white background"],
|
264 |
+
["examples/black-lamp.jpg", "black lamp", "minimalist interior"]
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
]
|
266 |
+
ex = gr.Examples(
|
267 |
+
examples=examples,
|
268 |
+
inputs=[iimg, prompt, bg_prompt],
|
269 |
+
outputs=[oimg, dlbt],
|
270 |
+
fn=process_prompt,
|
271 |
cache_examples=True
|
272 |
)
|
273 |
|
274 |
+
# Bounding Box ํญ
|
275 |
with gr.Tab("๐ Extract by Box", id="tab_bb"):
|
276 |
with gr.Row(equal_height=True):
|
277 |
with gr.Column(scale=1, min_width=400):
|
|
|
301 |
interactive=False
|
302 |
)
|
303 |
|
304 |
+
# Bounding Box Examples
|
305 |
with gr.Accordion("๐ Examples", open=False):
|
306 |
examples_bb = [
|
307 |
{
|
|
|
315 |
]
|
316 |
ex_bb = gr.Examples(
|
317 |
examples=examples_bb,
|
318 |
+
inputs=[annotator], # annotator๊ฐ ์ด๋ฏธ ์ ์๋ ํ์ ์ฌ์ฉ
|
319 |
outputs=[oimg_bb, dlbt_bb],
|
320 |
fn=process_bbox,
|
321 |
cache_examples=True
|
322 |
)
|
323 |
|
|
|
324 |
# Event handlers
|
325 |
btn.add(oimg)
|
326 |
for inp in [iimg, prompt]:
|
|
|
356 |
server_name="0.0.0.0",
|
357 |
server_port=7860,
|
358 |
show_error=True
|
359 |
+
)
|
360 |
+
|