Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Muat pipeline langsung dari model Anda di Hub
|
| 5 |
+
# Spaces akan otomatis men-download model Anda
|
| 6 |
+
pipe = pipeline("text-classification", model="niejanee/indobert-sentiment-tokopedia-reviews")
|
| 7 |
+
|
| 8 |
+
def classify_review(text):
|
| 9 |
+
result = pipe(text)[0]
|
| 10 |
+
return {result['label']: result['score']}
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=classify_review,
|
| 14 |
+
inputs=gr.Textbox(lines=5, placeholder="Masukkan ulasan produk di sini..."),
|
| 15 |
+
outputs="label",
|
| 16 |
+
title="Analisis Sentimen Ulasan Produk",
|
| 17 |
+
description="Model ini menganalisis sentimen ulasan produk menggunakan fine-tuned IndoBERT."
|
| 18 |
+
)
|
| 19 |
+
iface.launch()
|