Spaces:
Sleeping
Sleeping
ManjinderUNCC
commited on
Commit
•
26d0009
1
Parent(s):
60e1332
Update gradio_interface.py
Browse files- gradio_interface.py +7 -2
gradio_interface.py
CHANGED
@@ -29,17 +29,22 @@ def evaluate_text(input_text):
|
|
29 |
doc = nlp(input_text)
|
30 |
predicted_labels = doc.cats
|
31 |
|
32 |
-
# Construct output dictionary
|
33 |
output_dict = {
|
34 |
"PredictedLabels": {label: score for label, score in predicted_labels.items() if score > threshold}
|
35 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
return output_dict
|
37 |
|
38 |
# Gradio Interface
|
39 |
iface = gr.Interface(fn=evaluate_text, inputs="text", outputs="json", title="Text Evaluation-Manjinder", description="Enter your text")
|
40 |
iface.launch(share=True)
|
41 |
|
42 |
-
|
43 |
# import gradio as gr
|
44 |
# import spacy
|
45 |
# from sklearn.metrics import classification_report, accuracy_score, f1_score, precision_score, recall_score
|
|
|
29 |
doc = nlp(input_text)
|
30 |
predicted_labels = doc.cats
|
31 |
|
32 |
+
# Construct output dictionary with likelihood for each label
|
33 |
output_dict = {
|
34 |
"PredictedLabels": {label: score for label, score in predicted_labels.items() if score > threshold}
|
35 |
}
|
36 |
+
|
37 |
+
# Add likelihood for each ground truth label
|
38 |
+
for label in ground_truth_labels:
|
39 |
+
if label not in output_dict["PredictedLabels"]:
|
40 |
+
output_dict["PredictedLabels"][label] = 0 # Set likelihood to 0 if label not present
|
41 |
+
|
42 |
return output_dict
|
43 |
|
44 |
# Gradio Interface
|
45 |
iface = gr.Interface(fn=evaluate_text, inputs="text", outputs="json", title="Text Evaluation-Manjinder", description="Enter your text")
|
46 |
iface.launch(share=True)
|
47 |
|
|
|
48 |
# import gradio as gr
|
49 |
# import spacy
|
50 |
# from sklearn.metrics import classification_report, accuracy_score, f1_score, precision_score, recall_score
|