Skip to content

This project uses deep learning models to recognize landmarks and monuments, leveraging MobileNetV2 for landmark predictions and a custom CNN for monument classification. It provides functionalities for data visualization, training, and prediction, making it a comprehensive solution for image-based recognition tasks.

Notifications You must be signed in to change notification settings

vs0108/Monument-and-Architecture-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Monument-and-Architecture-Detection

Overview

This project focuses on recognizing landmarks and monuments using deep learning models. It includes two distinct implementations:

  • Architecture.py: Uses a pre-trained MobileNetV2 model for predicting prominent landmarks based on images provided by the user.

  • Monument_Prediction.py: Builds and trains a custom Convolutional Neural Network (CNN) model to classify monuments into predefined categories using a dataset of images.

Features

  1. Architecture.py
  • Leverages the MobileNetV2 model pre-trained on ImageNet.

  • Preprocesses input images for prediction.

  • Displays top-5 predicted classes for the input image.

  • Visualizes the input image using OpenCV.

  1. Monument_Prediction.py
  • Implements a custom CNN architecture.

  • Provides utilities for data preprocessing, visualization, and training.

  • Trains on a dataset using TensorFlow and Keras.

  • Saves the trained model for future use.

  • Offers functionalities to:

View random images from the dataset.

  • Plot training and validation loss/accuracy curves.

  • Predict and visualize results for new images.

Requirements

  1. Python 3.7+

  2. Libraries:

  • TensorFlow

  • OpenCV

  • NumPy

  • Pandas

  • Matplotlib

  • Google Colab (for cloud-based training)

Installation

  1. Clone the repository

git clone https://github.com/your_username/landmark-monument-recognition.git

  1. Navigate to the project directory

cd landmark-monument-recognition

  1. Install required libraries

pip install -r requirements.txt

Usage

  1. Architecture.py
  • Provide the path to the image you want to analyze in the image_path variable.

  • Run the script:

python Architecture.py

  • View the top-5 predictions along with the image.
  1. Monument_Prediction.py
  • Prepare the dataset:

Place training images in train/ directory.

Place testing images in test/ directory.

Update the dataset path in the path variable.

  • Train the model:

python Monument_Prediction.py

  • Save the trained model for future use.

  • Test new images using the pred_and_plot function.

Model Training and Evaluation

  1. CNN Architecture
  • The simplified CNN architecture includes:

  • Convolutional layers with ReLU activation.

  • MaxPooling layers for down-sampling.

  • A Flatten layer to convert feature maps to a single vector.

  • Dense layers with softmax activation for multi-class classification.

  1. Training
  • The model is trained using categorical cross-entropy loss and the Adam optimizer.

  • Accuracy and loss metrics are logged for both training and validation.

  1. Visualization
  • Loss and accuracy curves are plotted using the plot_loss_curves function.

Sample Results

  • Run pred_and_plot() to test the trained model on new images.

ex: pred_and_plot(model_10, "path_to_image.jpg", class_names)

Saving and Loading Models

The trained model is saved in TensorFlow format:

model_10.save("saved_trained_model")

Additionally, the model is saved in a pickle file for easier distribution:

with open('saved_trained_model.pkl', 'wb') as file: pickle.dump(model_10, file)

Dataset

The dataset should be organized as:

dataset/

├── train/

│ ├── class1/

│ ├── class2/

│ └── ...

├── test/

| ├── class1/

| ├── class2/

└── ...
  • Dataset Download

Kaggle Landmark Recognition Datasets

Google Open Images Dataset

Update your dataset path accordingly before training the model.

Future Improvements

  • Expand the dataset for more diverse classes.

  • Experiment with advanced pre-trained models (e.g., EfficientNet, ResNet).

  • Optimize hyperparameters for better performance.

  • Add functionality for automated dataset preprocessing.

Acknowledgments

  • Pre-trained MobileNetV2 model: TensorFlow Keras Applications.

  • Data Augmentation and Training Utilities: TensorFlow and Keras libraries.

  • Visualization: Matplotlib.

About

This project uses deep learning models to recognize landmarks and monuments, leveraging MobileNetV2 for landmark predictions and a custom CNN for monument classification. It provides functionalities for data visualization, training, and prediction, making it a comprehensive solution for image-based recognition tasks.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published