Update app.py
Browse files
app.py
CHANGED
@@ -171,6 +171,29 @@ def update_vote(vote_type, session_id, is_example_image):
|
|
171 |
with open("./assets/showui.png", "rb") as image_file:
|
172 |
base64_image = base64.b64encode(image_file.read()).decode("utf-8")
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
def build_demo(embed_mode, concurrency_count=1):
|
175 |
with gr.Blocks(title="ShowUI Demo", theme=gr.themes.Default()) as demo:
|
176 |
state_image_path = gr.State(value=None)
|
@@ -185,17 +208,6 @@ def build_demo(embed_mode, concurrency_count=1):
|
|
185 |
<img src="data:image/png;base64,{base64_image}" alt="ShowUI" width="320" style="margin-bottom: 10px;"/>
|
186 |
</div>
|
187 |
<p>ShowUI is a lightweight vision-language-action model for GUI agents.</p>
|
188 |
-
<div style="display: flex; justify-content: center; gap: 15px; font-size: 20px;">
|
189 |
-
<a href="https://huggingface.co/showlab/ShowUI-2B" target="_blank">
|
190 |
-
<img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-ShowUI--2B-blue" alt="model"/>
|
191 |
-
</a>
|
192 |
-
<a href="https://arxiv.org/abs/2411.17465" target="_blank">
|
193 |
-
<img src="https://img.shields.io/badge/arXiv%20paper-2411.17465-b31b1b.svg" alt="arXiv"/>
|
194 |
-
</a>
|
195 |
-
<a href="https://github.com/showlab/ShowUI" target="_blank">
|
196 |
-
<img src="https://img.shields.io/badge/GitHub-ShowUI-black" alt="GitHub"/>
|
197 |
-
</a>
|
198 |
-
</div>
|
199 |
</div>
|
200 |
"""
|
201 |
)
|
@@ -210,25 +222,6 @@ def build_demo(embed_mode, concurrency_count=1):
|
|
210 |
)
|
211 |
submit_btn = gr.Button(value="Submit", variant="primary")
|
212 |
|
213 |
-
examples = [
|
214 |
-
["./examples/app_store.png", "Download Kindle.", True],
|
215 |
-
["./examples/ios_setting.png", "Turn off Do not disturb.", True],
|
216 |
-
["./examples/apple_music.png", "Star to favorite.", True],
|
217 |
-
["./examples/map.png", "Boston.", True],
|
218 |
-
["./examples/wallet.png", "Scan a QR code.", True],
|
219 |
-
["./examples/word.png", "More shapes.", True],
|
220 |
-
["./examples/web_shopping.png", "Proceed to checkout.", True],
|
221 |
-
["./examples/web_forum.png", "Post my comment.", True],
|
222 |
-
["./examples/safari_google.png", "Click on search bar.", True],
|
223 |
-
]
|
224 |
-
|
225 |
-
def check_if_example(query):
|
226 |
-
"""Check if the query matches an example."""
|
227 |
-
for _, example_query, is_example in examples:
|
228 |
-
if example_query == query:
|
229 |
-
return is_example
|
230 |
-
return False
|
231 |
-
|
232 |
gr.Examples(
|
233 |
examples=[[e[0], e[1]] for e in examples],
|
234 |
inputs=[imagebox, textbox],
|
@@ -239,11 +232,6 @@ def build_demo(embed_mode, concurrency_count=1):
|
|
239 |
|
240 |
with gr.Column(scale=8):
|
241 |
output_img = gr.Image(type="pil", label="Output Image")
|
242 |
-
gr.HTML(
|
243 |
-
"""
|
244 |
-
<p><strong>Note:</strong> The <span style="color: red;">red point</span> on the output image represents the predicted clickable coordinates.</p>
|
245 |
-
"""
|
246 |
-
)
|
247 |
output_coords = gr.Textbox(label="Clickable Coordinates")
|
248 |
|
249 |
with gr.Row(elem_id="action-buttons", equal_height=True):
|
|
|
171 |
with open("./assets/showui.png", "rb") as image_file:
|
172 |
base64_image = base64.b64encode(image_file.read()).decode("utf-8")
|
173 |
|
174 |
+
examples = [
|
175 |
+
["./examples/app_store.png", "Download Kindle.", True],
|
176 |
+
["./examples/ios_setting.png", "Turn off Do not disturb.", True],
|
177 |
+
["./examples/apple_music.png", "Star to favorite.", True],
|
178 |
+
["./examples/map.png", "Boston.", True],
|
179 |
+
["./examples/wallet.png", "Scan a QR code.", True],
|
180 |
+
["./examples/word.png", "More shapes.", True],
|
181 |
+
["./examples/web_shopping.png", "Proceed to checkout.", True],
|
182 |
+
["./examples/web_forum.png", "Post my comment.", True],
|
183 |
+
["./examples/safari_google.png", "Click on search bar.", True],
|
184 |
+
]
|
185 |
+
|
186 |
+
def check_if_example(query):
|
187 |
+
"""Check if the query matches an example query."""
|
188 |
+
print(f"Checking query: {query}")
|
189 |
+
for _, example_query, is_example in examples:
|
190 |
+
print(f"Comparing with example: {example_query}")
|
191 |
+
if query.strip() == example_query.strip():
|
192 |
+
print("Match found!")
|
193 |
+
return is_example
|
194 |
+
print("No match found.")
|
195 |
+
return False
|
196 |
+
|
197 |
def build_demo(embed_mode, concurrency_count=1):
|
198 |
with gr.Blocks(title="ShowUI Demo", theme=gr.themes.Default()) as demo:
|
199 |
state_image_path = gr.State(value=None)
|
|
|
208 |
<img src="data:image/png;base64,{base64_image}" alt="ShowUI" width="320" style="margin-bottom: 10px;"/>
|
209 |
</div>
|
210 |
<p>ShowUI is a lightweight vision-language-action model for GUI agents.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
</div>
|
212 |
"""
|
213 |
)
|
|
|
222 |
)
|
223 |
submit_btn = gr.Button(value="Submit", variant="primary")
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
gr.Examples(
|
226 |
examples=[[e[0], e[1]] for e in examples],
|
227 |
inputs=[imagebox, textbox],
|
|
|
232 |
|
233 |
with gr.Column(scale=8):
|
234 |
output_img = gr.Image(type="pil", label="Output Image")
|
|
|
|
|
|
|
|
|
|
|
235 |
output_coords = gr.Textbox(label="Clickable Coordinates")
|
236 |
|
237 |
with gr.Row(elem_id="action-buttons", equal_height=True):
|