File size: 1,421 Bytes
43bb47f
 
1e36ee7
 
 
43bb47f
 
1e36ee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43bb47f
 
 
9e7d9be
c01b0e6
9e7d9be
 
 
 
43bb47f
1e36ee7
c01b0e6
9e7d9be
43bb47f
1e36ee7
 
 
43bb47f
 
1e36ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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()