File size: 3,455 Bytes
22ec88e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90f9e09
f2ada5a
 
fbeb298
 
 
 
5fc6e92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbeb298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc6e92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbeb298
5fc6e92
 
fbeb298
22ec88e
 
f2ada5a
22ec88e
 
 
 
 
 
 
 
 
90f9e09
 
f2ada5a
 
22ec88e
 
f2ada5a
 
90f9e09
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import streamlit as st
import numpy as np
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
import pickle 

# Load the LSTM model
lstm_model = load_model('lstm.h5')

# Load the Tokenizer used during training
with open('tokenizer.pkl', 'rb') as tokenizer_file:
    tokenizer = pickle.load(tokenizer_file)

# Define class labels and their numerical mapping
class_mapping = {"Angry": 0, "Sad": 1, "Joy": 2, "Surprise": 3}
numerical_to_label = {v: k for k, v in class_mapping.items()}

st.title('VibeConnect')


# Define the emojis you want to use
emojis = ["๐Ÿคฃ","๐Ÿฅฒ","๐Ÿฅน","๐Ÿ˜‡","๐Ÿ˜","๐Ÿ˜‹","๐Ÿคช","๐Ÿคฉ","๐Ÿฅณ","๐Ÿ˜ญ","๐Ÿ˜ก","๐Ÿ˜ฆ","๐Ÿ˜ง","๐Ÿ˜ฎ","๐Ÿฅด","๐Ÿคฎ","๐Ÿคง","๐Ÿ˜ท"]

# Create a string of emojis to use as the background
background_emojis = " ".join(emojis * 10)  # Repeat the emojis to cover the background

centered_text = """
    <style>
        .center {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh; /* Adjust height as needed */
        }
    </style>
    <div class="center">
        <h1>VibeConnect</h1>
    </div>
"""

# Set the HTML as the app's content
st.markdown(centered_text, unsafe_allow_html=True)

# Use HTML and CSS to set the background
background_style = f"""
    <style>
        body {{
            background: linear-gradient(to right, #ffecd2, #fcb69f);
            font-size: 30px;
            background-size: 100% 100%;
            background-attachment: fixed;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }}

        .content {{
            background: rgba(255, 255, 255, 0.8);
            padding: 20px;
            border-radius: 10px;
            text-align: center;
        }}
    </style>
    <div class="content">
        {background_emojis}
        
    </div>
"""

# Set the HTML as the app's background
st.markdown(background_style, unsafe_allow_html=True)

faded_youtube_logo = """
    <style>
        .center {
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
        }

        .faded-logo {
            opacity: 0.5; /* Adjust the opacity as needed */
        }
    </style>
    <div class="center">
        <img class="faded-logo" src="https://www.google.com/url?sa=i&url=https%3A%2F%2Fturbologo.com%2Farticles%2Fyoutube-logo%2F&psig=AOvVaw1gU5UHyLbw5yrC8oMHTMGv&ust=1701710559816000&source=images&cd=vfe&ved=0CBIQjRxqFwoTCNCDnO7k84IDFQAAAAAdAAAAABAE" alt="YouTube Logo" width="200">
    </div>
"""

# Set the HTML as the app's content
st.markdown(faded_youtube_logo, unsafe_allow_html=True)


# Text input for the user to enter a sequence
user_input = st.text_input('Enter a Text:')

if st.button('Predict'):
    # Tokenize and pad the user input
    sequence = tokenizer.texts_to_sequences([user_input])
    padded_sequence = pad_sequences(sequence, maxlen=128)

    # Make predictions
    prediction = lstm_model.predict(padded_sequence)

    emojis = ["๐Ÿ˜ก", "๐Ÿ˜ญ", "๐Ÿ˜„", "๐Ÿ˜ฏ"]

    threshold = 0.5 
    # Display the label
    for i in range(len(prediction[0])):
        label = numerical_to_label[i]
        probability = prediction[0][i]
        if probability > threshold:
            st.write(f'{label}{emojis[i]}')