Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
| import torch | |
| # ู ูุฏูู BRET | |
| model_name = "NvbilVmir1/Madar" | |
| # ุชุญู ูู ุงูู ูุฏูู ูุงูุชููููุฒุฑ | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForSequenceClassification.from_pretrained(model_name) | |
| id2label = model.config.id2label | |
| def predict_dialect(text): | |
| inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True) | |
| with torch.no_grad(): | |
| outputs = model(**inputs) | |
| pred = torch.argmax(outputs.logits, dim=-1).item() | |
| return id2label[pred] | |
| title = "AraELECTRA Arabic Dialect Classifier ๐" | |
| description = """ | |
| Detect the Arabic dialect from the input text. | |
| Dialects include: African, Khaleeji, Levant, and Egyptian. | |
| """ | |
| interface = gr.Interface( | |
| fn=predict_dialect, | |
| inputs=gr.Textbox(lines=3, placeholder="Type an Arabic sentence here..."), | |
| outputs="text", | |
| title=title, | |
| description=description, | |
| theme="default", | |
| allow_flagging="never", | |
| ) | |
| if __name__ == "__main__": | |
| interface.launch() | |