ICP 11 - AsharGit/Python-ICP GitHub Wiki

a. Description about the ICP

In this ICP we are given 3 tasks

  1. Add additional layers to our model to see if we see an improvement in the performance.
  2. Use 4 sample images in the test set to see how accurate our model is in predicting image category. As a bonus we load our model from .h5 file.
  3. Create an accuracy and loss plot

b. Objective

In this ICP we are building a CNN model to help image classification. We are using the Cifar-10 data set in this ICP.

c. Design/ implementation(include screenshots with explanations)

We start our ICP with a given source code, we simply run the code to see what our base accuracy is

Our base model accuracy is 71.31%

We also plot the accuracy and loss of our model

Accuracy

Loss

The first task of the ICP is to apply additional layers and see if it changes performance

Using the new model we execute the code again.

The accuracy of the new model is 79.67%, an improved accuracy of 8.36%

Task 3 of the ICP asks us to plot the accuracy and loss of this new model

We use matplotlib and assign our variables to create our plot

Accuracy

Loss

For task 2 we evaluate the first 4 images in the test data set and predict the correct category using our model

As a bonus we are supposed to load our model from a h5 file

We can save the model as an h5 file by using the model.save function

Now we can load up the model by using load_model

We use a list of categories so we can display results as string rather than as int's

Next we can use the test data to make our prediction

Finally we a run a loop to display the first 4 images, their real category, and the predicted category from our model

Our prediction model on the first 4 images in the test data set

d. Video link

https://youtu.be/_0pIDVdiXoA

e. Conclusion

i. What you have learned from the ICP

In this ICP I learned how to work with images, previously we worked with numbers on images but that was a simpler model to build and this one seemed a bit more challenging to get to work. I also learned about saving and loading models which can be useful for reuse.

ii. What the challenge you have faced

Different versions of Keras and Tensorflow seem to cause problems. I had a lot of difficulties running the code even though the code was correct. My machine still would throw an error when I moved code that was working in Google Colab over to Pycharm without any changes. Also while using Google Colab I also had problems generating images from Cifar-10 data set, despite trying many different solutions I was only able to generate the image as a collage.