NLPV commited on
Commit
7ec7391
·
verified ·
1 Parent(s): 73e4fda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -86,20 +86,32 @@ def launch(text_input):
86
  decoded_labels = label_encoder.inverse_transform(predicted_classes)
87
 
88
  map_data = pd.read_excel("ISCO-08 EN Structure and definitions.xlsx")
89
- isco_description = map_data[map_data['ISCO 08 Code']==decoded_labels]['Title EN']
90
-
91
- print("Most likely ISCO code is {} and probability is {}".format(decoded_labels,highest_probabilities))
92
-
 
 
93
  # Create descriptive text for the output
94
- #result_text = "Most likely ISCO code is {} and probability is {:.2f}".format(decoded_labels[0], highest_probabilities[0])
95
- result_text = f"Predicted ISCO Code: {decoded_labels[0]}\nProbability: {highest_probabilities[0]:.2f}\nISCO Description:{isco_description}"
96
- return result_text #[decoded_labels[0], highest_probabilities[0]]
97
-
 
 
 
98
 
 
99
  iface = gr.Interface(
100
  fn=launch,
101
- inputs=gr.Textbox(lines=2, placeholder="Enter job title in any language (e.g., Software Engineer) and description here (e.g., Develops and maintains software applications)..."),
102
- outputs=gr.Textbox(lines=2, placeholder="Predicted ISCO Code: <result> Probability: <result> ISCO Description: <result>")
 
 
 
 
 
 
103
  )
104
 
105
  iface.launch()
 
86
  decoded_labels = label_encoder.inverse_transform(predicted_classes)
87
 
88
  map_data = pd.read_excel("ISCO-08 EN Structure and definitions.xlsx")
89
+ # Retrieve the ISCO description based on the decoded label
90
+ isco_description = map_data[map_data['ISCO 08 Code'] == decoded_labels[0]]['Title EN'].values
91
+
92
+ # Print for debugging (optional)
93
+ print(f"Most likely ISCO code is {decoded_labels[0]} and probability is {highest_probabilities[0]}")
94
+
95
  # Create descriptive text for the output
96
+ result_text = (
97
+ f"Predicted ISCO Code: {decoded_labels[0]}\n"
98
+ f"Probability: {highest_probabilities[0]:.2f}\n"
99
+ f"ISCO Description: {isco_description[0] if len(isco_description) > 0 else 'Description not found'}"
100
+ )
101
+
102
+ return result_text
103
 
104
+ # Define the Gradio interface
105
  iface = gr.Interface(
106
  fn=launch,
107
+ inputs=gr.Textbox(
108
+ lines=2,
109
+ placeholder="Enter job title in any language (e.g., Software Engineer) and description here (e.g., Develops and maintains software applications)..."
110
+ ),
111
+ outputs=gr.Textbox(
112
+ lines=4,
113
+ placeholder="Predicted ISCO Code: <result>\nProbability: <result>\nISCO Description: <result>"
114
+ )
115
  )
116
 
117
  iface.launch()