|
import os |
|
import gradio as gr |
|
import spaces |
|
from transformers import pipeline |
|
import huggingface_hub |
|
|
|
|
|
token = os.getenv("HF_TOKEN") |
|
huggingface_hub.login(token=token) |
|
|
|
|
|
classifier = pipeline("text-classification", model="ICILS/xlm-r-icils-ilo", device=0) |
|
|
|
|
|
@spaces.GPU |
|
def classify_text(text): |
|
result = classifier(text)[0] |
|
label = result['label'] |
|
score = result['score'] |
|
return label, score |
|
|
|
|
|
demo = gr.Interface( |
|
fn=classify_text, |
|
inputs=gr.Textbox(lines=2, label="Job description text", placeholder="Enter a job description..."), |
|
outputs=[gr.Textbox(label="ISCO-08 Label"), gr.Number(label="Score")], |
|
title="XLM-R ISCO classification with ZeroGPU", |
|
description="Classify occupations using a pre-trained XLM-R-ISCO model on Hugging Face Spaces with ZeroGPU" |
|
) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |