Spaces:
Sleeping
Sleeping
File size: 909 Bytes
bf398a7 c52ae65 bf398a7 c52ae65 9d786ad c52ae65 b706990 c52ae65 b706990 c1f383c e67de93 c1f383c b706990 c1f383c |
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 29 |
import gradio as gr
from transformers import pipeline
# Load the classification pipeline
classifier = pipeline(
"sentiment-analysis",
# model="Karzan/user_profile_model",
model="Karzan/roles-based-on-skills-model",
return_all_scores=True,
top_k=10
)
# Define the prediction function
def classify_text(text):
# Perform classification
results = classifier(text)
# Format the output
formatted_results = [
{"label": item["label"], "score": round(item["score"], 4)}
for result in results for item in result
]
output = {}
print(formatted_results)
for i in range(len(formatted_results)):
output[formatted_results[i]['label']] = formatted_results[i]['score']
return output
demo = gr.Interface(fn=classify_text, inputs=[gr.Textbox(label="Input")], outputs=gr.Label(label="Classification"), title="Text Classification")
demo.launch() |