實驗結果顯示,本研究共評估 30 種主流視覺骨幹架構,最佳模型(Swin-B,86.8M 參數)達到 0.711 的逐樣本完全匹配率(Subset Accuracy,多標籤任務最嚴格的整體指標)與 0.808 的 Macro F1;效率最優方案(ViT-Small,21.7M 參數)在單張 NVIDIA RTX 3060(12GB)上以不足 10 分鐘的訓練時間達到 Subset Accuracy 0.636 與 Macro F1 0.785。若以較寬鬆的逐標籤正確率(per-label Accuracy,即 1 − Hamming Loss)衡量,兩者分別為 95.2% 與 94.0%。對照實驗進一步證明,相較於僅以 sigmoid 輸出各標籤機率的扁平化基線模型,本架構透過訓練期間的階層式損失函數設計與「約束感知推論引擎 (Constraint-Aware Inference Engine)」的後處理機制,將邏輯違規率由基線的 2.8% 降至 0%;此邏輯一致性保障伴隨可量化的取捨:HCCH 的 Subset Accuracy 較扁平化基線低 0.055(0.636 vs 0.691),逐標籤正確率低 0.60 個百分點。結果證實,本方法在輸出邏輯一致性上具有決定性優勢,為產業提供了一個具備語意理解、高度可配置且邏輯嚴謹的自動化檢測方案。;Coffee is one of the most globally traded agricultural commodities, with the specialty coffee sector imposing the most stringent quality standards. However, current defect inspection processes rely heavily on manual selection, suffering from low efficiency and inconsistent standards. Although previous studies have attempted to incorporate deep learning for visual recognition, most approaches employ coarse binary classification or flat multi-label classification lacking semantic structure, thereby failing to meet industrial demands for fine-grained defect characterization.
To address these challenges, this thesis proposes a Vision Transformer (ViT)-based Hierarchical Conditional Classification Head (HCCH) architecture, which explicitly encodes ontology constraints into the model design through grouped output structures and gating mechanisms, paired with a configurable training pipeline that allows the label taxonomy to be adjusted without modifying the model architecture.
Experimental results, based on evaluating 30 mainstream backbone architectures, demonstrate that the best-performing model (Swin-B, 86.8M parameters) achieves a Subset Accuracy (the strictest exact-match metric for multi-label tasks) of 0.711 and a Macro F1 of 0.808, while the efficiency-optimized variant (ViT-Small, 21.7M parameters) attains a Subset Accuracy of 0.636 and a Macro F1 of 0.785 within 10 minutes of training on a single NVIDIA RTX 3060 (12GB); under the more lenient per-label accuracy (defined as 1 − Hamming Loss), the two models reach 95.2% and 94.0%, respectively. A controlled comparison further shows that, relative to a flat baseline model that outputs label probabilities directly via sigmoid, the proposed architecture—combining hierarchical loss functions during training with the post-processing mechanism of the "Constraint-Aware Inference Engine"—reduces the logical violation rate from 2.8% to 0%; this guarantee of logical consistency comes with a measurable trade-off, as HCCH trails the flat baseline by 0.055 in Subset Accuracy (0.636 vs. 0.691) and by 0.60 percentage points in per-label accuracy. These results confirm that the proposed method provides a decisive advantage in output logical consistency, offering the industry an automated inspection solution that is semantically aware, highly configurable, and logically rigorous.