Featured image of post Machine Vision Meets Mountain Vistas: Classifying Cars on the Dragon’s Tail.

Machine Vision Meets Mountain Vistas: Classifying Cars on the Dragon’s Tail.

Dive into the world of machine learning as we explore the captivating automobile snapshots from the Tail of The Dragon. Utilizing the EfficientNetB1 neural network, we've achieved an impressive 95% accuracy in classifying a diverse range of automobiles.

Intro

The best projects often arise from simple curiosities through exploring the world around us. I love finding questions that few people, if anyone, have asked before. On a family trip to the Smoky Mountains, nestled between North Carolina and Tennessee, I found myself enamored by the Tail of the Dragon. With its 318 curves over an 11-mile stretch, this road is a paradise for motor enthusiasts.

Smoky Mountains

Businesses along the road capitalize on its popularity, snapping photos of passing vehicles and selling them to drivers online. I noticed the manual effort going into sorting every one of these images into categories like Porches, Mustangs, and Miatas, and in that I saw an opportunity: could machine learning automate this process?

Data Collection

Using Python’s BeautifulSoup for web scraping and Requests for image downloading, I compiled a dataset of around 500,000 images spanning 160 categories from the website. After manually merging categories together, I narrowed down to nine categories, BMW, Corvette/Camaro, Honda/Acura, Jeep, Miata, Mini, Mustang, Porsche, and VW/Audi. Some models or manufacturers are combined because that is how they are manually sorted in the website, Each group was filtered down to 30,000 images, culminating in a total dataset of 270,000 images. The data was split with an 80:20 ratio for training and validation.

Downloaded Images

Data Preprocessing

Given the variability in image compositions, data augmentation, modifying of images to improve performance, was key. I employed techniques like horizontal flips, rotations, zooms, and shears. Additionally, images were rescaled to have pixel values between 0 and 1 and resized to 300x200.

Processed Images

Model Training

Inspired by Albion Krasniqi’s research, I used the EfficientNetB1 neural network with pretrained ImageNet weights. Using the Adam optimizer and the categorical crossentropy loss function, the model was trained over 5 epochs.

Model Evaluation

The results were promising, with the model achieving high precision and recall for each category. The confusion matrix indicated occasional misclassifications, such as Miatas sometimes being identified as Corvettes or Jeeps.

precisionrecallf1-scoresupport
bmw0.940.920.936000
corvette0.980.910.956000
honda0.920.950.936000
jeep0.991.000.996000
miata0.990.900.956000
mini0.990.990.996000
mustang0.930.960.946000
porsche0.920.950.936000
vw0.900.970.936000
accuracy0.9554000
macro avg0.950.950.9554000
weighted avg0.950.950.9554000

Confusion Matrix Confusion Matrix Normalized

Taking a look at 100 examples of misclassifications revealed the model struggled with heavily modified cars, challenging lighting conditions, black cars, rare models, and cars in unusual angles, distances, or strange composition.

Incorrect Classifications 1

Incorrect Classifications 1

Incorrect Classifications 1

Incorrect Classifications 1

Conclusion

With an overall accuracy of 95%, the model presents a promising solution to automate the classification of car photos from the Tail of the Dragon. While manual checks post-classification would be necessary initially, continuous optimization would only enhance the model’s efficiency. Future research could experiment with different pre-trained models or delve into designing a bespoke model.

Thank you for joining me on this fascinating journey through machine vision and mountain vistas!