File size: 925 Bytes
b95566c
 
 
 
 
 
 
 
 
 
 
 
 
97c7dfe
b95566c
 
 
 
 
 
 
 
 
97c7dfe
b95566c
 
 
 
 
 
 
 
97c7dfe
b95566c
 
 
 
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
35
36
37
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()