# Machine Learning-Based Highway Truck Commodity Classification Using Logo Data
## 3 Methodology
### Integrated Logo Model  
The main advantage of the text-based approach is its robustness when the logo is mostly text. Though the model outputs incorrect or incomplete text predictions in some challenging traffic scenarios, it works well in most cases. The errors from the partially correct predictions can be corrected by finding the most similar company name using approximate string matching algorithms. This approach does not work when the logo consists essentially of non-text images.  
The image-based approach has the potential to cover scenarios where the text information is not available on truck bodies or the text-based approach fails to detect any texts from trucks. Due to the high recall of the universal logo detector, we are likely to get a good subset from all potential logos. However, the accuracy of this approach may not be high as compared to a text-based approach when only logos that consist of text are present.  
We now discuss potential approaches that combine both of these approaches. Let the set of detected bounding boxes from the text-based approach be denoted as \(\textbf{B}_{\text{text}}=B_{t}^{k}\), \(k=1,2,\ldots,N_{\text{text}}\), where \(N_{\text{text}}\) denotes the number of detections from the text-based model. Each \(B_{t}^{k}\) is associated with two confidence scores, namely the detection score (denoted as \(S_{t}^{0}\)), which measures how likely the detected region contains text, and the matching score (denoted as \(S_{t}^{1}\)), which measures the similarity between the detected text with the matched text in defined logo classes. Similarly, for the image-based approach, the set of detected bounding boxes is denoted as \(\textbf{B}_{\text{image}}=B_{t}^{k},k=1,2,\ldots,N_{\text{image}}\); each \(B_{t}^{k}\) is associated with one matching score (denoted as \(S_{i}\)), which measures the similarity between the detected region and the matched one in the collected logo gallery. There are two possible approaches for integrating these models:  
1. Text-focused Approach: If both text-based and image-based models detect a logo in the same location, (i.e., \(\text{IoU}(B_{t}^{m},B_{t}^{n})>0.3\)), we rely on the label from text-based model;
2. Combined Approach: We train a decision tree classifier with four output classes indicating whether to use the text-based model's result, the image-based model's result, neither or both (corresponding to 1, 2, 0, and 3). Ambiguity arises at the testing time when the image-based and text-based models give different predicted labels, while the classifier outputs 3. We resolve the issue by preferring the text-based model's result in this case.  
The later experimental evaluation shows that the first integration approach performs slightly better on our collected testing dataset. This is potentially because it consists of more text-based logos. The second approach has a better generalization ability since it can automatically learn the parameters that can combine the outputs of the two approaches. It can also be modified accordingly to adapt to a dataset with different text versus non-text distributions. A user can choose either one of the two approaches, based on the characteristics of the target dataset.