File size: 672 Bytes
e8d713c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import inference


# Define the function to classify text and return emojis
def classify_text(text: str):
    if len(text.strip()) == 0: return ""

    result = inference.predict(text)
    if result == 1:
        return "๐Ÿ˜Š Yay! Thanks!"
    
    return "๐Ÿ˜ž We would improve."

# Create the Gradio interface
inface = gr.Interface(fn=classify_text, 
                     inputs="text", 
                     outputs="text",
                     live=True, 
                     title="Review Classification", 
                     description="Enter some text and get a happy or sad emoji based on sentiment.")

# Launch the web app
inface.launch()