Skip to content

Sibikrish3000/movie-genre-classification

Repository files navigation

movie genre image

Movie Genre Classification API and Web App

This application uses machine learning to classify movies into genres based on their descriptions.

GitHub license GitHub stars GitHub issues

sklearn language fastapi docker streamlit

This project includes a FastAPI-based API and a Streamlit web application for classifying movie genres based on their descriptions. The machine learning models used in this project include Logistic Regression, Support Vector Classifier, and Balanced Random Forest.

Dataset

Movie Genre Dataset

Try on Streamlit

streamlit

Try on Huggingface Space

huggingface

Project Structure

project_root/
│
├── app.py
├── streamlit_app.py
├── models/
│   ├── Logistic_Regression_piped.pkl
│   ├── SVM_piped.pkl
│   └── balanced_random_forest.pkl
└── static/
    ├── images/
    │   ├── api.png
    │   ├── icon.png
    │   └── cover.jpg
    ├── about.md
    └── metrics.md
  • app.py: Defines the FastAPI application.
  • streamlit_app.py: Defines the streamlit webapp.
  • Dockerfile: Dockerfile for building the Docker image.
  • docker-compose.yml: Docker Compose file for orchestrating the services.
  • requirements.txt: List of dependencies.
  • models/: Directory containing pre-trained machine learning models.
  • static/: Directory containing static files such as images used in the interface.

Setup

  1. Clone the repository
git clone https://github.com/Sibikrish3000/movie-genre-classification.git
cd movie-genre-classification
  1. Install dependencies
pip install -r requirements.txt
  1. Download NLTK data:
python -m nltk.downloader punkt
python -m nltk.downloader stopwords
  1. Ensure the following directory structure and files are in place
project_root/
│
├── app.py
├── streamlit_app.py
├── notebook/
├── models/
│   ├── Logistic_Regression_piped.pkl
│   ├── SVM_piped.pkl
│   └── balanced_random_forest.pkl
└── static/
    ├── images/
    │   ├── api.png
    │   ├── icon.png
    │   └── cover.jpg
    ├── about.md
    └── metrics.md

Running the Application Locally

  1. Start the FastAPI server
uvicorn app:app --host 0.0.0.0 --port 8000 --reload
  1. Run the Streamlit application
streamlit run streamlit_app.py

Using Docker Compose

  1. Build and start the containers:

    docker network create AIservice
    docker-compose up --build
  2. Access the streamlit webapp at http://localhost:8501.

Development

Running in a Gitpod Cloud Environment

Click the button below to start a new development environment:

Open in Gitpod

Usage

  • Enter Movie Description: Input the movie description you want to classify.
  • Predict: Click the "Predict" button to see the classification result.

API Endpoints

Home

  • URL: /
  • Method: GET
  • Response: HTML home page

Predict

  • URL: /predict
  • Method: POST
  • Payload: JSON object with movie description and model selection
  • Response: JSON object with predicted genre

Streamlit Web Application

The Streamlit web application provides a user-friendly interface for movie genre classification. Users can input a movie description, select a model, and receive a genre prediction. The app also includes an "About" section and a "Metrics" section with relevant information.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Sibi Krishnamoorthy

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages