# Grading Methods

After thoroughly producing the dataset of images, it is time to establish additional definitions that will determine the AI model's behavior. An AI model is comprised of two main components: a .onnx file, which contains the weights that will classify the images, and a `.json` file, which describes the model and its parameters. The process of creating an AI model involves not only defining the classes of defects but also setting up the grading system associated with the model. Follow the steps below to create the definitions for the grading methods:

1. **Name the desired grading method.**
2. **Number the classes starting from zero.**
3. **Define the relationship between seed amount and the value of defects for each class,** creating the columns number of seeds, value, and equivalent defect. For example, considering the SCA methodology, a full black defect is counted as 1 seed per defect, resulting in 1 equivalent defect per seed classified as such. An immature seed is counted as 5 seeds per defect, resulting in 0.2 equivalent defects per seed classified as such.
4. **Establish inverse relationships** for certain classes, if applicable. For instance, a single stone occurrence accounts for 5 equivalent defects.
5. **Include sub-classifications related to size**, if necessary. In cases where grading systems are divided into size-related sub-classifications, describe these intermediary divisions and the rules for size definition, related to area or screen size. Subdivided classes should have the same class index.
6. **Classes that are not defective should be classified as value o.**
7. Repeat the above process for as many grading systems as desired. **Ensure the table includes all classes for each grading method.**

### Example of COB Methodology

Below is an example of how to structure the COB methodology for incorporation into the AI model. This includes naming the grading method, naming the classes, defining the relationship between seed amount and defect value, and finally, its resulting equivalence of defects.

#### Classificação Oficial Brasileira (COB)

<table><thead><tr><th width="111">Class</th><th>Defect Name</th><th width="111">Seeds</th><th width="82">Value</th><th>Equivalent Defects</th></tr></thead><tbody><tr><td>0</td><td>Black</td><td>1</td><td>1</td><td>1</td></tr><tr><td>1</td><td>Broken</td><td>5</td><td>1</td><td>0.2</td></tr><tr><td>2</td><td>Floater</td><td>5</td><td>1</td><td>0.2</td></tr><tr><td>3</td><td>Fox Bean</td><td>1</td><td>0</td><td>0</td></tr><tr><td>4.1</td><td>Husk Medium</td><td>3</td><td>1</td><td>0.33</td></tr><tr><td>4.2</td><td>Husk Large</td><td>1</td><td>1</td><td>1</td></tr><tr><td>5</td><td>Immature</td><td>5</td><td>1</td><td>0.2</td></tr><tr><td>6</td><td>Insect Damaged</td><td>5</td><td>1</td><td>0.2</td></tr><tr><td>7</td><td>Ok</td><td>1</td><td>0</td><td>0</td></tr><tr><td>8</td><td>Parchment</td><td>2</td><td>1</td><td>0.5</td></tr><tr><td>9</td><td>Pod</td><td>1</td><td>1</td><td>1</td></tr><tr><td>10.1</td><td>Stones Small</td><td>1</td><td>1</td><td>1</td></tr><tr><td>10.2</td><td>Stones Medium</td><td>1</td><td>2</td><td>2</td></tr><tr><td>10.3</td><td>Stones Large</td><td>1</td><td>5</td><td>5</td></tr><tr><td>11</td><td>Shell</td><td>3</td><td>1</td><td>0.33</td></tr><tr><td>12</td><td>Sour</td><td>1</td><td>2</td><td>0.5</td></tr></tbody></table>
