File size: 2,082 Bytes
78a4acb
 
 
 
 
 
 
 
ca63b78
78a4acb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4fcbe9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
06e1e4c
f4fcbe9
 
 
 
06e1e4c
f4fcbe9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78a4acb
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
import pandas as pd
import tensorflow as tf
import gradio as gr

# Load the SavedModel
model_path = 'Model'
loaded_model = tf.saved_model.load(model_path)

# Retrieve the inference function (usually 'serving_default')
infer = loaded_model.signatures['serving_default']

def pre_process(input_data):
    input_tensor = tf.constant(input_data, dtype=tf.string)
    return input_tensor

def ask(name):
    data = pre_process(name)
    predictions = infer(text = data)
    output_tensor = predictions['output']
    op = output_tensor.numpy()
    if op[0] > 0.5:
        return "The entered message is related to Banking"
    else:
        return "It is a non-banking message. May subject to be SPAM or other messages"

interface = gr.Interface(
    fn=ask,                      # Function to call for prediction
    inputs=gr.Textbox(label="Enter the bank message here:", placeholder="Type your message...", lines=5),  # Input component
    outputs=gr.Textbox(label="Prediction"),  # Output component
    title="Bank Message Classifier", # Title of the interface
    description="Classify your bank messages as 'Banking' or 'Non-Banking'.",  # Description text
    theme="compact",                  # UI theme for compact design
    css="""
    .gradio-container {
        font-family: Arial, sans-serif;
        background-color: #f4f4f4;
        border-radius: 10px;
        padding: 20px;
    }
    .gradio-title {
        font-size: 24px;
        font-weight: bold;
        color: #423f3f;
        text-align: center;
    }
    .gradio-description {
        font-size: 16px;
        color: #423f3f;
        text-align: center;
        margin-bottom: 20px;
    }
    .input_textbox {
        border: 1px solid #ddd;
        border-radius: 5px;
        padding: 10px;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    }
    .output_textbox {
        border: 1px solid #ddd;
        border-radius: 5px;
        padding: 10px;
        background-color: #e9ffe9;
    }
    """
)

interface.launch()