File size: 615 Bytes
1bb21bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
print('INFO: import modules')
import gradio as gr
import pickle
from required_classes import *


print('INFO: loading model')
try:
    with open('pretrain_logistic_regression_model.pkl', 'rb') as f:
        model = pickle.load(f)
    model.batch_size = 1
    print('INFO: model loaded')
except Exception as e:
    print(f"ERROR: loading model failed with: {str(e)}")

def classify(text):
    pred_classes = model.predict([text])
    output_text = ' '.join(pred_classes)
    return output_text

print('INFO: starting gradio interface')
iface = gr.Interface(fn=classify, inputs="text", outputs="text")
iface.launch()