Skip to content

This repo contains code for classifying caricature and cartoon images with 87% accuracy

Notifications You must be signed in to change notification settings

milsun/caricature-vs-cartoon-classifier

Repository files navigation

Caricature Vs Cartoon Classifier

This repo contains code for classifying caricature and cartoon images using Convolutional neural network(CNN) and transfer learning.

Abstract

VGG16

  • A CNN based model trained on augmented 3.5k original images.
  • Model takes advantage of transfer learning and uses pre-trained VGG16 model weights.
  • Trained model is able to achieve 87% accuracy.
  • Developed as a sub-project to filter cartoons from caricature dataset.
  • Trained model can be found here.

Getting Started

Prerequisites

Run below command if you don't have python3 installed

sudo apt-get install python3.6

Installing

Dependencies:

pip install tensorflow
pip install keras
pip install PyDrive
pip install numpy
pip install matplotlib

Usage

def load_image(filename):
    img = image.load_img(filename, target_size=(224, 224))
    img_tensor = image.img_to_array(img)             
    img_tensor = np.expand_dims(img_tensor, axis=0)       
    img_tensor /= 255. 

    return img_tensor

from keras.models import load_model

model = load_model('model.h5')
threshold = 0.2

if model.predict(load_image(img_name))[0][0] < threshold:
	print('Caricature')
else:
	print('Cartoon')

Results

As you can see model works pretty well, and only gets confused with cartoon images containing a single face.

Results

About

This repo contains code for classifying caricature and cartoon images with 87% accuracy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published