Spaces:
Runtime error
Runtime error
File size: 722 Bytes
c791d56 c0fbb26 56a53c2 c0fbb26 d9461f1 56a53c2 ef43818 d9461f1 56a53c2 d9461f1 56a53c2 d9461f1 56a53c2 d9461f1 56a53c2 067e6e3 |
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 |
import gradio as gr
import os
from transformers import pipeline
# Lấy token từ biến môi trường
token = os.getenv("TOKEN")
if token is None:
raise ValueError("TOKEN environment variable not set")
# Đăng nhập vào Hugging Face bằng token
from huggingface_hub import login
login(token=token)
# Tải mô hình từ Hugging Face Hub
model_name = "HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1"
classifier = pipeline("text-classification", model=model_name, token=token)
# Định nghĩa hàm xử lý
def classify_text(text):
return classifier(text)
# Tạo interface Gradio
iface = gr.Interface(fn=classify_text, inputs="text", outputs="label")
# Khởi chạy ứng dụng
iface.launch(share=True)
|