There are two models provided in the main.ipynb
file. First is the model trained from scratch, and the second is a model utilizing transfer learning.
The first model implements a CNN (Convolutional Neural Network). It is best described with the following picture.
In short, convolution and maxpooling serve as a way to filter the distinguishing features of the picture in matrix form. Subsequently, the flatten layer converts the matrix to a list of numbers as the hidden layer accepts an array of numbers rather than matrices. After processing the data
through the hidden layer, the numbers will go through a sigmoid function to classify the image: in this case, an output below 0.5 is a cheetah, and an output above 0.5 is a jaguar.
The second model uses transfer learning from imagenet to assist the learning process. It is much more accurate because of the experienced base model. The picture below illustrates the process well.
We do not need to do the complex convolutional layers as the base model already executes the operation. The numbers will also go through a sigmoid activation function at the end as described previously in the first model.
- Download dataset from Kaggle
- Install libraries via
pip install requirements.txt
- Train the model
- Test images (256x256) by uploading images from the internet and linking them through the path directory
test_img1 = cv2.imread('chee.jpg') # modify chee.jpg
result = int(model.predict(np.expand_dims(test_img1/255,0)) > 0.5)
result