File size: 1,486 Bytes
6f5b41f
308f73c
 
 
6f5b41f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308f73c
 
6f5b41f
 
 
 
 
 
 
 
 
 
 
 
 
308f73c
6f5b41f
 
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

import gradio as gr
import pandas as pd

# Load the uc_result.csv file
uc_result_df = pd.read_csv('uc_result.csv')

# Convert percentage columns to float for sorting
percentage_columns = [col for col in uc_result_df.columns if uc_result_df[col].dtype == 'object' and '%' in uc_result_df[col].iloc[0]]
for col in percentage_columns:
    uc_result_df[col] = uc_result_df[col].str.rstrip('%').astype('float') / 100

# Define a function to filter and sort the dataframe
def filter_and_sort(method=None, sort_by=None, ascending=True):
    filtered_df = uc_result_df
    if method:
        filtered_df = filtered_df[filtered_df['Method'].str.contains(method)]
    if sort_by:
        filtered_df = filtered_df.sort_values(by=sort_by, ascending=ascending)
    return filtered_df

# Create Gradio interface components
method_input = gr.inputs.Textbox(label="Filter by Method", placeholder="Enter method name...")
sort_by_dropdown = gr.inputs.Dropdown(label="Sort by", choices=uc_result_df.columns.tolist(), default=None)
ascending_checkbox = gr.inputs.Checkbox(label="Ascending Order", value=True)

# Create a Gradio interface to display the data
iface = gr.Interface(
    fn=filter_and_sort,
    inputs=[method_input, sort_by_dropdown, ascending_checkbox],
    outputs=gr.outputs.DataFrame(type="pandas"),
    title="Enhanced UC Results Display",
    description="This interface allows filtering and sorting of the results from uc_result.csv"
)

if __name__ == "__main__":
    iface.launch()