Categorical_Classification / categorical_classification.py
leghari221's picture
Upload categorical_classification.py
2a358f8
raw
history blame
1.02 kB
# -*- coding: utf-8 -*-
"""Categorical Classification.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1_5FDUSnfrkNJilGyx-hoov0pnOF1CHWn
"""
!pip install gradio transformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Softechlb/articles_classification")
model = AutoModelForSequenceClassification.from_pretrained("Softechlb/articles_classification")
from transformers import pipeline
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
def classify_text(text):
result = classifier(text)[0]
label = result["label"]
return label
import gradio as gr
interface = gr.Interface(
fn=classify_text,
inputs="textbox",
outputs="text",
title="Categorical Classification",
description="Text classification model Softechlb/articles_classification from Hugging Face that can classify texts into categories.",
)
interface.launch(share=True)