Tonic commited on
Commit
c514b03
Β·
verified Β·
1 Parent(s): bcd72e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -40
app.py CHANGED
@@ -36,10 +36,9 @@ def set_and_generate(url):
36
  generated_paragraph = generate_paragraph(url)
37
  return url, generated_paragraph
38
 
39
-
40
  # Create the Gradio Blocks interface
41
 
42
- with gr.Blocks(css=".thumbnail {width: 150px !important; height: 150px !important; object-fit: cover;}") as demo:
43
 
44
  gr.Markdown(title)
45
 
@@ -52,45 +51,31 @@ with gr.Blocks(css=".thumbnail {width: 150px !important; height: 150px !importan
52
  with gr.Column():
53
 
54
  image_url_input = gr.Textbox(label="Image URL")
55
-
56
  generate_button = gr.Button("Generate Paragraph")
57
 
58
 
59
 
60
- example_1 = gr.Button("Types of Falcons", elem_id="example_1")
61
-
62
- example_2 = gr.Button("Camel Racing - Saudi Arabia", elem_id="example_2")
63
-
64
- example_3 = gr.Button("Urban Street Scene - India", elem_id="example_3")
65
-
66
-
67
-
68
- # Attach CSS classes for making them look like thumbnails
69
-
70
- demo.load(lambda: None, every=2, target=example_1, inputs=(), outputs=[], ajax=False)
71
 
72
- demo.load(lambda: None, every=2, target=example_2, inputs=(), outputs=[], ajax=False)
73
-
74
- demo.load(lambda: None, every=2, target=example_3, inputs=(), outputs=[], ajax=False)
75
 
76
 
77
 
78
  with gr.Column():
79
 
80
- generated_paragraph_output = gr.Textbox(label="Generated Paragraph")
81
 
82
 
83
 
84
  # Wire click events
85
-
86
  generate_button.click(generate_paragraph, inputs=image_url_input, outputs=generated_paragraph_output)
87
 
88
 
89
-
90
  example_1.click(
91
 
92
  lambda: set_and_generate("https://www.animalspot.net/wp-content/uploads/2020/01/Types-of-Falcons.jpg"),
93
-
94
  outputs=[image_url_input, generated_paragraph_output]
95
 
96
  )
@@ -98,7 +83,6 @@ with gr.Blocks(css=".thumbnail {width: 150px !important; height: 150px !importan
98
  example_2.click(
99
 
100
  lambda: set_and_generate("https://www.leaders-mena.com/leaders/uploads/2023/01/The-Traditional-Camel-Racing-In-Saudi-Arabia-Unique-Sport-Activity-1024x576.jpg"),
101
-
102
  outputs=[image_url_input, generated_paragraph_output]
103
 
104
  )
@@ -106,52 +90,41 @@ with gr.Blocks(css=".thumbnail {width: 150px !important; height: 150px !importan
106
  example_3.click(
107
 
108
  lambda: set_and_generate("http://embed.robertharding.com/embed/1161-4342.jpg"),
109
-
110
  outputs=[image_url_input, generated_paragraph_output]
111
 
112
  )
113
 
 
 
114
  # Configure the CSS for thumbnails
115
 
116
  demo.css += """
117
 
118
  #example_1 {
119
 
120
- background: url("https://www.animalspot.net/wp-content/uploads/2020/01/Types-of-Falcons.jpg");
121
-
122
  background-size: cover;
123
 
124
- height: 150px;
125
-
126
  }
127
 
128
 
129
 
130
  #example_2 {
131
 
132
- background: url("https://www.leaders-mena.com/leaders/uploads/2023/01/The-Traditional-Camel-Racing-In-Saudi-Arabia-Unique-Sport-Activity-1024x576.jpg");
133
-
134
  background-size: cover;
135
 
136
- height: 150px;
137
-
138
  }
139
 
140
-
141
-
142
  #example_3 {
143
 
144
- background: url("http://embed.robertharding.com/embed/1161-4342.jpg");
145
-
146
  background-size: cover;
147
-
148
- height: 150px;
149
-
150
  }
151
 
 
152
 
153
 
154
-
155
- """
156
  # Launch the Gradio interface
 
157
  demo.launch()
 
36
  generated_paragraph = generate_paragraph(url)
37
  return url, generated_paragraph
38
 
 
39
  # Create the Gradio Blocks interface
40
 
41
+ with gr.Blocks(css=".thumbnail { width: 150px; height: 150px; object-fit: cover; }") as demo:
42
 
43
  gr.Markdown(title)
44
 
 
51
  with gr.Column():
52
 
53
  image_url_input = gr.Textbox(label="Image URL")
 
54
  generate_button = gr.Button("Generate Paragraph")
55
 
56
 
57
 
58
+ # Image thumbnails acting as buttons
 
 
 
 
 
 
 
 
 
 
59
 
60
+ example_1 = gr.Button(" ", elem_id="example_1", label=None)
61
+ example_2 = gr.Button(" ", elem_id="example_2", label=None)
62
+ example_3 = gr.Button(" ", elem_id="example_3", label=None)
63
 
64
 
65
 
66
  with gr.Column():
67
 
68
+ generated_paragraph_output = gr.Textbox(label="πŸ¦…Falcon VisionπŸ‘οΈ")
69
 
70
 
71
 
72
  # Wire click events
 
73
  generate_button.click(generate_paragraph, inputs=image_url_input, outputs=generated_paragraph_output)
74
 
75
 
 
76
  example_1.click(
77
 
78
  lambda: set_and_generate("https://www.animalspot.net/wp-content/uploads/2020/01/Types-of-Falcons.jpg"),
 
79
  outputs=[image_url_input, generated_paragraph_output]
80
 
81
  )
 
83
  example_2.click(
84
 
85
  lambda: set_and_generate("https://www.leaders-mena.com/leaders/uploads/2023/01/The-Traditional-Camel-Racing-In-Saudi-Arabia-Unique-Sport-Activity-1024x576.jpg"),
 
86
  outputs=[image_url_input, generated_paragraph_output]
87
 
88
  )
 
90
  example_3.click(
91
 
92
  lambda: set_and_generate("http://embed.robertharding.com/embed/1161-4342.jpg"),
 
93
  outputs=[image_url_input, generated_paragraph_output]
94
 
95
  )
96
 
97
+
98
+
99
  # Configure the CSS for thumbnails
100
 
101
  demo.css += """
102
 
103
  #example_1 {
104
 
105
+ background: url("https://www.animalspot.net/wp-content/uploads/2020/01/Types-of-Falcons.jpg") no-repeat center center;
 
106
  background-size: cover;
107
 
 
 
108
  }
109
 
110
 
111
 
112
  #example_2 {
113
 
114
+ background: url("https://www.leaders-mena.com/leaders/uploads/2023/01/The-Traditional-Camel-Racing-In-Saudi-Arabia-Unique-Sport-Activity-1024x576.jpg") no-repeat center center;
 
115
  background-size: cover;
116
 
 
 
117
  }
118
 
 
 
119
  #example_3 {
120
 
121
+ background: url("http://embed.robertharding.com/embed/1161-4342.jpg") no-repeat center center;
 
122
  background-size: cover;
 
 
 
123
  }
124
 
125
+ """
126
 
127
 
 
 
128
  # Launch the Gradio interface
129
+
130
  demo.launch()