All Projects → Helias → Car-Model-Recognition

Helias / Car-Model-Recognition

Licence: other
Car Model Recognition project

Programming Languages

python
139335 projects - #7 most used programming language
Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to Car-Model-Recognition

Chords.py
Neural networks applied in recognizing guitar chords using python, AutoML.NET with C# and .NET Core
Stars: ✭ 24 (-54.72%)
Mutual labels:  recognition
DecisionAmbiguityRecognition
Deep learning AI, that recognizes when are people uncertain
Stars: ✭ 16 (-69.81%)
Mutual labels:  recognition
tweet-music-recognizer
🎙️ Node.js Bot to identify songs in Twitter videos
Stars: ✭ 57 (+7.55%)
Mutual labels:  recognition
timeline
Timeline - A photo organizer
Stars: ✭ 39 (-26.42%)
Mutual labels:  recognition
Vehicle-Number-Plate-Reading
Read Vehicle Number Plate and store the data in a CSV file with date and time.
Stars: ✭ 47 (-11.32%)
Mutual labels:  recognition
etiketai
Etiketai is an online tool designed to label images, useful for training AI models
Stars: ✭ 63 (+18.87%)
Mutual labels:  recognition
Korean-OCR-Model-Design-based-on-Keras-CNN
Korean OCR Model Design(한글 OCR 모델 설계)
Stars: ✭ 34 (-35.85%)
Mutual labels:  recognition
ObjRecPoseEst
Object Detection and 3D Pose Estimation
Stars: ✭ 71 (+33.96%)
Mutual labels:  recognition
rutimeparser
Recognize date and time in russian text and return datetime.datetime.
Stars: ✭ 17 (-67.92%)
Mutual labels:  recognition
farm-animal-tracking
Farm Animal Tracking (FAT)
Stars: ✭ 19 (-64.15%)
Mutual labels:  recognition
SkeletonMatching
This repository implements skeleton matching algorithm.
Stars: ✭ 30 (-43.4%)
Mutual labels:  recognition
small model face recognition
针对移动端的人脸识别需求,训练测试一些相关的小模型实验。
Stars: ✭ 27 (-49.06%)
Mutual labels:  recognition
openface mass compare
An openface script that runs a REST server. Posted images are compared against a large dataset, and the most likely match is returned. Works with https://hub.docker.com/r/uoacer/openface-mass-compare/
Stars: ✭ 22 (-58.49%)
Mutual labels:  recognition
VideoRecognitionTracking
Real time object or face detection recognition and tracking in video. The Full end-to-end project.
Stars: ✭ 36 (-32.08%)
Mutual labels:  recognition
ner-d
Python module for Named Entity Recognition (NER) using natural language processing.
Stars: ✭ 14 (-73.58%)
Mutual labels:  recognition
SRLCD
fast loop closure detection (online visual place recognition) via saliency re-identification IROS 2020
Stars: ✭ 78 (+47.17%)
Mutual labels:  recognition
Identifying-Clothing-Attributes
Pretrained VGG-16 network as feature extractor for Object Recognition (Python, Keras, Scikit-Learn)
Stars: ✭ 22 (-58.49%)
Mutual labels:  recognition
Word-recognition-EmbedNet-CAB
Code implementation for our ICPR, 2020 paper titled "Improving Word Recognition using Multiple Hypotheses and Deep Embeddings"
Stars: ✭ 19 (-64.15%)
Mutual labels:  recognition
recognition-text
A recognition-text application which recognize any text from an image with 98% to 100% accuracy. Gave support for 92 languages and translate your recognized text to 6 supported languages.
Stars: ✭ 22 (-58.49%)
Mutual labels:  recognition
TensorFlow-Powered Robot Vision
No description or website provided.
Stars: ✭ 34 (-35.85%)
Mutual labels:  recognition

Car Model Recognition

This is a university project for the course "Computer Vision". This project consists of a classifier of a car model.

Requirements

  • Python3
  • numpy
  • pytorch
  • torchvision
  • scikit-learn
  • matplotlib
  • pillow
  • torch (pytorch)
  • torchvision

You can install the requirements using:

pip3 install -r requirements.txt

Troubleshooting: if you get some errors about pytorch or torchvision install use sudo to install it.

Usage

First, if you have no resnet152 model trained and you need from scratch to do it you need to:

  • download dataset
  • preprocess the dataset
  • train the model

Afterward you can try a new sample.

Download dataset

I suggest using VMMRdb as a dataset, it's free and full of labeled images for car model recognition instead of detection (most datasets are for this).

So download the dataset, select some models and put the directory model in the dataset folder, any directory in "dataset" will be considered a new class.

If you need more data for your project you can also add the followings dataset:

