Spaces:
Running
Running
File size: 1,237 Bytes
5e4f96f d2ec744 5e4f96f d2ec744 5e4f96f |
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 26 27 28 29 30 31 32 33 34 |
import pandas as pd
import gradio as gr
from autogluon.text import TextPredictor
# Load your saved AutoGluon model
predictor = TextPredictor.load("trained_autogluon")
# Define a prediction function for text classification
def classify_text(text):
single_row = pd.DataFrame([text], columns=["text"])
prediction = predictor.predict(single_row)
return prediction[0]
description_text = """
This [model](https://huggingface.co/manifesto-project/manifestoberta-xlm-roberta-56policy-topics-sentence-2023-1-1) was trained on over 8000 German tweets. The label definitions can be found in this [handbook](https://manifesto-project.wzb.eu/coding_schemes/mp_v4) from the Manifesto Project.
With this app you can classify statements into political topics like this:
1. Enter some text in the input box.
2. Click 'Submit' or press 'Enter' to get the classification result.
3. If you want to know the label's definition, look it up [here](https://manifesto-project.wzb.eu/coding_schemes/mp_v4).
"""
# Create a Gradio interface
demo = gr.Interface(
fn=classify_text,
inputs="text",
outputs="label",
title="Manifestoberta fine-tuned on Politweets",
description=description_text
)
# Launch the app
demo.launch() |