Spaces:
Sleeping
Sleeping
ManjinderUNCC
commited on
Commit
•
60e1332
1
Parent(s):
a987204
Update gradio_interface.py
Browse files- gradio_interface.py +11 -2
gradio_interface.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
import spacy
|
3 |
-
from sklearn.metrics import classification_report, accuracy_score, f1_score, precision_score, recall_score
|
4 |
|
5 |
# Load the trained spaCy model
|
6 |
model_path = "./my_trained_model"
|
@@ -9,6 +8,15 @@ nlp = spacy.load(model_path)
|
|
9 |
# Threshold for classification
|
10 |
threshold = 0.21
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# Function to classify text
|
13 |
def classify_text(text):
|
14 |
doc = nlp(text)
|
@@ -21,7 +29,7 @@ def evaluate_text(input_text):
|
|
21 |
doc = nlp(input_text)
|
22 |
predicted_labels = doc.cats
|
23 |
|
24 |
-
# Construct output dictionary
|
25 |
output_dict = {
|
26 |
"PredictedLabels": {label: score for label, score in predicted_labels.items() if score > threshold}
|
27 |
}
|
@@ -31,6 +39,7 @@ def evaluate_text(input_text):
|
|
31 |
iface = gr.Interface(fn=evaluate_text, inputs="text", outputs="json", title="Text Evaluation-Manjinder", description="Enter your text")
|
32 |
iface.launch(share=True)
|
33 |
|
|
|
34 |
# import gradio as gr
|
35 |
# import spacy
|
36 |
# from sklearn.metrics import classification_report, accuracy_score, f1_score, precision_score, recall_score
|
|
|
1 |
import gradio as gr
|
2 |
import spacy
|
|
|
3 |
|
4 |
# Load the trained spaCy model
|
5 |
model_path = "./my_trained_model"
|
|
|
8 |
# Threshold for classification
|
9 |
threshold = 0.21
|
10 |
|
11 |
+
# Ground truth labels
|
12 |
+
ground_truth_labels = {
|
13 |
+
"CapitalRequirements": 0,
|
14 |
+
"ConsumerProtection": 1,
|
15 |
+
"RiskManagement": 0,
|
16 |
+
"ReportingAndCompliance": 1,
|
17 |
+
"CorporateGovernance": 0
|
18 |
+
}
|
19 |
+
|
20 |
# Function to classify text
|
21 |
def classify_text(text):
|
22 |
doc = nlp(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 |
}
|
|
|
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
|