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.
- 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.
- 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.
-
Python 3.7+
-
Libraries:
-
TensorFlow
-
OpenCV
-
NumPy
-
Pandas
-
Matplotlib
-
Google Colab (for cloud-based training)
- Clone the repository
git clone https://github.com/your_username/landmark-monument-recognition.git
- Navigate to the project directory
cd landmark-monument-recognition
- Install required libraries
pip install -r requirements.txt
- 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.
- 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.
- 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.
- 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.
- Visualization
- Loss and accuracy curves are plotted using the plot_loss_curves function.
- Run pred_and_plot() to test the trained model on new images.
ex: pred_and_plot(model_10, "path_to_image.jpg", class_names)
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)
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.
-
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.
-
Pre-trained MobileNetV2 model: TensorFlow Keras Applications.
-
Data Augmentation and Training Utilities: TensorFlow and Keras libraries.
-
Visualization: Matplotlib.