https://github.com/mpolinowski/tf-cifar
The CIFAR-10 is a labeled subset of the 80 million tiny images dataset that can be directly downloaded using Keras.
https://github.com/mpolinowski/tf-cifar
cifar-10 image-classification tensorflow2
Last synced: 7 months ago
JSON representation
The CIFAR-10 is a labeled subset of the 80 million tiny images dataset that can be directly downloaded using Keras.
- Host: GitHub
- URL: https://github.com/mpolinowski/tf-cifar
- Owner: mpolinowski
- Created: 2022-12-17T10:01:59.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-18T10:22:46.000Z (almost 3 years ago)
- Last Synced: 2025-01-28T19:17:29.371Z (8 months ago)
- Topics: cifar-10, image-classification, tensorflow2
- Language: Python
- Homepage: https://mpolinowski.github.io/docs/IoT-and-Machine-Learning/ML/2022-12-16-tf-cifar/2022-12-16
- Size: 688 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Tensorflow Image Classifier
### CIFAR-10
The [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html) dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images per class. There are 50000 training images and 10000 test images:

> cifar10_labels = ['0=airplane','1=automobile','2=bird','3=cat','4=deer','5=dog','6=frog','7=horse','8=ship','9=truck']
The dataset is divided into five training batches and one test batch, each with 10000 images. The test batch contains exactly 1000 randomly-selected images from each class. The training batches contain the remaining images in random order, but some training batches may contain more images from one class than another. Between them, the training batches contain exactly 5000 images from each class. You can download the [Keras dataset](https://github.com/keras-team/keras/tree/master/keras/datasets) by:
```bash
from tensorflow.keras import datasets
(train_images, train_labels), (test_images, test_labels) = datasets.cifar10.load_data()
```## Run
```bash
python main.py
...
Epoch 100/100
98/98 [==============================] - 4s 41ms/step - loss: 0.5412 - accuracy: 0.8101
313/313 [==============================] - 1s 2ms/step - loss: 0.7025 - accuracy: 0.7602
Test Accuracy: 0.760200023651123
```## Validation
Visually inspect the accuracy by printing random test predictions:

### Confusion Matrix
> `y-axis = predicted / x-axis = true`
In a perfect model (accuracy=100%) we would expect a diagonal line from the top left to the bottom right. Every prediction that does not end up on this line is a false prediction:

Most of the mistakes are based on falsely predicting:
* `4` (deer) in images of `2` (bird)
* `5` (dog) in images of `3` (cat)
* `3` (cat) in images of `5` (dog)In words: The model cannot distinguish between cats and dogs and should be trained on those a little longer. While birds are sometimes mistaken for deers but not vice-versa.
## Transfer Learning
`train-tf-cifar-10-image-classifier.py` generates weights at checkpoints during a trainings run. These weights can be used to retrain the model for a different problem. Or use them in detections `run-prediction.py`.