Spaces:
Sleeping
Sleeping
Add training data display to debug tab
Browse files
app.py
CHANGED
|
@@ -6,82 +6,87 @@ import gradio as gr
|
|
| 6 |
import sys
|
| 7 |
import traceback
|
| 8 |
|
|
|
|
| 9 |
def test_model_loading():
|
| 10 |
"""Test if model can be loaded"""
|
| 11 |
try:
|
| 12 |
print("🔄 Testing model loading...")
|
| 13 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 14 |
-
|
| 15 |
model_name = "humy65/hebrew-intent-classifier"
|
| 16 |
print(f"📡 Attempting to load: {model_name}")
|
| 17 |
-
|
| 18 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 19 |
print("✅ Tokenizer loaded")
|
| 20 |
-
|
| 21 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 22 |
print("✅ Model loaded")
|
| 23 |
-
|
| 24 |
print(f"📋 Labels: {model.config.id2label}")
|
| 25 |
return True, "Model loaded successfully!", model, tokenizer
|
| 26 |
-
|
| 27 |
except Exception as e:
|
| 28 |
error_msg = f"❌ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 29 |
print(error_msg)
|
| 30 |
return False, error_msg, None, None
|
| 31 |
|
|
|
|
| 32 |
def classify_text(text):
|
| 33 |
"""Classification function with lazy loading"""
|
| 34 |
if not text or not text.strip():
|
| 35 |
return "⚠️ Please enter Hebrew text", {}
|
| 36 |
-
|
| 37 |
try:
|
| 38 |
# Try to load model on demand
|
| 39 |
success, message, model, tokenizer = test_model_loading()
|
| 40 |
-
|
| 41 |
if not success:
|
| 42 |
return f"Model Loading Failed:\n{message}", {}
|
| 43 |
-
|
| 44 |
# Perform classification
|
| 45 |
import torch
|
| 46 |
-
|
| 47 |
-
inputs = tokenizer(text, return_tensors="pt",
|
| 48 |
-
|
|
|
|
| 49 |
with torch.no_grad():
|
| 50 |
outputs = model(**inputs)
|
| 51 |
logits = outputs.logits
|
| 52 |
probabilities = torch.softmax(logits, dim=-1)
|
| 53 |
-
|
| 54 |
# Get results
|
| 55 |
predicted_id = torch.argmax(logits, dim=-1).item()
|
| 56 |
predicted_label = model.config.id2label[predicted_id]
|
| 57 |
confidence = probabilities[0][predicted_id].item()
|
| 58 |
-
|
| 59 |
# Create confidence scores for all labels
|
| 60 |
all_scores = {}
|
| 61 |
for i, prob in enumerate(probabilities[0]):
|
| 62 |
intent_name = model.config.id2label[i]
|
| 63 |
all_scores[intent_name] = float(prob)
|
| 64 |
-
|
| 65 |
result = f"""
|
| 66 |
🎯 Predicted Intent: {predicted_label}
|
| 67 |
🎲 Confidence: {confidence:.1%}
|
| 68 |
|
| 69 |
📊 All Predictions:
|
| 70 |
"""
|
| 71 |
-
|
| 72 |
# Sort and display
|
| 73 |
-
sorted_scores = sorted(
|
|
|
|
| 74 |
for intent, score in sorted_scores:
|
| 75 |
bar = "█" * max(1, int(score * 20))
|
| 76 |
result += f"\n{intent}: {score:.1%} {bar}"
|
| 77 |
-
|
| 78 |
return result, all_scores
|
| 79 |
-
|
| 80 |
except Exception as e:
|
| 81 |
error_msg = f"Classification Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 82 |
print(error_msg)
|
| 83 |
return error_msg, {}
|
| 84 |
|
|
|
|
| 85 |
def test_connection():
|
| 86 |
"""Test Hugging Face connection"""
|
| 87 |
try:
|
|
@@ -92,11 +97,138 @@ def test_connection():
|
|
| 92 |
except Exception as e:
|
| 93 |
return f"❌ Repository access failed: {str(e)}"
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
# Create interface
|
| 96 |
with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
|
| 97 |
-
|
| 98 |
gr.Markdown("# 🇮🇱 Hebrew Intent Classification - Debug Version")
|
| 99 |
-
|
| 100 |
with gr.Tab("Classification"):
|
| 101 |
with gr.Row():
|
| 102 |
with gr.Column():
|
|
@@ -106,67 +238,82 @@ with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
|
|
| 106 |
lines=3
|
| 107 |
)
|
| 108 |
classify_btn = gr.Button("Classify", variant="primary")
|
| 109 |
-
|
| 110 |
# Quick examples
|
| 111 |
gr.Markdown("### Examples:")
|
| 112 |
examples = [
|
| 113 |
"ש��חתי את הסיסמה שלי",
|
| 114 |
-
"רוצה לבטל את המנוי",
|
| 115 |
"כמה עולה החבילה",
|
| 116 |
"האתר לא עובד"
|
| 117 |
]
|
| 118 |
-
|
| 119 |
for example in examples:
|
| 120 |
gr.Button(example, size="sm").click(
|
| 121 |
lambda x=example: x, outputs=text_input
|
| 122 |
)
|
| 123 |
-
|
| 124 |
with gr.Column():
|
| 125 |
result_output = gr.Textbox(
|
| 126 |
label="Result:",
|
| 127 |
lines=12,
|
| 128 |
interactive=False
|
| 129 |
)
|
| 130 |
-
|
| 131 |
confidence_output = gr.Label(
|
| 132 |
label="Confidence Scores",
|
| 133 |
num_top_classes=4
|
| 134 |
)
|
| 135 |
-
|
| 136 |
with gr.Tab("Debug"):
|
| 137 |
gr.Markdown("### Debug Information")
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
# Connect classification
|
| 164 |
classify_btn.click(
|
| 165 |
classify_text,
|
| 166 |
inputs=[text_input],
|
| 167 |
outputs=[result_output, confidence_output]
|
| 168 |
)
|
| 169 |
-
|
| 170 |
text_input.submit(
|
| 171 |
classify_text,
|
| 172 |
inputs=[text_input],
|
|
|
|
| 6 |
import sys
|
| 7 |
import traceback
|
| 8 |
|
| 9 |
+
|
| 10 |
def test_model_loading():
|
| 11 |
"""Test if model can be loaded"""
|
| 12 |
try:
|
| 13 |
print("🔄 Testing model loading...")
|
| 14 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 15 |
+
|
| 16 |
model_name = "humy65/hebrew-intent-classifier"
|
| 17 |
print(f"📡 Attempting to load: {model_name}")
|
| 18 |
+
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 20 |
print("✅ Tokenizer loaded")
|
| 21 |
+
|
| 22 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 23 |
print("✅ Model loaded")
|
| 24 |
+
|
| 25 |
print(f"📋 Labels: {model.config.id2label}")
|
| 26 |
return True, "Model loaded successfully!", model, tokenizer
|
| 27 |
+
|
| 28 |
except Exception as e:
|
| 29 |
error_msg = f"❌ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 30 |
print(error_msg)
|
| 31 |
return False, error_msg, None, None
|
| 32 |
|
| 33 |
+
|
| 34 |
def classify_text(text):
|
| 35 |
"""Classification function with lazy loading"""
|
| 36 |
if not text or not text.strip():
|
| 37 |
return "⚠️ Please enter Hebrew text", {}
|
| 38 |
+
|
| 39 |
try:
|
| 40 |
# Try to load model on demand
|
| 41 |
success, message, model, tokenizer = test_model_loading()
|
| 42 |
+
|
| 43 |
if not success:
|
| 44 |
return f"Model Loading Failed:\n{message}", {}
|
| 45 |
+
|
| 46 |
# Perform classification
|
| 47 |
import torch
|
| 48 |
+
|
| 49 |
+
inputs = tokenizer(text, return_tensors="pt",
|
| 50 |
+
padding=True, truncation=True, max_length=128)
|
| 51 |
+
|
| 52 |
with torch.no_grad():
|
| 53 |
outputs = model(**inputs)
|
| 54 |
logits = outputs.logits
|
| 55 |
probabilities = torch.softmax(logits, dim=-1)
|
| 56 |
+
|
| 57 |
# Get results
|
| 58 |
predicted_id = torch.argmax(logits, dim=-1).item()
|
| 59 |
predicted_label = model.config.id2label[predicted_id]
|
| 60 |
confidence = probabilities[0][predicted_id].item()
|
| 61 |
+
|
| 62 |
# Create confidence scores for all labels
|
| 63 |
all_scores = {}
|
| 64 |
for i, prob in enumerate(probabilities[0]):
|
| 65 |
intent_name = model.config.id2label[i]
|
| 66 |
all_scores[intent_name] = float(prob)
|
| 67 |
+
|
| 68 |
result = f"""
|
| 69 |
🎯 Predicted Intent: {predicted_label}
|
| 70 |
🎲 Confidence: {confidence:.1%}
|
| 71 |
|
| 72 |
📊 All Predictions:
|
| 73 |
"""
|
| 74 |
+
|
| 75 |
# Sort and display
|
| 76 |
+
sorted_scores = sorted(
|
| 77 |
+
all_scores.items(), key=lambda x: x[1], reverse=True)
|
| 78 |
for intent, score in sorted_scores:
|
| 79 |
bar = "█" * max(1, int(score * 20))
|
| 80 |
result += f"\n{intent}: {score:.1%} {bar}"
|
| 81 |
+
|
| 82 |
return result, all_scores
|
| 83 |
+
|
| 84 |
except Exception as e:
|
| 85 |
error_msg = f"Classification Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 86 |
print(error_msg)
|
| 87 |
return error_msg, {}
|
| 88 |
|
| 89 |
+
|
| 90 |
def test_connection():
|
| 91 |
"""Test Hugging Face connection"""
|
| 92 |
try:
|
|
|
|
| 97 |
except Exception as e:
|
| 98 |
return f"❌ Repository access failed: {str(e)}"
|
| 99 |
|
| 100 |
+
|
| 101 |
+
def get_training_data():
|
| 102 |
+
"""Display the training data used for the model"""
|
| 103 |
+
training_data = [
|
| 104 |
+
("שכחתי את הסיסמה שלי", "שכחת סיסמה"),
|
| 105 |
+
("איך אני מבטל את המנוי?", "ביטול מנוי"),
|
| 106 |
+
("מה המחיר של התוכנית?", "שאלה כללית"),
|
| 107 |
+
("האתר לא עובד לי", "תמיכה טכנית"),
|
| 108 |
+
("אני לא מצליח להתחבר", "תמיכה טכנית"),
|
| 109 |
+
("איך אני משנה את כתובת האימייל?", "שאלה כללית"),
|
| 110 |
+
("אני רוצה לשדרג את התוכנית שלי", "שאלה כללית"),
|
| 111 |
+
("החשבון שלי ננעל", "תמיכה טכנית"),
|
| 112 |
+
("אני לא מקבל מיילים", "תמיכה טכנית"),
|
| 113 |
+
("איך אני רואה את החשבונית שלי?", "שאלה כללית"),
|
| 114 |
+
("אני רוצה לבטל את השירות", "ביטול מנוי"),
|
| 115 |
+
("שכחתי את פרטי ההתחברות", "שכחת סיסמה"),
|
| 116 |
+
("איבדתי את הסיסמה", "שכחת סיסמה"),
|
| 117 |
+
("לא זוכר את הסיסמה", "שכחת סיסמה"),
|
| 118 |
+
("הסיסמה לא עובדת", "שכחת סיסמה"),
|
| 119 |
+
("לא מצליח להיכנס עם הסיסמה", "שכחת סיסמה"),
|
| 120 |
+
("צריך לאפס את הסיסמה", "שכחת סיסמה"),
|
| 121 |
+
("בעיה עם הסיסמה", "שכחת סיסמה"),
|
| 122 |
+
("הסיסמה שלי לא נכונה", "שכחת סיסמה"),
|
| 123 |
+
("שכחתי מה הסיסמה", "שכחת סיסמה"),
|
| 124 |
+
("איך אני משחזר את הסיסמה", "שכחת סיסמה"),
|
| 125 |
+
("רוצה לשנות את הסיסמה", "שכחת סיסמה"),
|
| 126 |
+
("הסיסמה לא מתקבלת", "שכחת סיסמה"),
|
| 127 |
+
("בעיית התחברות - סיסמה", "שכחת סיסמה"),
|
| 128 |
+
("צריך עזרה עם הסיסמה", "שכחת סיסמה"),
|
| 129 |
+
("לא יודע מה הסיסמה שלי", "שכחת סיסמה"),
|
| 130 |
+
("רוצה לבטל את השירות", "ביטול מנוי"),
|
| 131 |
+
("איך מפסיקים את המנוי", "ביטול מנוי"),
|
| 132 |
+
("רוצה להפסיק את התשלום", "ביטול מנוי"),
|
| 133 |
+
("איך יוצאים מהמנוי", "ביטול מנוי"),
|
| 134 |
+
("בקשה לביטול מנוי", "ביטול מנוי"),
|
| 135 |
+
("לא רוצה יותר את השירות", "ביטול מנוי"),
|
| 136 |
+
("איך מבטלים את החשבון", "ביטול מנוי"),
|
| 137 |
+
("רוצה לסגור את החשבון", "ביטול מנוי"),
|
| 138 |
+
("עזרה בביטול מנוי", "ביטול מנוי"),
|
| 139 |
+
("הליך ביטול המנוי", "ביטול מנוי"),
|
| 140 |
+
("מעוניין לבטל", "ביטול מנוי"),
|
| 141 |
+
("איך מפסיקים את השירות", "ביטול מנוי"),
|
| 142 |
+
("רוצה להפסיק את ההרשמה", "ביטול מנוי"),
|
| 143 |
+
("בקשה להפסקת שירות", "ביטול מנוי"),
|
| 144 |
+
("מה כולל השירות", "שאלה כללית"),
|
| 145 |
+
("אילו תוכניות יש לכם", "שאלה כללית"),
|
| 146 |
+
("כמה עולה החבילה", "שאלה כללית"),
|
| 147 |
+
("מה ההבדל בין התוכניות", "שאלה כללית"),
|
| 148 |
+
("איך אני משנה את הפרטים שלי", "שאלה כללית"),
|
| 149 |
+
("איך אפשר לשדרג", "שאלה כללית"),
|
| 150 |
+
("מה האפשרויות שלכם", "שאלה כללית"),
|
| 151 |
+
("אני רוצה לעדכן פרטים", "שאלה כללית"),
|
| 152 |
+
("איך רואים את ההיסטוריה", "שאלה כללית"),
|
| 153 |
+
("האפליקציה קורסת", "תמיכה טכנית"),
|
| 154 |
+
("יש באג באתר", "תמיכה טכנית"),
|
| 155 |
+
("הדף לא נטען", "תמיכה טכנית"),
|
| 156 |
+
("שגיאה במערכת", "תמיכה טכנית"),
|
| 157 |
+
("הטוען לא עובד", "תמיכה טכנית"),
|
| 158 |
+
("בעיה טכנית", "תמיכה טכנית"),
|
| 159 |
+
("המערכת לא מגיבה", "תמיכה טכנית"),
|
| 160 |
+
("שגיאת חיבור", "תמיכה טכנית"),
|
| 161 |
+
("הכפתור לא עובד", "תמיכה טכנית"),
|
| 162 |
+
("התמונות לא נטענות", "תמיכה טכנית"),
|
| 163 |
+
("הווידאו לא מתנגן", "תמיכה טכנית"),
|
| 164 |
+
("איטיות באתר", "תמיכה טכנית")
|
| 165 |
+
]
|
| 166 |
+
|
| 167 |
+
# Count examples per category
|
| 168 |
+
category_counts = {}
|
| 169 |
+
for _, label in training_data:
|
| 170 |
+
category_counts[label] = category_counts.get(label, 0) + 1
|
| 171 |
+
|
| 172 |
+
result = f"""
|
| 173 |
+
📊 **Training Data Summary**
|
| 174 |
+
Total Examples: {len(training_data)}
|
| 175 |
+
|
| 176 |
+
📈 **Examples per Category:**
|
| 177 |
+
"""
|
| 178 |
+
|
| 179 |
+
# Add category statistics
|
| 180 |
+
for category, count in sorted(category_counts.items()):
|
| 181 |
+
percentage = (count / len(training_data)) * 100
|
| 182 |
+
result += f"\n• {category}: {count} examples ({percentage:.1f}%)"
|
| 183 |
+
|
| 184 |
+
result += f"""
|
| 185 |
+
|
| 186 |
+
📝 **Sample Training Examples:**
|
| 187 |
+
|
| 188 |
+
🔐 **שכחת סיסמה (Password Reset):**
|
| 189 |
+
• שכחתי את הסיסמה שלי
|
| 190 |
+
• לא זוכר את הסיסמה
|
| 191 |
+
• הסיסמה לא עובדת
|
| 192 |
+
• צריך לאפס את הסיסמה
|
| 193 |
+
• איך אני משחזר את הסיסמה
|
| 194 |
+
|
| 195 |
+
❌ **ביטול מנוי (Cancel Subscription):**
|
| 196 |
+
• איך אני מבטל את המנוי?
|
| 197 |
+
• רוצה להפסיק את התשלום
|
| 198 |
+
• לא רוצה יותר את השירות
|
| 199 |
+
• איך מבטלים את החשבון
|
| 200 |
+
• בקשה לביטול מנוי
|
| 201 |
+
|
| 202 |
+
❓ **שאלה כללית (General Question):**
|
| 203 |
+
• מה המחיר של התוכנית?
|
| 204 |
+
• כמה עולה החבילה
|
| 205 |
+
• אילו תוכניות יש לכם
|
| 206 |
+
• איך אני משנה את הפרטים שלי
|
| 207 |
+
• מה כולל השירות
|
| 208 |
+
|
| 209 |
+
🔧 **תמיכה טכנית (Technical Support):**
|
| 210 |
+
• האתר לא עובד לי
|
| 211 |
+
• האפליקציה קורסת
|
| 212 |
+
• יש באג באתר
|
| 213 |
+
• הדף לא נטען
|
| 214 |
+
• שגיאה במערכת
|
| 215 |
+
|
| 216 |
+
---
|
| 217 |
+
💡 **Model was trained with data augmentation techniques:**
|
| 218 |
+
• Synonym replacement
|
| 219 |
+
• Paraphrasing
|
| 220 |
+
• Context variation
|
| 221 |
+
• Original 12 examples → Enhanced to {len(training_data)} examples
|
| 222 |
+
"""
|
| 223 |
+
|
| 224 |
+
return result
|
| 225 |
+
|
| 226 |
+
|
| 227 |
# Create interface
|
| 228 |
with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo:
|
| 229 |
+
|
| 230 |
gr.Markdown("# 🇮🇱 Hebrew Intent Classification - Debug Version")
|
| 231 |
+
|
| 232 |
with gr.Tab("Classification"):
|
| 233 |
with gr.Row():
|
| 234 |
with gr.Column():
|
|
|
|
| 238 |
lines=3
|
| 239 |
)
|
| 240 |
classify_btn = gr.Button("Classify", variant="primary")
|
| 241 |
+
|
| 242 |
# Quick examples
|
| 243 |
gr.Markdown("### Examples:")
|
| 244 |
examples = [
|
| 245 |
"ש��חתי את הסיסמה שלי",
|
| 246 |
+
"רוצה לבטל את המנוי",
|
| 247 |
"כמה עולה החבילה",
|
| 248 |
"האתר לא עובד"
|
| 249 |
]
|
| 250 |
+
|
| 251 |
for example in examples:
|
| 252 |
gr.Button(example, size="sm").click(
|
| 253 |
lambda x=example: x, outputs=text_input
|
| 254 |
)
|
| 255 |
+
|
| 256 |
with gr.Column():
|
| 257 |
result_output = gr.Textbox(
|
| 258 |
label="Result:",
|
| 259 |
lines=12,
|
| 260 |
interactive=False
|
| 261 |
)
|
| 262 |
+
|
| 263 |
confidence_output = gr.Label(
|
| 264 |
label="Confidence Scores",
|
| 265 |
num_top_classes=4
|
| 266 |
)
|
| 267 |
+
|
| 268 |
with gr.Tab("Debug"):
|
| 269 |
gr.Markdown("### Debug Information")
|
| 270 |
+
|
| 271 |
+
with gr.Row():
|
| 272 |
+
with gr.Column():
|
| 273 |
+
test_btn = gr.Button("Test Model Loading")
|
| 274 |
+
debug_output = gr.Textbox(
|
| 275 |
+
label="Debug Output:",
|
| 276 |
+
lines=15,
|
| 277 |
+
interactive=False
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
test_btn.click(
|
| 281 |
+
lambda: test_model_loading()[1],
|
| 282 |
+
outputs=debug_output
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
conn_btn = gr.Button("Test Repository Connection")
|
| 286 |
+
conn_output = gr.Textbox(
|
| 287 |
+
label="Connection Test:",
|
| 288 |
+
lines=5,
|
| 289 |
+
interactive=False
|
| 290 |
+
)
|
| 291 |
+
|
| 292 |
+
conn_btn.click(
|
| 293 |
+
test_connection,
|
| 294 |
+
outputs=conn_output
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
with gr.Column():
|
| 298 |
+
data_btn = gr.Button("Show Training Data")
|
| 299 |
+
training_output = gr.Textbox(
|
| 300 |
+
label="Training Data:",
|
| 301 |
+
lines=20,
|
| 302 |
+
interactive=False
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
data_btn.click(
|
| 306 |
+
get_training_data,
|
| 307 |
+
outputs=training_output
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
# Connect classification
|
| 311 |
classify_btn.click(
|
| 312 |
classify_text,
|
| 313 |
inputs=[text_input],
|
| 314 |
outputs=[result_output, confidence_output]
|
| 315 |
)
|
| 316 |
+
|
| 317 |
text_input.submit(
|
| 318 |
classify_text,
|
| 319 |
inputs=[text_input],
|