Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,12 +18,25 @@ train = pd.read_csv('train.csv')
|
|
18 |
tokenizer = Tokenizer()
|
19 |
tokenizer.fit_on_texts(train.text)
|
20 |
|
21 |
-
model = tf.keras.models.load_model('DETECTION.keras')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
st.title("TONE DETECTION | BCS WINTER PROJECT")
|
24 |
st.write("Enter a sentence to analyze text's Tone:")
|
25 |
|
26 |
user_input = st.text_input("")
|
27 |
if user_input:
|
28 |
-
result =
|
29 |
st.write(f"TONE: {result}")
|
|
|
18 |
tokenizer = Tokenizer()
|
19 |
tokenizer.fit_on_texts(train.text)
|
20 |
|
21 |
+
model = tf.keras.models.load_model('DETECTION.keras', custom_objects={"emotion": emotion})
|
22 |
+
|
23 |
+
class Predict:
|
24 |
+
def __init__(self, model, tokenizer):
|
25 |
+
self.model = model
|
26 |
+
self.tokenizer = tokenizer
|
27 |
+
|
28 |
+
def predict(self, txt):
|
29 |
+
x = pad_sequences(self.tokenizer.texts_to_sequences([txt]), maxlen=30)
|
30 |
+
x = self.model(x)
|
31 |
+
x = ny.argmax(x)
|
32 |
+
return map_id[x]
|
33 |
+
|
34 |
+
predict = Predict(model, tokenizer)
|
35 |
|
36 |
st.title("TONE DETECTION | BCS WINTER PROJECT")
|
37 |
st.write("Enter a sentence to analyze text's Tone:")
|
38 |
|
39 |
user_input = st.text_input("")
|
40 |
if user_input:
|
41 |
+
result = predict.predict(user_input)
|
42 |
st.write(f"TONE: {result}")
|