Spaces:
Runtime error
Runtime error
File size: 1,058 Bytes
180d149 02304bb 180d149 02304bb f9775c7 02304bb | 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 | import streamlit as st
import tensorflow as tf
import pickle
from tensorflow.keras.preprocessing.sequence import pad_sequences
st.title("IMDB Movie Review Sentiment Analysis")
st.write("Bu uygulama, girilen film yorumunun pozitif mi negatif mi olduğunu tahmin eder.")
model = tf.keras.models.load_model("src/imdb_lstm_model.h5")
with open("src/tokenizer.pkl", "rb") as file:
tokenizer = pickle.load(file)
maxlen = 200
yorum = st.text_area("Film yorumunu yazınız:")
if st.button("Tahmin Et"):
if yorum.strip() == "":
st.warning("Lütfen bir yorum yazınız.")
else:
yorum_dizi = tokenizer.texts_to_sequences([yorum])
yorum_pad = pad_sequences(
yorum_dizi,
maxlen=maxlen
)
tahmin = model.predict(yorum_pad)[0][0]
if tahmin >= 0.5:
st.success("Tahmin: Pozitif Yorum")
else:
st.error("Tahmin: Negatif Yorum")
st.write("Pozitif olma olasılığı:", round(float(tahmin), 4)) |