import gradio as gr from transformers import pipeline model = pipeline("sentiment-analysis", model="kelompokjavonlp/sentiment_analysis") def predict_sentiment(text): if not text.strip(): return "Komentar kosong." result = model(text)[0] label = result['label'] score = result['score'] label_map = { "1 star": "Sangat Negatif 😡", "2 stars": "Negatif 😠", "3 stars": "Netral 😐", "4 stars": "Positif 🙂", "5 stars": "Sangat Positif 😍" } return f"Hasil: {label_map.get(label, label)}\nTingkat keyakinan: {score:.2f}" demo = gr.Interface( fn=predict_sentiment, inputs=gr.Textbox(lines=4, placeholder="Masukkan komentar YouTube..."), outputs="text", title="🎬 Analisis Sentimen Komentar YouTube", description="Masukkan komentar dan lihat hasil sentimennya." ) demo.launch()