danieldux commited on
Commit
f78d989
1 Parent(s): 087d986

Add Gradio app for calculating hierarchical precision and recall

Browse files
Files changed (1) hide show
  1. gradioapp1.py +30 -0
gradioapp1.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: gradioapp1.py
2
+ import gradio as gr
3
+ from ham import calculate_hierarchical_precision_recall
4
+ from isco import create_hierarchy_dict
5
+
6
+ # from tests import test_cases
7
+
8
+ isco_csv_url = (
9
+ "https://www.ilo.org/ilostat-files/ISCO/newdocs-08-2021/ISCO-08/ISCO-08%20EN.csv"
10
+ )
11
+
12
+ hierachy = create_hierarchy_dict(isco_csv_url)
13
+
14
+ # Define the Gradio interface
15
+ iface = gr.Interface(
16
+ fn=calculate_hierarchical_precision_recall,
17
+ inputs=[
18
+ gr.Textbox(lines=2, placeholder="Enter true labels separated by commas"),
19
+ gr.Textbox(lines=2, placeholder="Enter predicted labels separated by commas"),
20
+ gr.Textbox(lines=5, placeholder="Enter hierarchy in JSON format"),
21
+ ],
22
+ outputs="textbox",
23
+ examples=[
24
+ # Add example inputs here if necessary
25
+ ],
26
+ description="This app calculates hierarchical precision and recall. Enter the true labels, predicted labels, and the hierarchy in JSON format.",
27
+ )
28
+
29
+ # Run the app
30
+ iface.launch()