Handle CSV training, testing, validation and dataset structure

The dataset structure should be like this:

dataset / classes / file.jpg

For example, we have 3 classes: honda_civic, nissan and ford:

dataset_dir / honda_civic / file1.jpg
dataset_dir / honda_civic / file2.jpg
....
dataset_dir / nissan / file1.jpg
dataset_dir / nissan / file2.jpg
....
dataset_dir / ford / file1.jpg
dataset_dir / ford / file2.jpg
...
and so on.

The "dataset_dir" is the IMAGES_PATH in config.py. The python script will save the classes in a dict() named num_classes, like this:

num_classes = {
  "honda_civic": 1,
  "nissan": 2,
  "ford": 3
}

This conversion happens automatically when you just add a directory inside the IMAGES_PATH, if you add tomorrow a new car, like, FIAT, the program will add automatically to the classes, just pay attention to the order of the classes inside num_classes and the related training, testing and validation CSV files.

The file training, testing, and validation (CSV) should contain only two columns: FILE_NAME, NUM_CLASS

Example of CSV file:

file1.jpg, 1
file2.jpg, 1
file1.jpg, 2
file2.jpg, 2
file1.jpg, 3
file2.jpg, 3

Anyway, this paragraph is only for your info, the CSV files are automatically generated by the preprocessing phase explained in the following paragraph.

Preprocess the dataset

You have to generate the CSV files and calculate the mean and standard deviation to apply a normalization, just use the -p parameter to process your dataset so type:

$ python3 main.py -p

Train the model

Short introduction

Before the training process, modify the EPOCHS parameter in config.py, usually with 3 classes 30-50 epochs should be enough, but you have to see the results_graph.png file (when you finish your training with the default epochs parameter) and check if the blue curve is stable.

An example of the graph could be the following: graph results - Car Model Recognition

After 45-50 epochs (number bottom of the graph), the blue curve is stable and does not have peaks down. Moreover, the testing curve (the orange one) is pretty "stable", even with some peaks, for the testing is normal that the peaks are frequently.

Train the model

To train a new model resnet152 model you can run the main.py with the -t parameter, so type:

$ python3 main.py -t

The results will be saved in the results/ directory with the F1 score, accuracy, confusion matrix, and the accuracy/loss graph difference between training and testing.

Try a new sample

Try to predict a new sample you can just type:

python3 main.py -i path/file.jpg

I used this project to predict 3 models:

  • Nissan Altima
  • Honda Civic
  • Ford Explorer

I selected all 2000-2007 images from VMMRdb, so I downloaded the full dataset and choose the 2000-2007 images and put them into one directory per class (so I had 3 directories named "Ford Explorer", "Nissan Altima", "Honda Civic" in dataset folder).

Troubleshooting

- Size mismatch

Error:

RuntimeError: Error(s) in loading state_dict for ResNet:
size mismatch for fc.weight: copying a param with shape torch.Size([1000, 2048]) from checkpoint, the shape in current model is torch.Size([3, 2048]).
size mismatch for fc.bias: copying a param with shape torch.Size([1000]) from checkpoint, the shape in current model is torch.Size([3]).

Solution: you probably need to re-train your neural network model because you are using the wrong model for your data and classes, so don't use some pretrained model but train a new neural network with your data/classes.

- CUDA out of memory

Error:

######### ERROR #######
CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 1.96 GiB total capacity; 967.98 MiB already allocated; 25.94 MiB free; 48.02 MiB cached)


######### batch #######
[images.png, files_path.png, ....]

Traceback (most recent call last):
  File "main.py", line 227, in <module>
    train_model_iter("resnet152", resnet152_model)
  File "main.py", line 215, in train_model_iter
    model, loss_acc, y_testing, preds = train_model(model_name=model_name, model=model, weight_decay=weight_decay)
  File "main.py", line 124, in train_model
    epoch_loss /= samples
ZeroDivisionError: division by zero

Solution: you're using CUDA, probably, the memory of your GPU is too low for the batch size that you're giving in input, try to reduce the BATCH_SIZE from config.py or use your RAM instead of GPU memory if you have more, so put USE_CUDA=false in config.py.

- "My model does not recognize exactly the class"

Probably you have to increase the DATA PER CLASS in your dataset, a good number of images per class could be 10k (10 000 items), but with only 3 classes you can even use 2k-5k items per class. Another parameter that affects hugely the training is the EPOCHS, try to at least 50 epochs if you are not satisfied with the results.

You are not the only one to get these troubles, check the issue #3 to get a full conversation of this solutions/troubleshooting.

Credits

Contribute

You can help us opening a new issue to report a bug or a suggestion

or you can donate to support us

Donate PayPal

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].