Mhammad Ibrahim
Fix model loading from TensorFlow weights
1176a10
raw
history blame
563 Bytes
# import gradio as gr
# def greet(name):
# return "Hello " + name + "!!"
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo.launch()
import gradio as gr
from transformers import pipeline
# Load model from Hugging Face Hub
classifier = pipeline("text-classification", model="Mhammad2023/bert-finetuned-ner", from_tf=True)
def predict(text):
result = classifier(text)[0]
return f"{result['label']} ({round(result['score']*100, 2)}%)"
gr.Interface(fn=predict, inputs="text", outputs="text", title="Text Classification").launch()