Shamima's picture
Update app.py
97c7dfe
import gradio as gr
import os
import pandas as pd
import mindsdb_sdk
# Connect to cloud server
email = os.environ.get('email')
passw = os.environ.get('passw')
# Connect to MindsDB Pro
server = mindsdb_sdk.connect('https://cloud.mindsdb.com', login=email, password=passw, is_managed=True)
project = server.get_project("mindsdb")
model = project.list_models()[0]
def classify_text(text):
# Classify text using the loaded model
var = {"Text": text}
data = pd.DataFrame(var, index=[0])
result = model.predict(data)
label = result['topic']
#score = result['score']
return f"Label: {label}"
# Create Gradio interface
iface = gr.Interface(
fn=classify_text,
inputs=gr.inputs.Textbox(label="Enter text to classify"),
outputs="text",
title="Identify spoiler comments with zero-shot text classification",
description="Input a comment here"
)
# Launch the interface
iface.launch()