This repository is to do car recognition by fine-tuning ResNet-152 with Cars Dataset from Stanford.
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.
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-152 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
Update "model_weights_path" in "utils.py" with your best model, and use 1,629 validation images for result analysis:
$ python analyze.py
88.70%
$ python test.py
Submit predictions of test data set (8,041 testing images) at Cars Dataset, evaluation result:
88.88%
Download pre-trained model into "models" folder then run:
$ python demo.py --i [image_path]
If no argument, a sample image is used:
$ python demo.py
class_name: Lamborghini Reventon Coupe 2008
prob: 0.9999994
You can build and run the docker using the following process:
Cloning
git clone https://github.com/jqueguiner/car-classification.git car-classification
Building Docker
cd car-classification && docker build -t car-classification -f Dockerfile .
Running Docker
echo "http://$(curl ifconfig.io):5000" && docker run -p 5000:5000 -d car-classification
Calling the API for image detection
curl -X POST "http://MY_SUPER_API_IP:5000/detect" -H "accept: image/png" -H "Content-Type: application/json" -d '{"url":"https://i.ibb.co/Lzpp400/input.jpg"}'