File size: 6,996 Bytes
dbf7cb0
 
33a4cab
 
 
dbf7cb0
 
 
 
 
 
9fc4854
 
 
 
 
 
 
8ee1346
 
 
33a4cab
 
 
 
8ee1346
33a4cab
 
 
 
 
 
 
9fc4854
33a4cab
9fc4854
dbf7cb0
33a4cab
 
9fc4854
33a4cab
9fc4854
 
33a4cab
 
 
 
 
 
 
9fc4854
33a4cab
9fc4854
33a4cab
 
dbf7cb0
33a4cab
 
 
 
 
dbf7cb0
33a4cab
 
 
 
 
dbf7cb0
33a4cab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9fc4854
33a4cab
9fc4854
33a4cab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dbf7cb0
33a4cab
1fbfac0
33a4cab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9fc4854
33a4cab
9fc4854
33a4cab
9fc4854
33a4cab
9fc4854
 
 
 
 
 
 
 
 
 
 
33a4cab
dbf7cb0
 
 
 
8ee1346
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import gradio as gr
from apscheduler.schedulers.background import BackgroundScheduler
from src.css_html_js import custom_css
from src.envs import API, REPO_ID
from src.process_leaderboard_data import Leaderboard


def restart_space():
    API.restart_space(repo_id=REPO_ID)


CITATION_TEXT = r"""@misc{cloneval,
    author={Christop, Iwona and Kuczyński, Tomasz and Kubis, Marek},
    title={{ClonEval: An Open Voice Cloning Benchmark}},
    year={2025},
}"""


app = gr.Blocks(css=custom_css)

with app:
    # Init class Leaderboard
    leaderboard = Leaderboard()

    # Custom CSS styling for tab-item components
    app.css = """
    .tab-item {
        font-size: 10px;
        padding: 10px 20px;
    }
    """

    # Title and Description of the Leaderboard
    gr.HTML(open("pages/description.html", "r").read())

    # LEADERBOARD
    with gr.Tabs(elem_classes="tab-buttons") as tabs:
        with gr.TabItem("🏅 Leaderboard", elem_id="Leaderboard", id=0, elem_classes="tab-item"):

            # OVERALL
            with gr.TabItem("Overall", elem_id="Overall", id=1, elem_classes="tab-item"):
                gr.Markdown(open("pages/overall.md", "r").read())

                # Create and display leaderboard table
                leaderboard_dataframe = leaderboard.create_leaderboard_data('All', 'wavlm', 'emotion')
                leaderboard_table = gr.DataFrame(leaderboard_dataframe,
                                                 datatype= ["markdown" if col == "Model" else "str" for col in leaderboard_dataframe.columns],
                                                 interactive=False,
                )

            # EMOTIONS
            with gr.TabItem("Emotions", elem_id="Emotions", id=2, elem_classes="tab-item"):
                gr.Markdown(open("pages/emotions.md", "r").read())

                # UI for selecting dataset and emotion options
                with gr.Row():
                    with gr.Column():
                        dataset = gr.Radio(
                                choices = leaderboard.get_emotional_dataset_list(),
                                value = None,
                                label = "Dataset",
                            )
                    with gr.Column(min_width=750):
                        emotion = gr.Radio(
                                choices = leaderboard.get_emotion_list(),
                                value = "Anger",
                                label = "Emotion",
                            )
                        
                # Create and display leaderboard table
                leaderboard_dataframe = leaderboard.create_leaderboard_data(emotion.value, 'wavlm', 'emotion')
                leaderboard_table = gr.DataFrame(leaderboard_dataframe,
                                                 datatype= ["markdown" if col == "Model" else "str" for col in leaderboard_dataframe.columns],
                                                 interactive=False,
                )

                # Update leaderboard table based on user selection changes in emotion or dataset options.
                dataset.change(leaderboard.update_leaderboard_data_in_emotion_section,
                    [dataset, gr.State('dataset'), leaderboard_table],
                    [emotion, leaderboard_table]
                )
                emotion.change(leaderboard.update_leaderboard_data_in_emotion_section,
                    [emotion, gr.State('emotion'), leaderboard_table],
                    [dataset, leaderboard_table]
                )


            # FEATURES
            with gr.TabItem("Features", elem_id="Features", id=3, elem_classes="tab-item"):
                gr.Markdown(open("pages/features.md", "r").read())

                # UI for selecting dataset, emotion, and feature options
                with gr.Row():
                    with gr.Column():
                        dataset = gr.Radio(
                                choices = leaderboard.get_emotional_dataset_list(),
                                value = None,
                                elem_id = "dataset_features",
                                label = "Dataset",
                            )
                    with gr.Column(min_width=750):
                        emotion = gr.Radio(
                                choices = leaderboard.get_emotion_list(),
                                value = "Anger",
                                elem_id = "emotion_features",
                                label = "Emotion",
                            )
                with gr.Row():
                        hidden_columns = ['model', 'dataset', 'emotion', 'wavlm', "Unnamed: 0"]
                        feature = gr.Radio(
                            choices = [kol for kol in list(leaderboard.get_models_performance_dataframe_column()) if kol not in hidden_columns],
                            value = "pitch",
                            label = "Feature",
                        )

                # Create and display leaderboard table
                leaderboard_dataframe = leaderboard.create_leaderboard_data(emotion.value, feature.value, 'emotion')
                leaderboard_table = gr.DataFrame(leaderboard_dataframe,
                                                 datatype= ["markdown" if col == "Model" else "str" for col in leaderboard_dataframe.columns],
                                                 interactive=False,
                )

                # Update leaderboard table based on user selection changes in emotion, dataset, or feature options.
                emotion.change(leaderboard.update_leaderboard_data_in_feature_section,
                    [emotion, feature, gr.State('emotion'), leaderboard_table],
                    [dataset, leaderboard_table]
                )
                dataset.change(leaderboard.update_leaderboard_data_in_feature_section,
                    [dataset, feature, gr.State('dataset'), leaderboard_table],
                    [emotion, leaderboard_table]
                )
                feature.change(leaderboard.update_leaderboard_data_by_feature,
                    [emotion, dataset, feature],
                    [leaderboard_table]
                )

        # ABOUT
        with gr.TabItem("📝 About", elem_id="About", id=4):
            gr.Markdown(open("pages/about.md", "r").read())

        # SUBMIT HERE
        with gr.TabItem("🚀 Submit here! ", elem_id="Submit", id=5):
            gr.Markdown(open("pages/submit.md", "r").read())

    with gr.Column():
        with gr.Accordion("📙 Citation", open=False):
            citation_button = gr.Textbox(
                label="",
                value=CITATION_TEXT,
                lines=5,
                elem_id="citation-button",
                show_copy_button=True,
            )


scheduler = BackgroundScheduler()
scheduler.add_job(restart_space, "interval", seconds=1800)
scheduler.start()
app.queue(default_concurrency_limit=40).launch()