Phuc Nguyen
edit predict func
13dcfdb
raw
history blame contribute delete
645 Bytes
############### Tích hợp model từ Hub ###############
from transformers import pipeline
import gradio as gr
classifier = pipeline(
model="lxyuan/distilbert-base-multilingual-cased-sentiments-student",
top_k=None,
framework="pt"
)
############### Tạo giao diện ###############
def predict(text):
predictions = classifier(text)[0]
result = {pred['label']: pred['score'] for pred in predictions}
return result
demo = gr.Interface(
fn=predict,
inputs="text",
outputs="label",
title="Sentiment Analysis App",
description="Phân tích cảm xúc bằng mô hình DistillBERT"
)
demo.launch()