A basic image classification project developed in Python as part of DecodeLabs Artificial Intelligence Project 4.
This project demonstrates image classification using a pre-trained deep learning model.
The system uses MobileNetV2, a model trained on the ImageNet dataset, to analyze a user-selected image and identify the most likely objects or categories present in the image.
The program allows the user to select an image from their computer and then displays the top five predictions along with their confidence scores.
- Load a pre-trained image classification model
- Allow the user to select an image
- Preprocess the selected image
- Use MobileNetV2 to classify the image
- Display the top five predictions
- Display the highest-confidence prediction
- Show the confidence score for the final prediction
- Python
- TensorFlow
- NumPy
- Matplotlib
- Tkinter
- MobileNetV2
- ImageNet
The project uses MobileNetV2 with pre-trained ImageNet weights.
MobileNetV2 is used to classify images into categories learned from the ImageNet dataset.
The model processes the selected image and returns the most likely classifications.
Select Image
↓
Load Image
↓
Resize Image to 224 × 224
↓
Convert Image to Array
↓
Preprocess Image
↓
MobileNetV2 Model
↓
Generate Predictions
↓
Get Top 5 Predictions
↓
Display Final Prediction
For each selected image, the program displays:
- Top 5 predicted categories
- Confidence percentage for each prediction
- Final prediction
- Confidence score of the final prediction
For the test image used during development, the model produced:
1. book_jacket : 34.25%
2. doormat : 20.77%
3. bottlecap : 4.84%
4. packet : 3.93%
5. carton : 2.46%
Prediction : book_jacket
Confidence : 34.25%
Here is the AI Image Classification system running in the terminal:
pip install tensorflow numpy matplotlibpython image_classifier.pyA file-selection window will appear.
Choose a .jpg, .jpeg, or .png image.
The program will then analyze the image and display the top five predictions.
========================================
AI IMAGE CLASSIFICATION
========================================
Loading MobileNetV2 Model...
Model Loaded Successfully!
Please select an image...
========================================
TOP 5 PREDICTIONS
========================================
1. book_jacket : 34.25%
2. doormat : 20.77%
3. bottlecap : 4.84%
4. packet : 3.93%
5. carton : 2.46%
========================================
FINAL PREDICTION
========================================
Prediction : book_jacket
Confidence : 34.25%
The predictions are generated by a pre-trained model and represent the model's confidence in the available ImageNet categories. The highest-confidence prediction is not guaranteed to be the correct interpretation of every image.
