|
import os |
|
import gradio as gr |
|
from transformers import pipeline |
|
import huggingface_hub |
|
|
|
|
|
|
|
|
|
classifier = pipeline("text-classification", model="ICILS/xlm-r-icils-ilo", device=0) |
|
|
|
|
|
def classify_text(text): |
|
""" |
|
Classify the input text into occupational categories using a pre-trained model. |
|
|
|
Args: |
|
text (str): Job description text. |
|
|
|
Returns: |
|
tuple: (label, score) - The classification label and the associated confidence score. |
|
""" |
|
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", |
|
description=( |
|
"Classify job descriptions into occupational categories using a pre-trained XLM-R-ISCO model " |
|
"from Hugging Face Spaces." |
|
), |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|