add feedback loop on name entry + leaderboard emojisé
Browse files
app.py
CHANGED
@@ -150,6 +150,33 @@ def gradio_interface():
|
|
150 |
with gr.Tabs() as tabs:
|
151 |
with gr.Tab("⚔️ Arena (battle)", id=0):
|
152 |
notice_markdown = gr.Markdown(get_notice_markdown(), elem_id="notice_markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
filename, input_image, segmented_a, segmented_b, a_name, b_name = select_new_image()
|
155 |
model_a_name = gr.State(a_name)
|
@@ -158,7 +185,6 @@ def gradio_interface():
|
|
158 |
|
159 |
# Compute the absolute difference between the masks
|
160 |
mask_difference = compute_mask_difference(segmented_a, segmented_b)
|
161 |
-
username_input = gr.Textbox(label="Enter your username (optional)", placeholder="Username for prize notification")
|
162 |
|
163 |
with gr.Row():
|
164 |
image_a_display = gr.Image(
|
@@ -272,7 +298,7 @@ def gradio_interface():
|
|
272 |
outputs=vote_table
|
273 |
)
|
274 |
|
275 |
-
with gr.Tab("👥
|
276 |
current_time = datetime.now()
|
277 |
start_of_week = current_time - timedelta(days=current_time.weekday())
|
278 |
|
@@ -289,7 +315,15 @@ def gradio_interface():
|
|
289 |
for vote in weekly_votes:
|
290 |
user_vote_count[vote.user_id] = user_vote_count.get(vote.user_id, 0) + 1
|
291 |
sorted_users = sorted(user_vote_count.items(), key=lambda x: x[1], reverse=True)
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
user_leaderboard_table = gr.Dataframe(
|
295 |
headers=["User", "Votes"],
|
|
|
150 |
with gr.Tabs() as tabs:
|
151 |
with gr.Tab("⚔️ Arena (battle)", id=0):
|
152 |
notice_markdown = gr.Markdown(get_notice_markdown(), elem_id="notice_markdown")
|
153 |
+
with gr.Row(equal_height=True):
|
154 |
+
def on_enter_contest(username):
|
155 |
+
feedback_message = f"Thank you, {username or 'anonymous'}! You can see how you rank in the Hall of Fame."
|
156 |
+
logging.info(feedback_message)
|
157 |
+
return feedback_message
|
158 |
+
|
159 |
+
with gr.Column(scale=1):
|
160 |
+
username_input = gr.Textbox(
|
161 |
+
label="Enter your username (optional)",
|
162 |
+
placeholder="✨ Enter your username (optional) ✨",
|
163 |
+
show_label=False,
|
164 |
+
submit_btn="Enter",
|
165 |
+
interactive=True
|
166 |
+
)
|
167 |
+
|
168 |
+
with gr.Column(scale=4):
|
169 |
+
feedback_output = gr.Textbox(
|
170 |
+
label="Feedback",
|
171 |
+
interactive=False,
|
172 |
+
show_label=False
|
173 |
+
)
|
174 |
+
|
175 |
+
username_input.submit(
|
176 |
+
fn=on_enter_contest,
|
177 |
+
inputs=username_input,
|
178 |
+
outputs=feedback_output
|
179 |
+
)
|
180 |
|
181 |
filename, input_image, segmented_a, segmented_b, a_name, b_name = select_new_image()
|
182 |
model_a_name = gr.State(a_name)
|
|
|
185 |
|
186 |
# Compute the absolute difference between the masks
|
187 |
mask_difference = compute_mask_difference(segmented_a, segmented_b)
|
|
|
188 |
|
189 |
with gr.Row():
|
190 |
image_a_display = gr.Image(
|
|
|
298 |
outputs=vote_table
|
299 |
)
|
300 |
|
301 |
+
with gr.Tab("👥 Hall of Fame", id=3) as user_leaderboard_tab:
|
302 |
current_time = datetime.now()
|
303 |
start_of_week = current_time - timedelta(days=current_time.weekday())
|
304 |
|
|
|
315 |
for vote in weekly_votes:
|
316 |
user_vote_count[vote.user_id] = user_vote_count.get(vote.user_id, 0) + 1
|
317 |
sorted_users = sorted(user_vote_count.items(), key=lambda x: x[1], reverse=True)
|
318 |
+
|
319 |
+
# Add medals for the top 3 users
|
320 |
+
medals = ["🥇", "🥈", "🥉"]
|
321 |
+
leaderboard = []
|
322 |
+
for index, (user, count) in enumerate(sorted_users):
|
323 |
+
medal = medals[index] if index < len(medals) else ""
|
324 |
+
leaderboard.append([f"{medal} {user}", count])
|
325 |
+
|
326 |
+
return leaderboard
|
327 |
|
328 |
user_leaderboard_table = gr.Dataframe(
|
329 |
headers=["User", "Votes"],
|