stanford-cars-classification

所属分类:模式识别(视觉/语音等)
开发工具:Python
文件大小:2201KB
下载次数:0
上传日期:2019-06-16 04:37:28
上 传 者sh-1993
说明:  斯坦福汽车分类,斯坦福汽车数据集上的高精度图像分类
(stanford-cars-classification,Image classification on stanford-car dataset with high accuracy)

文件列表:
checkpoints (0, 2019-06-16)
clr_callback.py (5326, 2019-06-16)
config.py (4884, 2019-06-16)
data (0, 2019-06-16)
datasets (0, 2019-06-16)
datasets\trainset.csv (125870, 2019-06-16)
demo.py (3030, 2019-06-16)
docs (0, 2019-06-16)
docs\Solution_for_Stanford_cars_classification.pdf (454032, 2019-06-16)
ensemble.py (812, 2019-06-16)
evaluate.py (7371, 2019-06-16)
images (0, 2019-06-16)
images\12crops.png (492932, 2019-06-16)
images\demo.png (131195, 2019-06-16)
images\distribution.png (12507, 2019-06-16)
images\model_accuracy.png (94023, 2019-06-16)
images\samples (0, 2019-06-16)
images\samples\00589.jpg (44501, 2019-06-16)
images\samples\02381.jpg (51886, 2019-06-16)
images\samples\03126.jpg (209510, 2019-06-16)
images\samples\04046.jpg (54598, 2019-06-16)
images\train_samples.png (306826, 2019-06-16)
logs (0, 2019-06-16)
logs\DenseNet201_trainlog_fold0.csv (6556, 2019-06-16)
logs\DenseNet201_trainlog_fold1.csv (14432, 2019-06-16)
logs\DenseNet201_trainlog_fold2.csv (3560, 2019-06-16)
logs\DenseNet201_trainlog_fold3.csv (6089, 2019-06-16)
logs\DenseNet201_trainlog_fold4.csv (6640, 2019-06-16)
logs\EfficientNetB0_trainlog_fold0.csv (9937, 2019-06-16)
logs\EfficientNetB0_trainlog_fold1.csv (11577, 2019-06-16)
logs\EfficientNetB0_trainlog_fold2.csv (11762, 2019-06-16)
logs\EfficientNetB0_trainlog_fold3.csv (6704, 2019-06-16)
logs\EfficientNetB0_trainlog_fold4.csv (8585, 2019-06-16)
logs\EfficientNetB1_trainlog_fold0.csv (10173, 2019-06-16)
logs\EfficientNetB1_trainlog_fold1.csv (9385, 2019-06-16)
... ...

