Skip to content

foamliu/Car-Recognition-PyTorch

Repository files navigation

Car Recognition

This repository is to do car recognition by fine-tuning ResNet-152 with Cars Dataset from Stanford.

Dependencies

  • Python 3.6.8
  • PyTorch 1.3

Dataset

We use the Cars Dataset, which contains 16,185 images of 196 classes of cars. The data is split into 8,144 training images and 8,041 testing images, where each class has been split roughly in a 50-50 split.

image

You can get it from Cars Dataset:

$ cd Car-Recognition-PyTorch
$ wget http://imagenet.stanford.edu/internal/car196/cars_train.tgz
$ wget http://imagenet.stanford.edu/internal/car196/cars_test.tgz
$ wget --no-check-certificate https://ai.stanford.edu/~jkrause/cars/car_devkit.tgz

ImageNet Pretrained Models

Download ResNet-152 into models folder.

Usage

Data Pre-processing

Extract 8,144 training images, and split them by 80:20 rule (6,515 for training, 1,629 for validation):

$ python pre_process.py

Train

$ python train.py

If you want to visualize during training, run in your terminal:

$ tensorboard --logdir runs

image

Analysis

Update "model_weights_path" in "utils.py" with your best model, and use 1,629 validation images for result analysis:

$ python analyze.py

Validation acc:

88.70%

Confusion matrix:

image

Test

$ python test.py

Submit predictions of test data set (8,041 testing images) at Cars Dataset, evaluation result:

Test acc:

88.88%

image

Demo

image

class_name: Lamborghini Reventon Coupe 2008
prob: 0.9999994

Download pre-trained model then run:

$ python demo.py

It picks 20 random valid images to recognize:

1 2 3 4
image image image image
Ferrari 458 Italia Convertible 2012, prob: 0.9993 Buick Rainier SUV 2007, prob: 0.9707 Dodge Dakota Club Cab 2007, prob: 1.0 Dodge Magnum Wagon 2008, prob: 1.0
image image image image
Hyundai Azera Sedan 2012, prob: 0.9955 BMW 3 Series Sedan 2012, prob: 1.0 Mercedes-Benz 300-Class Convertible 1993, prob: 0.9959 McLaren MP4-12C Coupe 2012, prob: 1.0
image image image image
Ford Freestar Minivan 2007, prob: 0.712 Buick Regal GS 2012, prob: 1.0 Toyota Corolla Sedan 2012, prob: 0.7908 Lincoln Town Car Sedan 2011, prob: 1.0
image image image image
Audi V8 Sedan 1994, prob: 0.9453 Daewoo Nubira Wagon 2002, prob: 0.52 Chrysler 300 SRT-8 2010, prob: 1.0 Ford F-150 Regular Cab 2007, prob: 1.0
image image image image
Dodge Caravan Minivan 1997, prob: 1.0 BMW M6 Convertible 2010, prob: 0.3966 Nissan Leaf Hatchback 2012, prob: 0.6143 Honda Accord Coupe 2012, prob: 0.9997

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published