Add Hugging Face sign on
Browse files
app.py
CHANGED
|
@@ -80,6 +80,7 @@ def update_rankings_table():
|
|
| 80 |
return []
|
| 81 |
return rankings
|
| 82 |
|
|
|
|
| 83 |
def select_new_image():
|
| 84 |
"""Select a new image and its segmented versions."""
|
| 85 |
max_attempts = 10
|
|
@@ -216,13 +217,56 @@ head = """
|
|
| 216 |
</script>
|
| 217 |
"""
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
def gradio_interface():
|
| 221 |
"""Create and return the Gradio interface."""
|
| 222 |
with gr.Blocks(js=js, head=head, fill_width=True) as demo:
|
|
|
|
|
|
|
| 223 |
button_name = "Difference between masks"
|
| 224 |
|
| 225 |
with gr.Tabs() as tabs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
with gr.Tab("⚔️ Arena (battle)", id=0):
|
| 227 |
image_width = None
|
| 228 |
image_height = 600 # Limit image height to fit on a standard screen
|
|
@@ -318,35 +362,6 @@ def gradio_interface():
|
|
| 318 |
new_notice_markdown = get_notice_markdown()
|
| 319 |
|
| 320 |
return outputs + [new_notice_markdown]
|
| 321 |
-
|
| 322 |
-
with gr.Row(equal_height=True):
|
| 323 |
-
def on_enter_contest(username):
|
| 324 |
-
feedback_message = f"Thank you, {username or 'anonymous'}! You can see how you rank in the Hall of Fame."
|
| 325 |
-
logging.info(feedback_message)
|
| 326 |
-
return feedback_message
|
| 327 |
-
|
| 328 |
-
with gr.Column(scale=2):
|
| 329 |
-
username_input = gr.Textbox(
|
| 330 |
-
label="Enter your username (optional)",
|
| 331 |
-
placeholder="✨ Enter your username (optional)",
|
| 332 |
-
show_label=False,
|
| 333 |
-
submit_btn="Enter",
|
| 334 |
-
interactive=True
|
| 335 |
-
)
|
| 336 |
-
|
| 337 |
-
with gr.Column(scale=3):
|
| 338 |
-
feedback_output = gr.Textbox(
|
| 339 |
-
label="Feedback",
|
| 340 |
-
interactive=False,
|
| 341 |
-
show_label=False
|
| 342 |
-
)
|
| 343 |
-
|
| 344 |
-
username_input.submit(
|
| 345 |
-
fn=on_enter_contest,
|
| 346 |
-
inputs=username_input,
|
| 347 |
-
outputs=feedback_output
|
| 348 |
-
)
|
| 349 |
-
|
| 350 |
|
| 351 |
notice_markdown = gr.Markdown(get_notice_markdown(), elem_id="notice_markdown")
|
| 352 |
vote_a_button.click(
|
|
|
|
| 80 |
return []
|
| 81 |
return rankings
|
| 82 |
|
| 83 |
+
|
| 84 |
def select_new_image():
|
| 85 |
"""Select a new image and its segmented versions."""
|
| 86 |
max_attempts = 10
|
|
|
|
| 217 |
</script>
|
| 218 |
"""
|
| 219 |
|
| 220 |
+
def get_default_username(profile: gr.OAuthProfile | None) -> str:
|
| 221 |
+
"""
|
| 222 |
+
Returns the username if the user is logged in, or an empty string if not logged in.
|
| 223 |
+
"""
|
| 224 |
+
if profile is None:
|
| 225 |
+
return ""
|
| 226 |
+
return profile.username
|
| 227 |
|
| 228 |
def gradio_interface():
|
| 229 |
"""Create and return the Gradio interface."""
|
| 230 |
with gr.Blocks(js=js, head=head, fill_width=True) as demo:
|
| 231 |
+
|
| 232 |
+
|
| 233 |
button_name = "Difference between masks"
|
| 234 |
|
| 235 |
with gr.Tabs() as tabs:
|
| 236 |
+
with gr.Row(equal_height=True):
|
| 237 |
+
def on_enter_contest(username):
|
| 238 |
+
feedback_message = f"Thank you, {username or 'anonymous'}! You can see how you rank in the Hall of Fame."
|
| 239 |
+
logging.info(feedback_message)
|
| 240 |
+
return feedback_message
|
| 241 |
+
|
| 242 |
+
with gr.Column(scale=1):
|
| 243 |
+
username_input = gr.Textbox(
|
| 244 |
+
label="Enter your username (optional)",
|
| 245 |
+
placeholder="✨ Enter your username (optional)",
|
| 246 |
+
show_label=False,
|
| 247 |
+
submit_btn="Enter",
|
| 248 |
+
interactive=True
|
| 249 |
+
)
|
| 250 |
+
demo.load(fn=get_default_username, inputs=None, outputs=username_input)
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
with gr.Column(scale=3):
|
| 254 |
+
feedback_output = gr.Textbox(
|
| 255 |
+
label="Feedback",
|
| 256 |
+
interactive=False,
|
| 257 |
+
show_label=False
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
with gr.Column(scale=1):
|
| 261 |
+
gr.LoginButton()
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
username_input.submit(
|
| 265 |
+
fn=on_enter_contest,
|
| 266 |
+
inputs=username_input,
|
| 267 |
+
outputs=feedback_output
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
with gr.Tab("⚔️ Arena (battle)", id=0):
|
| 271 |
image_width = None
|
| 272 |
image_height = 600 # Limit image height to fit on a standard screen
|
|
|
|
| 362 |
new_notice_markdown = get_notice_markdown()
|
| 363 |
|
| 364 |
return outputs + [new_notice_markdown]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
|
| 366 |
notice_markdown = gr.Markdown(get_notice_markdown(), elem_id="notice_markdown")
|
| 367 |
vote_a_button.click(
|