Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,6 @@ from tensorflow.keras.preprocessing.sequence import pad_sequences
|
|
| 6 |
from tensorflow.keras.models import load_model
|
| 7 |
import pickle
|
| 8 |
|
| 9 |
-
# Model ve diğer nesneleri yükleme
|
| 10 |
model = load_model('model.h5')
|
| 11 |
|
| 12 |
with open('tokenizer.pkl', 'rb') as handle:
|
|
@@ -15,25 +14,21 @@ with open('tokenizer.pkl', 'rb') as handle:
|
|
| 15 |
with open('label_encoder.pkl', 'rb') as handle:
|
| 16 |
label_encoder = pickle.load(handle)
|
| 17 |
|
| 18 |
-
# Eğitim sırasında kullanılan maksimum dizi uzunluğunu belirleme
|
| 19 |
max_length = model.input_shape[1]
|
| 20 |
|
| 21 |
-
|
| 22 |
-
st.
|
| 23 |
-
st.write("Lütfen bir metin girin ve modelin tahmin ettiği duyguyu görün.")
|
| 24 |
|
| 25 |
-
input_text = st.text_input("
|
| 26 |
|
| 27 |
-
if st.button("
|
| 28 |
if input_text:
|
| 29 |
-
# Metni ön işleme
|
| 30 |
input_sequence = tokenizer.texts_to_sequences([input_text])
|
| 31 |
padded_input_sequence = pad_sequences(input_sequence, maxlen=max_length)
|
| 32 |
|
| 33 |
-
# Tahmin yapma
|
| 34 |
prediction = model.predict(padded_input_sequence)
|
| 35 |
predicted_label = label_encoder.inverse_transform([np.argmax(prediction[0])])
|
| 36 |
|
| 37 |
-
st.write("
|
| 38 |
else:
|
| 39 |
-
st.write("
|
|
|
|
| 6 |
from tensorflow.keras.models import load_model
|
| 7 |
import pickle
|
| 8 |
|
|
|
|
| 9 |
model = load_model('model.h5')
|
| 10 |
|
| 11 |
with open('tokenizer.pkl', 'rb') as handle:
|
|
|
|
| 14 |
with open('label_encoder.pkl', 'rb') as handle:
|
| 15 |
label_encoder = pickle.load(handle)
|
| 16 |
|
|
|
|
| 17 |
max_length = model.input_shape[1]
|
| 18 |
|
| 19 |
+
st.title("Text Emotion Classification")
|
| 20 |
+
st.write("Please enter a text and see the emotion predicted by the model.")
|
|
|
|
| 21 |
|
| 22 |
+
input_text = st.text_input("Enter Text:")
|
| 23 |
|
| 24 |
+
if st.button("Predict"):
|
| 25 |
if input_text:
|
|
|
|
| 26 |
input_sequence = tokenizer.texts_to_sequences([input_text])
|
| 27 |
padded_input_sequence = pad_sequences(input_sequence, maxlen=max_length)
|
| 28 |
|
|
|
|
| 29 |
prediction = model.predict(padded_input_sequence)
|
| 30 |
predicted_label = label_encoder.inverse_transform([np.argmax(prediction[0])])
|
| 31 |
|
| 32 |
+
st.write("Predicted Emotion:", predicted_label[0])
|
| 33 |
else:
|
| 34 |
+
st.write("Please enter a text.")
|