Spaces:
Sleeping
Sleeping
| """ | |
| Hebrew Intent Classification Demo - Debug Version | |
| """ | |
| import gradio as gr | |
| import sys | |
| import traceback | |
| def test_model_loading(): | |
| """Test if model can be loaded""" | |
| try: | |
| print("๐ Testing model loading...") | |
| from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
| model_name = "humy65/hebrew-intent-classifier" | |
| print(f"๐ก Attempting to load: {model_name}") | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| print("โ Tokenizer loaded") | |
| model = AutoModelForSequenceClassification.from_pretrained(model_name) | |
| print("โ Model loaded") | |
| print(f"๐ Labels: {model.config.id2label}") | |
| return True, "Model loaded successfully!", model, tokenizer | |
| except Exception as e: | |
| error_msg = f"โ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}" | |
| print(error_msg) | |
| return False, error_msg, None, None | |
| def classify_text(text): | |
| """Classification function with lazy loading""" | |
| if not text or not text.strip(): | |
| return "โ ๏ธ Please enter Hebrew text", {} | |
| try: | |
| # Try to load model on demand | |
| success, message, model, tokenizer = test_model_loading() | |
| if not success: | |
| return f"Model Loading Failed:\n{message}", {} | |
| # Perform classification | |
| import torch | |
| inputs = tokenizer(text, return_tensors="pt", | |
| padding=True, truncation=True, max_length=128) | |
| with torch.no_grad(): | |
| outputs = model(**inputs) | |
| logits = outputs.logits | |
| probabilities = torch.softmax(logits, dim=-1) | |
| # Get results | |
| predicted_id = torch.argmax(logits, dim=-1).item() | |
| predicted_label = model.config.id2label[predicted_id] | |
| confidence = probabilities[0][predicted_id].item() | |
| # Create confidence scores for all labels | |
| all_scores = {} | |
| for i, prob in enumerate(probabilities[0]): | |
| intent_name = model.config.id2label[i] | |
| all_scores[intent_name] = float(prob) | |
| result = f""" | |
| ๐ฏ Predicted Intent: {predicted_label} | |
| ๐ฒ Confidence: {confidence:.1%} | |
| ๐ All Predictions: | |
| """ | |
| # Sort and display | |
| sorted_scores = sorted( | |
| all_scores.items(), key=lambda x: x[1], reverse=True) | |
| for intent, score in sorted_scores: | |
| bar = "โ" * max(1, int(score * 20)) | |
| result += f"\n{intent}: {score:.1%} {bar}" | |
| return result, all_scores | |
| except Exception as e: | |
| error_msg = f"Classification Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}" | |
| print(error_msg) | |
| return error_msg, {} | |
| def test_connection(): | |
| """Test Hugging Face connection""" | |
| try: | |
| from huggingface_hub import HfApi | |
| api = HfApi() | |
| info = api.model_info("humy65/hebrew-intent-classifier") | |
| return f"โ Model repository accessible\nModel ID: {info.modelId}\nLast Modified: {info.lastModified}" | |
| except Exception as e: | |
| return f"โ Repository access failed: {str(e)}" | |
| def get_training_data(): | |
| """Display the training data used for the model""" | |
| training_data = [ | |
| ("ืฉืืืชื ืืช ืืกืืกืื ืฉืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืื ืื ื ืืืื ืืช ืืื ืื?", "ืืืืื ืื ืื"), | |
| ("ืื ืืืืืจ ืฉื ืืชืืื ืืช?", "ืฉืืื ืืืืืช"), | |
| ("ืืืชืจ ืื ืขืืื ืื", "ืชืืืื ืืื ืืช"), | |
| ("ืื ื ืื ืืฆืืื ืืืชืืืจ", "ืชืืืื ืืื ืืช"), | |
| ("ืืื ืื ื ืืฉื ื ืืช ืืชืืืช ืืืืืืื?", "ืฉืืื ืืืืืช"), | |
| ("ืื ื ืจืืฆื ืืฉืืจื ืืช ืืชืืื ืืช ืฉืื", "ืฉืืื ืืืืืช"), | |
| ("ืืืฉืืื ืฉืื ื ื ืขื", "ืชืืืื ืืื ืืช"), | |
| ("ืื ื ืื ืืงืื ืืืืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืื ืื ื ืจืืื ืืช ืืืฉืืื ืืช ืฉืื?", "ืฉืืื ืืืืืช"), | |
| ("ืื ื ืจืืฆื ืืืื ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืฉืืืชื ืืช ืคืจืื ืืืชืืืจืืช", "ืฉืืืช ืกืืกืื"), | |
| ("ืืืืืชื ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืื ืืืืจ ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืกืืกืื ืื ืขืืืืช", "ืฉืืืช ืกืืกืื"), | |
| ("ืื ืืฆืืื ืืืืื ืก ืขื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืฆืจืื ืืืคืก ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืขืื ืขื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืกืืกืื ืฉืื ืื ื ืืื ื", "ืฉืืืช ืกืืกืื"), | |
| ("ืฉืืืชื ืื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืื ืื ื ืืฉืืืจ ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืจืืฆื ืืฉื ืืช ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืกืืกืื ืื ืืชืงืืืช", "ืฉืืืช ืกืืกืื"), | |
| ("ืืขืืืช ืืชืืืจืืช - ืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืฆืจืื ืขืืจื ืขื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืื ืืืืข ืื ืืกืืกืื ืฉืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืจืืฆื ืืืื ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืืื ืืคืกืืงืื ืืช ืืื ืื", "ืืืืื ืื ืื"), | |
| ("ืจืืฆื ืืืคืกืืง ืืช ืืชืฉืืื", "ืืืืื ืื ืื"), | |
| ("ืืื ืืืฆืืื ืืืื ืื", "ืืืืื ืื ืื"), | |
| ("ืืงืฉื ืืืืืื ืื ืื", "ืืืืื ืื ืื"), | |
| ("ืื ืจืืฆื ืืืชืจ ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืืื ืืืืืื ืืช ืืืฉืืื", "ืืืืื ืื ืื"), | |
| ("ืจืืฆื ืืกืืืจ ืืช ืืืฉืืื", "ืืืืื ืื ืื"), | |
| ("ืขืืจื ืืืืืื ืื ืื", "ืืืืื ืื ืื"), | |
| ("ืืืื ืืืืื ืืื ืื", "ืืืืื ืื ืื"), | |
| ("ืืขืื ืืื ืืืื", "ืืืืื ืื ืื"), | |
| ("ืืื ืืคืกืืงืื ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืจืืฆื ืืืคืกืืง ืืช ืืืจืฉืื", "ืืืืื ืื ืื"), | |
| ("ืืงืฉื ืืืคืกืงืช ืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืื ืืืื ืืฉืืจืืช", "ืฉืืื ืืืืืช"), | |
| ("ืืืื ืชืืื ืืืช ืืฉ ืืื", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืขืืื ืืืืืื", "ืฉืืื ืืืืืช"), | |
| ("ืื ืืืืื ืืื ืืชืืื ืืืช", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืื ื ืืฉื ื ืืช ืืคืจืืื ืฉืื", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืืคืฉืจ ืืฉืืจื", "ืฉืืื ืืืืืช"), | |
| ("ืื ืืืคืฉืจืืืืช ืฉืืื", "ืฉืืื ืืืืืช"), | |
| ("ืื ื ืจืืฆื ืืขืืื ืคืจืืื", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืจืืืื ืืช ืืืืกืืืจืื", "ืฉืืื ืืืืืช"), | |
| ("ืืืคืืืงืฆืื ืงืืจืกืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืฉ ืืื ืืืชืจ", "ืชืืืื ืืื ืืช"), | |
| ("ืืืฃ ืื ื ืืขื", "ืชืืืื ืืื ืืช"), | |
| ("ืฉืืืื ืืืขืจืืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืืืขื ืื ืขืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืขืื ืืื ืืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืืขืจืืช ืื ืืืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืฉืืืืช ืืืืืจ", "ืชืืืื ืืื ืืช"), | |
| ("ืืืคืชืืจ ืื ืขืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืชืืื ืืช ืื ื ืืขื ืืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืืืืืื ืื ืืชื ืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืืืืืช ืืืชืจ", "ืชืืืื ืืื ืืช") | |
| ] | |
| # Count examples per category | |
| category_counts = {} | |
| for _, label in training_data: | |
| category_counts[label] = category_counts.get(label, 0) + 1 | |
| result = f""" | |
| ๐ **Training Data Summary** | |
| Total Examples: {len(training_data)} | |
| ๐ **Examples per Category:** | |
| """ | |
| # Add category statistics | |
| for category, count in sorted(category_counts.items()): | |
| percentage = (count / len(training_data)) * 100 | |
| result += f"\nโข {category}: {count} examples ({percentage:.1f}%)" | |
| result += f""" | |
| ๐ **Sample Training Examples:** | |
| ๐ **ืฉืืืช ืกืืกืื (Password Reset):** | |
| โข ืฉืืืชื ืืช ืืกืืกืื ืฉืื | |
| โข ืื ืืืืจ ืืช ืืกืืกืื | |
| โข ืืกืืกืื ืื ืขืืืืช | |
| โข ืฆืจืื ืืืคืก ืืช ืืกืืกืื | |
| โข ืืื ืื ื ืืฉืืืจ ืืช ืืกืืกืื | |
| โ **ืืืืื ืื ืื (Cancel Subscription):** | |
| โข ืืื ืื ื ืืืื ืืช ืืื ืื? | |
| โข ืจืืฆื ืืืคืกืืง ืืช ืืชืฉืืื | |
| โข ืื ืจืืฆื ืืืชืจ ืืช ืืฉืืจืืช | |
| โข ืืื ืืืืืื ืืช ืืืฉืืื | |
| โข ืืงืฉื ืืืืืื ืื ืื | |
| โ **ืฉืืื ืืืืืช (General Question):** | |
| โข ืื ืืืืืจ ืฉื ืืชืืื ืืช? | |
| โข ืืื ืขืืื ืืืืืื | |
| โข ืืืื ืชืืื ืืืช ืืฉ ืืื | |
| โข ืืื ืื ื ืืฉื ื ืืช ืืคืจืืื ืฉืื | |
| โข ืื ืืืื ืืฉืืจืืช | |
| ๐ง **ืชืืืื ืืื ืืช (Technical Support):** | |
| โข ืืืชืจ ืื ืขืืื ืื | |
| โข ืืืคืืืงืฆืื ืงืืจืกืช | |
| โข ืืฉ ืืื ืืืชืจ | |
| โข ืืืฃ ืื ื ืืขื | |
| โข ืฉืืืื ืืืขืจืืช | |
| --- | |
| ๐ก **Model was trained with data augmentation techniques:** | |
| โข Synonym replacement | |
| โข Paraphrasing | |
| โข Context variation | |
| โข Original 12 examples โ Enhanced to {len(training_data)} examples | |
| """ | |
| return result | |
| def get_training_data(): | |
| """Display the training data used for the model""" | |
| training_data = [ | |
| ("ืฉืืืชื ืืช ืืกืืกืื ืฉืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืื ืื ื ืืืื ืืช ืืื ืื?", "ืืืืื ืื ืื"), | |
| ("ืื ืืืืืจ ืฉื ืืชืืื ืืช?", "ืฉืืื ืืืืืช"), | |
| ("ืืืชืจ ืื ืขืืื ืื", "ืชืืืื ืืื ืืช"), | |
| ("ืื ื ืื ืืฆืืื ืืืชืืืจ", "ืชืืืื ืืื ืืช"), | |
| ("ืืื ืื ื ืืฉื ื ืืช ืืชืืืช ืืืืืืื?", "ืฉืืื ืืืืืช"), | |
| ("ืื ื ืจืืฆื ืืฉืืจื ืืช ืืชืืื ืืช ืฉืื", "ืฉืืื ืืืืืช"), | |
| ("ืืืฉืืื ืฉืื ื ื ืขื", "ืชืืืื ืืื ืืช"), | |
| ("ืื ื ืื ืืงืื ืืืืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืื ืื ื ืจืืื ืืช ืืืฉืืื ืืช ืฉืื?", "ืฉืืื ืืืืืช"), | |
| ("ืื ื ืจืืฆื ืืืื ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืฉืืืชื ืืช ืคืจืื ืืืชืืืจืืช", "ืฉืืืช ืกืืกืื"), | |
| ("ืืืืืชื ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืื ืืืืจ ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืกืืกืื ืื ืขืืืืช", "ืฉืืืช ืกืืกืื"), | |
| ("ืื ืืฆืืื ืืืืื ืก ืขื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืฆืจืื ืืืคืก ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืขืื ืขื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืกืืกืื ืฉืื ืื ื ืืื ื", "ืฉืืืช ืกืืกืื"), | |
| ("ืฉืืืชื ืื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืื ืื ื ืืฉืืืจ ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืจืืฆื ืืฉื ืืช ืืช ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืืกืืกืื ืื ืืชืงืืืช", "ืฉืืืช ืกืืกืื"), | |
| ("ืืขืืืช ืืชืืืจืืช - ืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืฆืจืื ืขืืจื ืขื ืืกืืกืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืื ืืืืข ืื ืืกืืกืื ืฉืื", "ืฉืืืช ืกืืกืื"), | |
| ("ืจืืฆื ืืืื ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืืื ืืคืกืืงืื ืืช ืืื ืื", "ืืืืื ืื ืื"), | |
| ("ืจืืฆื ืืืคืกืืง ืืช ืืชืฉืืื", "ืืืืื ืื ืื"), | |
| ("ืืื ืืืฆืืื ืืืื ืื", "ืืืืื ืื ืื"), | |
| ("ืืงืฉื ืืืืืื ืื ืื", "ืืืืื ืื ืื"), | |
| ("ืื ืจืืฆื ืืืชืจ ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืืื ืืืืืื ืืช ืืืฉืืื", "ืืืืื ืื ืื"), | |
| ("ืจืืฆื ืืกืืืจ ืืช ืืืฉืืื", "ืืืืื ืื ืื"), | |
| ("ืขืืจื ืืืืืื ืื ืื", "ืืืืื ืื ืื"), | |
| ("ืืืื ืืืืื ืืื ืื", "ืืืืื ืื ืื"), | |
| ("ืืขืื ืืื ืืืื", "ืืืืื ืื ืื"), | |
| ("ืืื ืืคืกืืงืื ืืช ืืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืจืืฆื ืืืคืกืืง ืืช ืืืจืฉืื", "ืืืืื ืื ืื"), | |
| ("ืืงืฉื ืืืคืกืงืช ืฉืืจืืช", "ืืืืื ืื ืื"), | |
| ("ืื ืืืื ืืฉืืจืืช", "ืฉืืื ืืืืืช"), | |
| ("ืืืื ืชืืื ืืืช ืืฉ ืืื", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืขืืื ืืืืืื", "ืฉืืื ืืืืืช"), | |
| ("ืื ืืืืื ืืื ืืชืืื ืืืช", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืื ื ืืฉื ื ืืช ืืคืจืืื ืฉืื", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืืคืฉืจ ืืฉืืจื", "ืฉืืื ืืืืืช"), | |
| ("ืื ืืืคืฉืจืืืืช ืฉืืื", "ืฉืืื ืืืืืช"), | |
| ("ืื ื ืจืืฆื ืืขืืื ืคืจืืื", "ืฉืืื ืืืืืช"), | |
| ("ืืื ืจืืืื ืืช ืืืืกืืืจืื", "ืฉืืื ืืืืืช"), | |
| ("ืืืคืืืงืฆืื ืงืืจืกืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืฉ ืืื ืืืชืจ", "ืชืืืื ืืื ืืช"), | |
| ("ืืืฃ ืื ื ืืขื", "ืชืืืื ืืื ืืช"), | |
| ("ืฉืืืื ืืืขืจืืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืืืขื ืื ืขืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืขืื ืืื ืืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืืขืจืืช ืื ืืืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืฉืืืืช ืืืืืจ", "ืชืืืื ืืื ืืช"), | |
| ("ืืืคืชืืจ ืื ืขืืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืชืืื ืืช ืื ื ืืขื ืืช", "ืชืืืื ืืื ืืช"), | |
| ("ืืืืืืื ืื ืืชื ืื", "ืชืืืื ืืื ืืช"), | |
| ("ืืืืืืช ืืืชืจ", "ืชืืืื ืืื ืืช") | |
| ] | |
| # Count examples per category | |
| category_counts = {} | |
| for _, label in training_data: | |
| category_counts[label] = category_counts.get(label, 0) + 1 | |
| result = f""" | |
| ๐ **Training Data Summary** | |
| Total Examples: {len(training_data)} | |
| ๐ **Examples per Category:** | |
| """ | |
| # Add category statistics | |
| for category, count in sorted(category_counts.items()): | |
| percentage = (count / len(training_data)) * 100 | |
| result += f"\nโข {category}: {count} examples ({percentage:.1f}%)" | |
| result += f""" | |
| ๐ **Sample Training Examples:** | |
| ๐ **ืฉืืืช ืกืืกืื (Password Reset):** | |
| โข ืฉืืืชื ืืช ืืกืืกืื ืฉืื | |
| โข ืื ืืืืจ ืืช ืืกืืกืื | |
| โข ืืกืืกืื ืื ืขืืืืช | |
| โข ืฆืจืื ืืืคืก ืืช ืืกืืกืื | |
| โข ืืื ืื ื ืืฉืืืจ ืืช ืืกืืกืื | |
| โ **ืืืืื ืื ืื (Cancel Subscription):** | |
| โข ืืื ืื ื ืืืื ืืช ืืื ืื? | |
| โข ืจืืฆื ืืืคืกืืง ืืช ืืชืฉืืื | |
| โข ืื ืจืืฆื ืืืชืจ ืืช ืืฉืืจืืช | |
| โข ืืื ืืืืืื ืืช ืืืฉืืื | |
| โข ืืงืฉื ืืืืืื ืื ืื | |
| โ **ืฉืืื ืืืืืช (General Question):** | |
| โข ืื ืืืืืจ ืฉื ืืชืืื ืืช? | |
| โข ืืื ืขืืื ืืืืืื | |
| โข ืืืื ืชืืื ืืืช ืืฉ ืืื | |
| โข ืืื ืื ื ืืฉื ื ืืช ืืคืจืืื ืฉืื | |
| โข ืื ืืืื ืืฉืืจืืช | |
| ๐ง **ืชืืืื ืืื ืืช (Technical Support):** | |
| โข ืืืชืจ ืื ืขืืื ืื | |
| โข ืืืคืืืงืฆืื ืงืืจืกืช | |
| โข ืืฉ ืืื ืืืชืจ | |
| โข ืืืฃ ืื ื ืืขื | |
| โข ืฉืืืื ืืืขืจืืช | |
| --- | |
| ๐ก **Model was trained with data augmentation techniques:** | |
| โข Synonym replacement | |
| โข Paraphrasing | |
| โข Context variation | |
| โข Original 12 examples โ Enhanced to {len(training_data)} examples | |
| """ | |
| return result | |
| # Create interface | |
| with gr.Blocks(title="Hebrew Intent Classification - Debug") as demo: | |
| gr.Markdown("# ๐ฎ๐ฑ Hebrew Intent Classification - Debug Version 2.1 ๐") | |
| gr.Markdown("### ๐ข Version 2.1 - Training Data Display Added (Aug 12, 2025) โ ") | |
| with gr.Tab("Classification"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| text_input = gr.Textbox( | |
| label="Hebrew Text:", | |
| placeholder="ืฉืืืชื ืืช ืืกืืกืื ืฉืื", | |
| lines=3 | |
| ) | |
| classify_btn = gr.Button("Classify", variant="primary") | |
| # Quick examples | |
| gr.Markdown("### Examples:") | |
| examples = [ | |
| "ืฉืืืชื ืืช ืืกืืกืื ืฉืื", | |
| "ืจืืฆื ืืืื ืืช ืืื ืื", | |
| "ืืื ืขืืื ืืืืืื", | |
| "ืืืชืจ ืื ืขืืื" | |
| ] | |
| for example in examples: | |
| gr.Button(example, size="sm").click( | |
| lambda x=example: x, outputs=text_input | |
| ) | |
| with gr.Column(): | |
| result_output = gr.Textbox( | |
| label="Result:", | |
| lines=12, | |
| interactive=False | |
| ) | |
| confidence_output = gr.Label( | |
| label="Confidence Scores", | |
| num_top_classes=4 | |
| ) | |
| with gr.Tab("Debug"): | |
| gr.Markdown("### Debug Information") | |
| with gr.Row(): | |
| with gr.Column(): | |
| test_btn = gr.Button("Test Model Loading") | |
| debug_output = gr.Textbox( | |
| label="Debug Output:", | |
| lines=15, | |
| interactive=False | |
| ) | |
| test_btn.click( | |
| lambda: test_model_loading()[1], | |
| outputs=debug_output | |
| ) | |
| conn_btn = gr.Button("Test Repository Connection") | |
| conn_output = gr.Textbox( | |
| label="Connection Test:", | |
| lines=5, | |
| interactive=False | |
| ) | |
| conn_btn.click( | |
| test_connection, | |
| outputs=conn_output | |
| ) | |
| with gr.Column(): | |
| data_btn = gr.Button("Show Training Data") | |
| training_output = gr.Textbox( | |
| label="Training Data:", | |
| lines=20, | |
| interactive=False | |
| ) | |
| data_btn.click( | |
| get_training_data, | |
| outputs=training_output | |
| ) | |
| # Connect classification | |
| classify_btn.click( | |
| classify_text, | |
| inputs=[text_input], | |
| outputs=[result_output, confidence_output] | |
| ) | |
| text_input.submit( | |
| classify_text, | |
| inputs=[text_input], | |
| outputs=[result_output, confidence_output] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch( | |
| share=True, | |
| server_name="0.0.0.0", | |
| server_port=7860 | |
| ) | |
| # Connect classification | |
| classify_btn.click( | |
| classify_text, | |
| inputs=[text_input], | |
| outputs=[result_output, confidence_output] | |
| ) | |
| text_input.submit( | |
| classify_text, | |
| inputs=[text_input], | |
| outputs=[result_output, confidence_output] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch( | |
| share=True, | |
| server_name="0.0.0.0", | |
| server_port=7860 | |
| ) | |