File size: 797 Bytes
bd7036e
 
b6a86d3
bd7036e
83b1735
bd7036e
b6a86d3
 
bd7036e
b6a86d3
 
 
 
bd7036e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline
import os

model = pipeline("text-classification", model="i0xs0/Text_Classifiction_V2", tokenizer="i0xs0/Text_Classifiction_V2")

if not os.path.exists(".logs"):
    os.makedirs(".logs")
    
def predict_emotion(text):

    with open(".logs/user_logs.txt", "a") as log_file:
        log_file.write(f"User input: {text}\n")
    results = model(text)  
    return {item["label"]: item["score"] for item in results}


theme = gr.themes.Ocean()

demo = gr.Interface(
    fn=predict_emotion,                
    inputs=gr.Textbox(label="Input Text"),  
    outputs=gr.Label(label="Emotion"),
    title="Emotion Classifier",
    description="Enter a text to classify its emotion.",
    allow_flagging="never",  

    theme=theme  
)


demo.launch()