Spaces:
Runtime error
Runtime error
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) | |