ID: 5fa3fedec2a4984b34ef0c63

Car color recognition with YOLOv4

by Spectrico

Car color recognition with YOLOv4 object detector

License: MIT License

Tags: Tensorflow

 Model stats and performance
Framework Tensorflow
OS Used Windows
Inference time in seconds per sample.

Performance data is not available.


Car color recognition example with YOLOv4 object detector


A Python example for using Spectrico's car color classifier. It consists of an object detector for finding the cars, and a classifier to recognize the colors of the detected cars. The object detector is an implementation of YOLOv4 (OpenCV DNN backend). YOLOv4 weights were downloaded from AlexeyAB/darknet. The classifier is based on MobileNet v3 (TensorFlow backend). It recognizes 14 colors: black, white, grey, silver, blue, red, green, brown, beige, golden, bordeaux, yellow, orange, and violet. Online web demo: Vehicle Make and Model Recognition

Object Detection and Classification in images

This example takes an image as input, detects the cars using YOLOv4 object detector, crops the car images, resizes them to the input size of the classifier, and recognizes the color of each car. The result is shown on the display and saved as output.jpg image file.


Use --help to see usage of

$ python --image cars.jpg
$ python [-h] [--yolo MODEL_PATH] [--confidence CONFIDENCE] [--threshold THRESHOLD] [--image]

required arguments:
  -i, --image              path to input image

optional arguments:
  -h, --help               show this help message and exit
  -y, --yolo MODEL_PATH    path to YOLO model weight file, default yolo-coco
  --confidence CONFIDENCE  minimum probability to filter weak detections, default 0.5
  --threshold THRESHOLD    threshold when applying non-maxima suppression, default 0.3


  • python
  • numpy
  • tensorflow
  • opencv
  • yolov4.weights must be downloaded from and saved in folder yolov4


The settings are stored in python file named

model_file = "model-weights-spectrico-car-colors-recognition-mobilenet_v3-224x224-180420.pb"
label_file = "labels.txt"
input_layer = "input_1"
output_layer = "Predictions/Softmax/Softmax"
classifier_input_size = (224, 224)

model_file is the path to the car color classifier classifier_input_size is the input size of the classifier label_file is the path to the text file, containing a list with the supported colors


The examples are based on the tutorial by Adrian Rosebrock: YOLO object detection with OpenCV

The YOLOv4 object detector is from:

  title={YOLOv4: Optimal Speed and Accuracy of Object Detection},
  author={Bochkovskiy, Alexey and Wang, Chien-Yao and Liao, Hong-Yuan Mark},
  journal={arXiv preprint arXiv:2004.10934},

The car color classifier is based on MobileNetV3 mobile architecture: Searching for MobileNetV3

  title={Searching for mobilenetv3},
  author={Howard, Andrew and Sandler, Mark and Chu, Grace and Chen, Liang-Chieh and Chen, Bo and Tan, Mingxing and Wang, Weijun and Zhu, Yukun and Pang, Ruoming and Vasudevan, Vijay and others},
  booktitle={Proceedings of the IEEE International Conference on Computer Vision},

Author View Profile

Sofia, Bulgaria
Level 9 8800 XP

204 Profile

User Reviews

0 total ratings

Model has not been reviewed yet.

More by this user | Show All

Also checkout...