Spaces:
Build error
Build error
| ############### 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() |