File size: 3,400 Bytes
5e83b31
 
 
b6fdf6a
097c12b
b6fdf6a
 
 
 
 
766fce4
 
b6fdf6a
 
 
3c10a49
b6fdf6a
766fce4
b6fdf6a
 
1e19a95
b6fdf6a
 
3c10a49
 
 
6e6e2d0
b6fdf6a
1e19a95
 
 
 
766fce4
6e6e2d0
 
 
b6fdf6a
 
 
 
 
01c14fd
6e6e2d0
b6fdf6a
 
 
 
3c10a49
b6fdf6a
 
6e6e2d0
 
b6fdf6a
 
 
 
 
6e6e2d0
 
 
b6fdf6a
6e6e2d0
b6fdf6a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
license: mit
---

# Model Card for lego-technic-sorting-model
Classification of lego technic pieces under basic room lighting conditions

## Model Details

### Model Description
CNN designed from the ground up, without using a pre-trained model to classify images of lego pieces into 7 categories. <br>
Achieved a 93% validation accuracy

- **Developed by:** Aveek Goswami, Amos Koh
- **Funded by [optional]:** Nullspace Robotics Singapore
- **Model type:** Convolutional Neural Network (CNN)

### Model Sources

- **Repository:** https://github.com/magichampz/lego-sorting-machine-ag-ak


## Uses
The files in the create-model folder are meant to be used on your own computer.
You can train your own deep learning model using your own data and  test this model on your computer using testing-tflite-model.py on a single image.
The model was trained on Google Colab, so create_training_data_array.py was used to creata a numpy array file to upload data in the form of a numpy array to Google Colab. 
After transfering the tflite model to your Pi, you can then run the image classification file in the raspberry-pi folder to detect and classify lego pieces in real time.

Example of real time object detection and classification:
![image/gif](https://cdn-uploads.huggingface.co/production/uploads/652dc3dab86e108d0fea458c/E7UZXLWPvU_39cxrF49jD.gif)


## Bias, Limitations and Recommendations
The images of the lego pieces used to train the model were taken in room lighting conditions, illuminated with a torchlight. <br>
To use the model, would recommend  trying to recreate the conditions and achieve photographs with a similar lighting. <br>
Otherwise, it might be better to retrain the model with a new dataset of images corresponding to your lighting conditions
<!-- This section is meant to convey both technical and sociotechnical limitations. -->

## Training Details

### Training Data
- **Data:** https://huggingface.co/datasets/magichampz/lego-technic-pieces <br>
More images can be taken by editing the motion_detection_and_image_classification.py script.

<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->

### Training Procedure 
The model was trained using the GPU's available on Google Colab. The jupyter notebook loaded the data from a npy file (in the dataset card), which contained all the images as well as their category labels.
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

#### Preprocessing
Images were normalized before being fed into the model. Their contrast was also increased using the increase_contrast_more function defined in the notebook attached.


## Evaluation

### Results
Our model was trained with 6000 images across 7 different categories of lego technic pieces, split into a 80/20 train/test split. <br>
It achieved 93% testing accuracy and graphs of the accuracy and loss are shown below. <br>
A confusion matrix was also plotted to visualize the performance of the classification algorithm. It depicts the count value of true versus false predictions across each category.

![Unknown-5](https://user-images.githubusercontent.com/91732309/190358182-58fa5671-263d-490b-8f54-616cb2daf764.png)