Spaces:
Runtime error
Runtime error
Download app from mithunmiracle27/mithu: direct link, hf CLI and curl.
- Browser
- Download file 711 Bytes
-
https://huggingface.co/spaces/mithunmiracle27/mithu/resolve/main/app
- Command line
-
hf download hf://spaces/mithunmiracle27/mithu/app
-
curl -L -o app https://huggingface.co/spaces/mithunmiracle27/mithu/resolve/main/app
711 Bytes
| import gradio as gr | |
| import tensorflow as tf | |
| import pickle | |
| from tensorflow.keras.preprocessing.sequence import pad_sequences | |
| model = tf.keras.models.load_model("keras-rnn-sentiment") | |
| with open("tokenizer.pkl", "rb") as f: | |
| tokenizer = pickle.load(f) | |
| max_length = 200 | |
| def predict_sentiment(text): | |
| seq = tokenizer.texts_to_sequences([text]) | |
| padded = pad_sequences(seq, maxlen=max_length) | |
| prediction = model.predict(padded)[0][0] | |
| if prediction > 0.5: | |
| return "Positive Review ๐" | |
| else: | |
| return "Negative Review ๐" | |
| demo = gr.Interface( | |
| fn=predict_sentiment, | |
| inputs=gr.Textbox(lines=3), | |
| outputs="text", | |
| title="RNN Sentiment Analyzer" | |
| ) | |
| demo.launch() |