# Stanford-cars classification In this repository, I'm making a cars classifier using the Stanford cars dataset, which contains 196 classes(including make and model). This repository also contains the checkpoint of 13 models trained on Stanford-cars dataset with high accuracy. You can use it as pretrained weights then transfer learning to other dataset.
Ensemble of some models in this repository can achieve accuracy **0.9462**, higher accuracy than [state-of-the-art stanford cars 2018](https://paperswithcode.com/sota/fine-grained-image-classification-on-stanford) (**0.945**) and nearly [state-of-the-art image classification on stanford cars 2019](https://paperswithcode.com/sota/image-classification-on-stanford-cars) (**0.947**) ## Environments - Ubuntu 16.04 LTS - Cuda 10.0, cuDNN v7.5.0 - Python 3.5, Keras 2.2.4, Tensorflow 1.13.1, Efficientnet - Quick install dependencies:
$ **pip install --upgrade -r requirement.txt** ## Datasets https://ai.stanford.edu/~jkrause/cars/car_dataset.html
3D Object Representations for Fine-Grained Categorization
Jonathan Krause, Michael Stark, Jia Deng, Li Fei-Fei
4th IEEE Workshop on 3D Representation and Recognition, at ICCV 2013 (3dRR-13). Sydney, Australia. Dec. 8, 2013.
[[pdf]](https://ai.stanford.edu/~jkrause/papers/3drr13.pdf) [[BibTex]](https://ai.stanford.edu/~jkrause/papers/3drr13.bib) [[slides]](https://ai.stanford.edu/~jkrause/papers/3drr_talk.pdf) 196 classes
Trainset: 8144 images
Testset: 8041 images
Some images in training set:

Distribution of training set:

Min: 24 images/class , max: 68 images/class , mean: 41 images/class, so this dataset is quite balanced.

Quick download datasets via command line:
$ **bash quick_download.sh**
Cross-validation 5 folds
$ **python prepare.py**
## Training Using pre-trained weights on imagenet dataset, with transfer learning to train the model. All layers will be fine tuned and the last fully connected layer will be replaced entirely. Useful tricks I used for training: - Cyclical Learning Rate [[paper]](https://arxiv.org/abs/1506.01186) [[repo]](https://github.com/bckenstler/CLR) - Heavy augmentation: random crops, horizontal flip, rotate, shear, AddToHueAndSaturation, AddMultiply, GaussianBlur, ContrastNormalization, sharpen, emboss - Random eraser [[paper]](https://arxiv.org/abs/1708.04896) - Mixup [[paper]](https://arxiv.org/abs/1710.09412) - Cross-validation 5 folds $ **python train.py --network network --gpu gpu_id --epochs number_of_epochs --multiprocessing False/True**
You can choose any network in list:
- VGG16, VGG19 - ResNet50, ResNet101, ResNet152, ResNet50V2, ResNet101V2, ResNet152V2, ResNeXt50, ResNeXt101 - InceptionV3, InceptionResNetV2, Xception - MobileNet, MobileNetV2 - DenseNet121, DenseNet169, DenseNet201 - NASNetMobile, NASNetLarge - EfficientNetB0, EfficientNetB1, EfficientNetB2, EfficientNetB3, EfficientNetB4, EfficientNetB5, EfficientNetB6, EfficientNetB7 For example to train MobileNetV2 on 200 epochs:
$ **python train.py --network MobileNetV2 --gpu 0 --epochs 200 --multiprocessing False**
I used the optimal parameters (input size, batch_size) for my hardware (1x1080 Ti 12GB, RAM 32GB, CPU 12 Core), you can modify [config.py](https://github.com/dungnb1333/stanford-cars-classification/blob/master/config.py) to suit your hardware. I saved training log of 13 models on each fold in [logs](https://github.com/dungnb1333/stanford-cars-classification/tree/master/logs) ## Checkpoint Download checkpoint of 13 models in [link](https://www.dropbox.com/sh/jv7dbd5ksj2exun/AAATZFgaxe7rMEjv10PG1BYha?dl=0) then put into folder [checkpoints](https://github.com/dungnb1333/stanford-cars-classification/tree/master/checkpoints) to evaluate model, generate submission or demo on image. ## Evaluate models: To enhance the result, I applied 12 crops for validation and test prediction. Accuracy of single model is ensemble of 12 crops and 5 folds. For example with input shape of network is 224x224x3:

To evaluate network, run:
$ **python evaluate.py --network network --gpu gpu_id --multi_crops True/False**
For example:
$ **python evaluate.py --network MobileNetV2 --gpu 0 --multi_crops True**
To generate submission for each model, run:
$ **python predict.py --network network --gpu gpu_id** Output is network.txt in folder [submission](https://github.com/dungnb1333/stanford-cars-classification/tree/master/submission) and raw output network.npy in folder [data](https://github.com/dungnb1333/stanford-cars-classification/tree/master/data) You can summit your result at [stanford-cars evaluation server](http://imagenet.stanford.edu/internal/car196/submission/submission.php). Accuracy and size of 13 models:

## Ensemble multi-models Final result [**0.9462**](https://github.com/dungnb1333/stanford-cars-classification/blob/master/submission/Ensemble.txt) is ensemble of some models with suitable ratios: result = sum(weight x model) / sum(weight).
$ **python ensemble.py**
I just tried a few cases, you can try with other ratios and other models to get higher accuracy than 0.9462. ## Demo on image $ **python demo.py --network network --gpu gpu_id --image_path path --imshow True/False**
For example:
$ **python demo.py --network ResNeXt101 --gpu 0 --image_path images/samples/02381.jpg --imshow True**

Please read the file [docs/Solution_for_StanfordCars_classification.pdf](https://github.com/dungnb1333/stanford-cars-classification/raw/master/docs/Solution_for_Stanford_cars_classification.pdf) for more information.

近期下载者

相关文件


收藏者