Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50,001 changes: 50,001 additions & 0 deletions movie review/IMDB Dataset.csv

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions movie review/ModelandUI.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "uyJ5GBdtu6Se",
"outputId": "1f31bb5d-6bbd-4e65-8622-a4621b802971"
},
"outputs": [],
"source": [
"from keras.models import load_model\n",
"import joblib\n",
"from tensorflow.keras.preprocessing.sequence import pad_sequences\n",
"\n",
"model = load_model(\"model.h5\")\n",
"tokenizer = joblib.load(\"tokenizer.pkl\")\n",
"\n",
"def predictive_system(review):\n",
" sequences = tokenizer.texts_to_sequences([review])\n",
" padded_sequence = pad_sequences(sequences, maxlen=200)\n",
" prediction = model.predict(padded_sequence)\n",
" sentiment = \"positive\" if prediction[0][0] > 0.5 else \"negative\"\n",
" return sentiment"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "09lmoy45viYL",
"outputId": "e33339b3-608a-4afc-d275-616901b246c7"
},
"outputs": [],
"source": [
"!pip install gradio"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 611
},
"id": "6LurZW72vne5",
"outputId": "954e4006-6e09-4cb1-a4b4-54ee77e938b7"
},
"outputs": [],
"source": [
"import gradio as gr\n",
"title = \"MOVIE SENTIMENT ANALYSIS APPLICATION BY @Anuraj-IND\"\n",
"app = gr.Interface(fn = predictive_system, inputs=\"textbox\", outputs=\"textbox\", title=title)\n",
"\n",
"app.launch(share=True)"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
28 changes: 28 additions & 0 deletions movie review/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Movie Sentiment Analysis Application

## Overview

This project demonstrates a movie sentiment analysis application using a Long Short-Term Memory (LSTM) model for textual data. The model is built using TensorFlow and Keras, trained on the IMDB dataset to classify movie reviews as positive or negative. The application is deployed using Gradio for an interactive user interface.
You can run this one google colab make sure to run :
1. sentimentpro_modelGenCode.ipynb
2. ModelandUI.ipynb
## Note : dont put any other file mannually in colab except IMDB Dataset.csv
3. after running 'sentimentpro_modelGenCode.ipynb' successfully youll get "model.h5" and "tokenizer.pkl" generated which you have to download and upload in "ModelandUI.ipynb"

## Project Structure

- **IMDB Dataset**: The dataset used for training and testing the model.
- **Model Building**: The LSTM model is built and trained.
- **Deployment**: The model is deployed using Gradio for interactive usage.
### Prerequisites

- Python 3.x
- TensorFlow and Keras
- Pandas and NumPy
- Gradio for deployment

### Installation

To set up the environment, run:

`pip install tensorflow pandas numpy gradio`
Binary file added movie review/model.h5
Binary file not shown.
Loading
Loading