Lab Guide: Image Recognition with TensorFlow and Keras
Objective
To provide students with hands-on experience in developing, training, and evaluating image recognition models using TensorFlow and Keras.
Prerequisites
- Basic understanding of Python programming.
- Familiarity with machine learning concepts.
- Python and necessary libraries installed: TensorFlow and Keras.
Lab Outline
Introduction to Image Recognition: - Discussing the basics of image recognition and convolutional neural networks (CNN).
Setting Up the Environment: - Installing TensorFlow and Keras:
Image Data Preprocessing:
-
Step 1: Importing Necessary Libraries:
-
Step 2: Loading and Preprocessing Image Data:
Building a Convolutional Neural Network (CNN):
-
Step 3: Defining the CNN Architecture:
-
Step 4: Adding Dense Layers:
Compiling and Training the Model:
-
Step 5: Compiling the Model:
-
Step 6: Training the Model:
Evaluating the Model:
- Step 7: Evaluating the Model and Visualizing Results:
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2) import matplotlib.pyplot as plt plt.plot(history.history['accuracy'], label='accuracy') plt.plot(history.history['val_accuracy'], label = 'val_accuracy') plt.xlabel('Epoch') plt.ylabel('Accuracy') plt.ylim([0.5, 1]) plt.legend(loc='lower right') plt.show()