pain commited on
Commit
0a3c175
·
1 Parent(s): 08545c6

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -110
app.py DELETED
@@ -1,110 +0,0 @@
1
- import gradio as gr
2
- import utils
3
-
4
-
5
- # Araclip demo
6
- with gr.Blocks() as demo_araclip:
7
-
8
- gr.Markdown("## Input parameters")
9
-
10
- txt = gr.Textbox(label="Text Query (Caption)")
11
- num = gr.Slider(label="Number of retrieved image", value=1, minimum=1, maximum=1000)
12
-
13
-
14
- with gr.Row():
15
- btn = gr.Button("Retrieve images", scale=1)
16
-
17
- gr.Markdown("## Retrieved Images")
18
-
19
- gallery = gr.Gallery(
20
- label="Generated images", show_label=True, elem_id="gallery"
21
- , columns=[5], rows=[1], object_fit="contain", height="auto")
22
-
23
-
24
- with gr.Row():
25
- lables = gr.Label(label="Text image similarity")
26
-
27
- with gr.Row():
28
-
29
- with gr.Column(scale=1):
30
- gr.Markdown("<div style='text-align: center; font-size: 24px; font-weight: bold;'>Data Retrieved based on Images Similarity</div>")
31
-
32
- json_output = gr.JSON()
33
-
34
- with gr.Column(scale=1):
35
- # gr.Markdown("### Data Retrieved based on Text similarity")
36
- # gr.Markdown("<div style='text-align: center;'> Data Retrieved based on Text similarity </div>")
37
- gr.Markdown("<div style='text-align: center; font-size: 24px; font-weight: bold;'>Data Retrieved based on Text similarity</div>")
38
- json_text = gr.JSON()
39
-
40
-
41
- btn.click(utils.predict, inputs=[txt, num], outputs=[gallery,lables, json_output, json_text])
42
-
43
-
44
- gr.Examples(
45
- examples=[["تخطي لاعب فريق بيتسبرج بايرتس منطقة اللوحة الرئيسية في مباراة بدوري البيسبول", 5],
46
- ["وقوف قطة بمخالبها على فأرة حاسوب على المكتب", 10],
47
- ["صحن به شوربة صينية بالخضار، وإلى جانبه بطاطس مقلية وزجاجة ماء", 7]],
48
- inputs=[txt, num],
49
- outputs=[gallery,lables, json_output, json_text],
50
- fn=utils.predict,
51
- cache_examples=False,
52
- )
53
-
54
- # mclip demo
55
- with gr.Blocks() as demo_mclip:
56
-
57
- gr.Markdown("## Input parameters")
58
-
59
- txt = gr.Textbox(label="Text Query (Caption)")
60
- num = gr.Slider(label="Number of retrieved image", value=1, minimum=1, maximum=1000)
61
-
62
- with gr.Row():
63
- btn = gr.Button("Retrieve images", scale=1)
64
-
65
- gr.Markdown("## Retrieved Images")
66
-
67
- gallery = gr.Gallery(
68
- label="Generated images", show_label=True, elem_id="gallery_mclip"
69
- , columns=[5], rows=[1], object_fit="contain", height="auto")
70
-
71
-
72
- lables = gr.Label()
73
-
74
- with gr.Row():
75
-
76
- with gr.Column(scale=1):
77
- gr.Markdown("## Images Retrieved")
78
- json_output = gr.JSON()
79
-
80
- with gr.Column(scale=1):
81
- gr.Markdown("## Text Retrieved")
82
- json_text = gr.JSON()
83
-
84
- btn.click(utils.predict_mclip, inputs=[txt, num], outputs=[gallery,lables, json_output, json_text])
85
-
86
-
87
-
88
-
89
- gr.Examples(
90
- examples=[["تخطي لاعب فريق بيتسبرج بايرتس منطقة اللوحة الرئيسية في مباراة بدوري البيسبول", 5],
91
- ["وقوف قطة بمخالبها على فأرة حاسوب على المكتب", 10],
92
- ["صحن به شوربة صينية بالخضار، وإلى جانبه بطاطس مقلية وزجاجة ماء", 7]],
93
- inputs=[txt, num],
94
- outputs=[gallery,lables, json_output, json_text],
95
- fn=utils.predict_mclip,
96
- cache_examples=False,
97
- )
98
-
99
-
100
- # Group the demos in a TabbedInterface
101
- with gr.Blocks() as demo:
102
-
103
- gr.Markdown("<font color=red size=10><center>AraClip: Arabic Image Retrieval Application</center></font>")
104
- gr.TabbedInterface([demo_araclip, demo_mclip], ["Our Model", "Mclip model"])
105
-
106
-
107
-
108
- if __name__ == "__main__":
109
-
110
- demo.launch()