|
import gradio as gr |
|
import pandas as pd |
|
|
|
def read_file(): |
|
df = pd.read_csv("./data.csv") |
|
return df |
|
|
|
def count_names(df): |
|
chris_count = (df["First"] == "Chris").sum() |
|
loick_count = (df["First"] == "Loïck").sum() |
|
return chris_count, loick_count |
|
|
|
def determine_goat(chris_count, loick_count): |
|
if chris_count > loick_count: |
|
return "The current GOAT is: Chris" |
|
elif loick_count > chris_count: |
|
return "The current GOAT is: Loïck" |
|
else: |
|
return "The current GOAT is: It's a tie between Chris and Loïck" |
|
|
|
def process_file(): |
|
df = read_file() |
|
chris_count, loick_count = count_names(df) |
|
goat = determine_goat(chris_count, loick_count) |
|
return df, f"Chris count: {chris_count}, Loïck count: {loick_count}", goat |
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# Leaderboard") |
|
|
|
gr.Markdown( |
|
"App to find out whether Chris or Loïck is the person who finds the most stuff on Hugging Face in advance. " |
|
"Whoever finds the most by December 31, 2025, will be declared the GOAT and owe the other an O'Tacos." |
|
) |
|
|
|
process_btn = gr.Button("Process data history") |
|
|
|
df_output = gr.DataFrame(label="DataFrame") |
|
count_output = gr.Textbox(label="Counts 🧮") |
|
goat_output = gr.Textbox(label="Current GOAT 🐐") |
|
|
|
process_btn.click( |
|
fn=process_file, |
|
outputs=[df_output, count_output, goat_output] |
|
) |
|
|
|
demo.launch() |