This repository is to do car recognition by fine-tuning ResNet-50 with Cars Dataset from Stanford.
- Numpy 1.16.1
- Tensorflow 1.13.1
- Keras 2.0.0
- OpenCV 4.2.0
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 80-20 split.
You can get it from Cars Dataset:
$ cd Car-Recognition
$ 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
Download ResNet-50 into models folder.
Extract 8,144 training images, and split them by 80:20 rule (6,515 for training, 1,629 for validation):
$ python pre_process.py
$ python train.py
If you want to visualize during training, run in your terminal:
$ tensorboard --logdir path_to_current_dir/logs
Python version must be atleast 3.6.8 to run this command in your cmd or anaconda promopt or miniconda prompt
Update "model_weights_path" in "utils.py" with your best model, and use 1,629 validation images for result analysis:
$ python analyze.py
97.54%
$ python test.py
Submit predictions of test data set (8,041 testing images) at Cars Dataset, evaluation result:
87.60%
Download pre-trained model into "models" folder then run:
$ python demo.py
If no argument, a sample image is used:
$ python demo.py
class_name: Lamborghini Reventon Coupe 2008
prob: 0.9999994
$ python gui.py
Select a directory of images of cars. It will create bounding box around a car and will show class name and probability score: