It is a python code to build a CNN model and to train the model to differentiate between cat and dog images.
Feel free to use two test images of a puppy and a cat, puppy21.jpg
and cat21.jpg
respectively.
The Drive link for the dataset I used :: https://drive.google.com/file/d/1Loswupf1eCdHiitqshCwMjqGhRAitk5M/view?usp=sharing
Please keep all the contents of the repository and the downloaded dataset in the same folder for proper functioning.
Cheers!
Before executing the python notebook be sure to install keras and numpy. For installing first check if you have python installed.
Head over to python.org
to install python. When installed run command prompt. Execute the command pip install keras
and then pip install numpy
.
These codes will successfully install keras and numpy modules in your system.
The python notebook is commented in each block to make it easier to understand.
The code Follows the following approach::
1) Initialising the CNN
2) Step 1 - Convolution
3) Step 2 - Pooling
4) Step 3 - Flattening
5) Step 4 - Full connection
6) Compiling the CNN
7) Training the model
8) predictions for dog image using train model
9) predictions for cat image using train model