File size: 713 Bytes
d870d13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import tensorflow as tf
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification, TextClassificationPipeline

tokenizer = AutoTokenizer.from_pretrained("dipesh/Intent-Classification-Bert-Base-Cased")

model = TFAutoModelForSequenceClassification.from_pretrained("dipesh/Intent-Classification-Bert-Base-Cased")

intent_classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer, return_all_scores=False,
                                               framework='tf')


def predict(input_text):
    ans = intent_classifier(input_text)
    return ans[0]['label']


predict("hello")

iface = gr.Interface(fn=predict, inputs="text", outputs="text")
iface.launch()