Spaces:
Runtime error
Runtime error
File size: 1,018 Bytes
713bacd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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()
|