leghari221's picture
Rename categorical_classification.py to app.py
1831ac0
raw
history blame contribute delete
No virus
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)