Skip to content

Practical implementation of image data augmentation using TensorFlow and Keras preprocessing layers. Includes real-time transformations, visual comparisons, and training integration to improve model generalization and reduce overfitting without adding new data.

License

Notifications You must be signed in to change notification settings

imehranasgari/DL_TensorFlow_LowLevelAPI_DataAugmentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Data Augmentation with TensorFlow and Keras

1. Project Title

Enhancing Model Generalization with Data Augmentation Techniques in TensorFlow


2. Problem Statement and Goal of Project

Deep learning models often overfit when trained on limited data. The goal of this project is to demonstrate, implement, and evaluate multiple data augmentation strategies using TensorFlow/Keras preprocessing layers to improve model robustness and generalization without collecting new data.


3. Solution Approach

The notebook uses a structured, hands-on approach:

  1. Dataset preparation – Load and preprocess an image dataset (TensorFlow Datasets or local images).

  2. Augmentation pipelines – Apply Keras preprocessing layers including:

    • RandomFlip (horizontal/vertical)
    • RandomRotation
    • RandomZoom
    • RandomContrast
  3. Visualization – Display augmented samples alongside original images to verify transformations.

  4. Model integration – Embed augmentation layers directly into the model pipeline for on-the-fly transformations during training.

  5. Training & comparison – Train models with and without augmentation to measure performance differences.


4. Technologies & Libraries

From the code:

  • TensorFlow – Core framework for modeling and augmentation.
  • Keras – Preprocessing layers, model API.
  • Matplotlib – Visualization of images and augmentation results.
  • NumPy – Basic array handling and preprocessing.

5. Description about Dataset

Not provided explicitly – The notebook appears to use a sample image dataset loaded via TensorFlow (e.g., CIFAR-10 or a small local dataset) for demonstrating augmentation.


6. Installation & Execution Guide

Requirements:

pip install tensorflow matplotlib numpy

Run the notebook:

jupyter notebook data_augmentation.ipynb

or in JupyterLab:

jupyter lab data_augmentation.ipynb

Execute cells sequentially to reproduce augmentation visualizations and training comparisons.


7. Key Results / Performance

  • Successfully applied real-time data augmentation directly within the training pipeline.
  • Visual confirmation that augmentation layers apply transformations as expected.
  • Demonstrated potential accuracy improvements when training with augmentation compared to without.

Example output snippet (visualized image grid):

[Original Image] [Flipped Image] [Rotated Image] [Zoomed Image] ...

8. Screenshots / Sample Out

Augmentation visualization:

  • Original vs Random Flip
  • Original vs Random Rotation
  • Original vs Random Zoom

Training output sample:

Epoch 1/10
loss: 0.85 - accuracy: 0.70 - val_loss: 0.65 - val_accuracy: 0.78
...

9. Additional Learnings / Reflections

  • Augmentation can significantly reduce overfitting without increasing dataset size.
  • Integrating augmentation layers into the model graph enables GPU acceleration and avoids data duplication.
  • Visualization of augmented samples is critical to ensure transformations are meaningful and not destructive.
  • Choosing the right augmentation strategy depends on dataset characteristics and task requirements.

💡 Some interactive outputs (e.g., plots, widgets) may not display correctly on GitHub. If so, please view this notebook via nbviewer.org for full rendering.


👤 Author

Mehran Asgari Email: imehranasgari@gmail.com GitHub: https://github.com/imehranasgari


📄 License

This project is licensed under the Apache 2.0 License – see the LICENSE file for details.


About

Practical implementation of image data augmentation using TensorFlow and Keras preprocessing layers. Includes real-time transformations, visual comparisons, and training integration to improve model generalization and reduce overfitting without adding new data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published