politweets / app.py
Andrej
added description to demo
d2ec744
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()