Skip to content

Classification of car brands with "Wide Residual Networks"

Notifications You must be signed in to change notification settings

purpleFar/car-brand-classification

Repository files navigation

car-brand-classification

Code style: black

This repository gathers the code for car brand classification from the in-class Kaggle challenge.
To read the detailed solution, please, refer to my report.

Hardware

The following specs were used to create the original solution.

  • Windows 10
  • Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz 2.50GHz
  • NVIDIA GeForce GTX 1660 Ti

Reproducing Submission

To reproduct my submission without retrainig, do the following steps:

  1. Installation
  2. Download Data
  3. Preprocessing Images
  4. Download Pretrained models
  5. Inference

Installation

All requirements should be detailed in requirements.txt. Using Anaconda is strongly recommended.

$ conda create -n  hw1 python=3.6
$ conda activate hw1
$ pip install -r requirements.txt

Download Data

If the Kaggle API is installed, run following commands.

Note! there is no default unzip command in windows 10, you must unzip by GUI.

$ kaggle competitions download -c cs-t0828-2020-hw1
$ unzip cs-t0828-2020-hw1.zip

Unzip them then you can see following structure:

car-brand-classification/
    ├── testing_data
    │   ├── 000004.jpg
    │   ├── 000005.jpg
    │   │   .
    │   │   .
    │   │   .
    │   └── 016181.jpg
    ├── training_data
    │   ├── 000001.jpg
    │   ├── 000002.jpg
    │   │   .
    │   │   .
    │   │   .
    │   └── 016185.jpg
    ├── training_labels.csv
    │   .
    │   .

Preprocessing Images

To train or inference, preprocessing is required. Run following command.

$ python preprocessing.py

then there is some file in preprocess_file folder like this

car-brand-classification/preprocess_file/
    ├── label.pkl
    ├── name_to_num.pkl
    └── num_to_name.pkl

Train models

To train models, run following command.

$ python train.py --train_dir training_data --model_save_dir model

Pretrained models

You can download pretrained model that used for my submission from link. Or run following commands.

Note! there is no default unzip command in windows 10, you must unzip by GUI.

$ wget https://drive.google.com/file/d/1fkrZNX9LAD8Ro5DOyG-Qap0MxV9LOLmH/view?usp=sharing
$ unzip model_wide_resnet.zip

Unzip them then you can see following structure:

car-brand-classification/model_wide_resnet/
    ├── best_model0.pt
    ├── best_model1.pt
    ├── best_model2.pt
    ├── best_model3.pt
    ├── best_model4.pt
    ├── best_model5.pt
    ├── best_model6.pt
    ├── best_model7.pt
    ├── best_model8.pt
    ├── best_model9.pt
    ├── best_model10.pt
    ├── best_model11.pt
    └── best_model12.pt

Inference

If trained weights are prepared, you can create a file containing the car brand classification for each picture in test set.

Using the model trained by yourself, enter the command:

$ python test.py --test_dir testing_data --model_dir model --save_name submission.csv

Using the pre-trained model, enter the command:

$ python test.py --test_dir testing_data --model_dir model_wide_resnet --save_name submission.csv

And you can see the submission.csv in result folder

About

Classification of car brands with "Wide Residual Networks"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages