This project provides a collection of Python-based heatmap visualization techniques designed to identify and pinpoint AI-edited or AI-generated manipulations within images. Leveraging various computer vision and explainable AI (XAI) methodologies, the tool aims to enhance transparency and aid in the detection of subtle, often imperceptible, alterations introduced by advanced AI models. It offers researchers, forensic analysts, and developers a robust framework to visualize regions of interest where AI interventions are most prominent.
- Diverse Heatmap Generation: Implementations of various heatmap generation algorithms (e.g., Grad-CAM, Saliency Maps, Attention Maps, Anomaly Detection based heatmaps) tailored for image manipulation detection.
- Image Preprocessing: Utilities for loading, resizing, and normalizing images to prepare them for analysis.
- Visualization Overlay: Seamless overlay of generated heatmaps onto original images to clearly highlight manipulated regions.
- Customizable Parameters: Options to adjust heatmap intensity, color schemes, and thresholding for refined visualization.
- Output Formats: Support for saving analyzed images with heatmap overlays in various common image formats.
- Modular Design: A flexible architecture that allows for easy integration of new heatmap algorithms or AI detection models.
This project is built using the following technologies:
- Python: The primary programming language.
- NumPy: Essential for numerical operations and array manipulation.
- Matplotlib: Used for generating and displaying heatmaps and visual overlays.
- Pillow (PIL Fork): For basic image loading, manipulation, and saving.
- OpenCV (cv2): For advanced image processing tasks (e.g., resizing, color conversions).
- PyTorch / TensorFlow (Optional): If integrating with specific deep learning models for manipulation detection, one of these frameworks would be utilized for model inference and gradient-based heatmap generation.
To get this project up and running on your local machine, follow these steps:
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git cd Heatmap-Visualization-Techniques-for-Identifying-AI-Edited-Image-Manipulations -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
(A sample
requirements.txtmight look like:numpy matplotlib Pillow opencv-python # If using deep learning: # torch # torchvision # tensorflow)
This section will guide you on how to use the various heatmap visualization techniques.
-
Prepare your input image(s): Place the images you wish to analyze in a designated directory (e.g.,
input_images/). -
Run the main script with desired parameters: You can specify the input image path and the heatmap generation method.
Example: To generate a saliency map for an image:
python main.py --image input_images/ai_edited_image.jpg --method saliency --output_dir output_heatmaps/
To generate a Grad-CAM heatmap (requires a pre-trained model capable of detecting manipulations):
python main.py --image input_images/ai_edited_image.jpg --method gradcam --model_path path/to/your/detection_model.pth --target_layer layer4 --output_dir output_heatmaps/
Common Arguments:
--image: Path to the input image file. (Required)--method: Heatmap generation method (e.g.,saliency,gradcam,attention,anomaly). (Required)--output_dir: Directory to save the output heatmaps and overlaid images. (Default:output/)--model_path: (Optional, required forgradcamor similar methods) Path to a pre-trained AI manipulation detection model.--target_layer: (Optional, forgradcam) The target convolutional layer for Grad-CAM.--alpha: (Optional) Transparency level for the heatmap overlay (0.0-1.0). (Default: 0.6)
Refer to the
main.pyscript for a comprehensive list of arguments and their descriptions. -
View the results: The generated heatmap and the original image with the heatmap overlay will be saved in the specified
output_dir.
(You would typically include a screenshot here showing an example image with a heatmap overlay)
A placeholder for an image demonstrating a heatmap overlaying an AI-edited image, highlighting manipulated regions.
We welcome contributions to this project! If you'd like to improve the codebase, add new features, or fix bugs, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name. - Make your changes and ensure the code adheres to the existing style.
- Write clear, concise commit messages.
- Push your branch to your forked repository.
- Open a Pull Request against the
mainbranch of this repository, describing your changes in detail.
Please ensure your pull requests are well-documented and pass any existing tests.
This project is licensed under the MIT License - see the LICENSE file for details.
Note: Remember to replace YOUR_USERNAME/YOUR_REPOSITORY in the badge links with your actual GitHub username and repository name once your project is hosted. You should also create a LICENSE file in the root of your project with the MIT license text.