File size: 965 Bytes
f78d989
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# filename: gradioapp1.py
import gradio as gr
from ham import calculate_hierarchical_precision_recall
from isco import create_hierarchy_dict

# from tests import test_cases

isco_csv_url = (
    "https://www.ilo.org/ilostat-files/ISCO/newdocs-08-2021/ISCO-08/ISCO-08%20EN.csv"
)

hierachy = create_hierarchy_dict(isco_csv_url)

# Define the Gradio interface
iface = gr.Interface(
    fn=calculate_hierarchical_precision_recall,
    inputs=[
        gr.Textbox(lines=2, placeholder="Enter true labels separated by commas"),
        gr.Textbox(lines=2, placeholder="Enter predicted labels separated by commas"),
        gr.Textbox(lines=5, placeholder="Enter hierarchy in JSON format"),
    ],
    outputs="textbox",
    examples=[
        # Add example inputs here if necessary
    ],
    description="This app calculates hierarchical precision and recall. Enter the true labels, predicted labels, and the hierarchy in JSON format.",
)

# Run the app
iface.launch()