Spaces:
Runtime error
Runtime error
File size: 755 Bytes
1fed686 e025580 1fed686 e025580 1fed686 e025580 |
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 |
import gradio as gr
from transformers import pipeline
from bertopic import BERTopic
topic_model = BERTopic.load("TarekAi/ArBERTopic")
def predict_topic(document):
topics, probabilities = topic_model.transform([document])
return {"Predicted Topic": topics[0], "Probabilities": probabilities[0].tolist()}
# Create the Gradio interface
iface = gr.Interface(
fn=predict_topic,
inputs=gr.inputs.Textbox(lines=5, placeholder="Enter your idea here..."),
outputs=[
gr.outputs.Textbox(label="Predicted Topic"),
gr.outputs.Label(label="Topic Probabilities")
],
title="BERTopic Inference",
description="Enter a single idea to get the predicted topic and its probabilities."
)
# Launch the interface
iface.launch()
|