Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification | |
| import torch | |
| MODEL_NAME = "kaixkhazaki/turkish-sentiment" | |
| device = 0 if torch.cuda.is_available() else -1 | |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) | |
| model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME) | |
| sentiment = pipeline("text-classification", model=model, tokenizer=tokenizer, return_all_scores=True, device=device) | |
| demo = gr.Interface( | |
| fn=analyze, | |
| inputs=gr.Textbox(lines=3, placeholder="Bir metin yazın..."), | |
| outputs=gr.Label(num_top_classes=3), | |
| title="🇹🇷 Türkçe Duygu Analizi", | |
| description=( | |
| "Pozitif, Negatif ve Nötr duyguları tahmin eder.\n" | |
| "Model: [kaixkhazaki/turkish-sentiment](https://huggingface.co/kaixkhazaki/turkish-sentiment)" | |
| ), | |
| examples=[ | |
| ["Bugün gerçekten harika bir gün!"], | |
| ["Bu film çok sıkıcıydı."], | |
| ["Ne iyi ne kötü, ortalama bir deneyimdi."] | |
| ], | |
| ) | |
| demo.launch() | |