Spaces:
Runtime error
Runtime error
mejor UI
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: telecom_object_detection.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
-
__all__ = ['title', 'css', 'urls', '
|
5 |
|
6 |
# %% telecom_object_detection.ipynb 2
|
7 |
import gradio as gr
|
@@ -16,46 +16,50 @@ h1#title {
|
|
16 |
}
|
17 |
'''
|
18 |
|
19 |
-
# %% telecom_object_detection.ipynb
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
|
24 |
-
def
|
25 |
-
return
|
26 |
|
27 |
-
def
|
28 |
-
return
|
29 |
|
30 |
-
with demo:
|
|
|
31 |
gr.Markdown(title)
|
32 |
|
33 |
with gr.Tabs():
|
34 |
-
|
35 |
-
with gr.TabItem('Image Upload'):
|
36 |
with gr.Row():
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
with gr.Row():
|
41 |
-
example_images = gr.Dataset(components=[img_input],
|
42 |
samples=[[path.as_posix()] for path in sorted(Path('images').rglob('*.jpg'))]
|
|
|
|
|
|
|
|
|
43 |
)
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
47 |
with gr.Row():
|
48 |
-
|
49 |
img_output_from_url = gr.Image(shape=(650,650))
|
50 |
|
51 |
with gr.Row():
|
52 |
example_url = gr.Dataset(components=[url_input],samples=[[str(url)] for url in urls])
|
|
|
53 |
|
54 |
-
url_but = gr.Button('Detect')
|
55 |
-
|
56 |
-
#url_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_url,queue=True)
|
57 |
-
#img_but.click(detect_objects,inputs=[options,url_input,img_input,slider_input],outputs=img_output_from_upload,queue=True)
|
58 |
-
example_images.click(fn=set_example_image,inputs=[example_images],outputs=[img_input])
|
59 |
-
example_url.click(fn=set_example_url,inputs=[example_url],outputs=[url_input])
|
60 |
|
61 |
-
|
|
|
|
|
|
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: telecom_object_detection.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
+
__all__ = ['title', 'css', 'urls', 'flip_text', 'flip_image']
|
5 |
|
6 |
# %% telecom_object_detection.ipynb 2
|
7 |
import gradio as gr
|
|
|
16 |
}
|
17 |
'''
|
18 |
|
19 |
+
# %% telecom_object_detection.ipynb 5
|
20 |
+
import numpy as np
|
21 |
+
import gradio as gr
|
22 |
|
23 |
+
urls = ["https://c8.alamy.com/comp/J2AB4K/the-new-york-stock-exchange-on-the-wall-street-in-new-york-J2AB4K.jpg"]
|
24 |
|
25 |
+
def flip_text(x):
|
26 |
+
return x[::-1]
|
27 |
|
28 |
+
def flip_image(x):
|
29 |
+
return np.fliplr(x)
|
30 |
|
31 |
+
with gr.Blocks(css=css) as demo:
|
32 |
+
|
33 |
gr.Markdown(title)
|
34 |
|
35 |
with gr.Tabs():
|
36 |
+
with gr.TabItem("Image Upload"):
|
|
|
37 |
with gr.Row():
|
38 |
+
image_input = gr.Image()
|
39 |
+
image_output = gr.Image()
|
|
|
40 |
with gr.Row():
|
41 |
+
"""example_images = gr.Dataset(components=[img_input],
|
42 |
samples=[[path.as_posix()] for path in sorted(Path('images').rglob('*.jpg'))]
|
43 |
+
)"""
|
44 |
+
example_images = gr.Examples(
|
45 |
+
examples=[path.as_posix() for path in sorted(Path('images').rglob('*.jpg'))],
|
46 |
+
inputs=image_input
|
47 |
)
|
48 |
+
|
49 |
+
|
50 |
+
image_button = gr.Button("Detect")
|
51 |
+
|
52 |
+
with gr.TabItem("Image URL"):
|
53 |
with gr.Row():
|
54 |
+
text_input = gr.Textbox(lines=2, label='Enter valid image URL here..')
|
55 |
img_output_from_url = gr.Image(shape=(650,650))
|
56 |
|
57 |
with gr.Row():
|
58 |
example_url = gr.Dataset(components=[url_input],samples=[[str(url)] for url in urls])
|
59 |
+
text_button = gr.Button("Detect")
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
+
text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
63 |
+
image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
64 |
+
|
65 |
+
demo.launch()
|