--- license: apache-2.0 tags: - image-classification - x-ray - customs - smuggling-detection - sonar language: - ar - en --- # 🔱 SONAR AI - Customs X-Ray Inspection Models ## Dr. Abbas Fadel Jassim | 2026 > AI-powered customs inspection system for X-ray cargo scanning --- ## 📊 Models Performance Summary | # | Model | Task | Classes | F1 Score | Architecture | |---|-------|------|---------|----------|-------------| | 1 | **Classification** | تصنيف البضاعة | 43 | **94.2%** | Swin-V2 Tiny | | 2 | **Concealment** | كشف الإخفاء | 2 | **98.4%** | Swin-V2 Tiny | | 3 | **Risk Assessment** | تقييم الخطورة | 5 | **97.3%** | DaViT Tiny | --- ## 🔍 Model 1: Classification (43 cargo categories) **Task:** Classify X-ray images into 43 different cargo types | Model | Params | Accuracy | F1 Score | |-------|--------|----------|----------| | 🏆 **Swin-V2 Tiny** | 27.6M | 94.2% | **94.1%** | | 🥈 **DaViT Tiny** | 27.6M | 94.2% | **94.1%** | ### Per-Class Performance (Swin-V2): | Category | Precision | Recall | F1 | Samples | |----------|-----------|--------|-----|---------| | appliances | 98.2% | 98.2% | **98.2%** | 57 | | auto_parts | 92.6% | 94.3% | **93.5%** | 53 | | bags | 100% | 100% | **100%** | 12 | | banana | 100% | 100% | **100%** | 40 | | batteries | 100% | 88.9% | **94.1%** | 9 | | beverages | 71.4% | 100% | **83.3%** | 10 | | cables | 100% | 94.4% | **97.1%** | 18 | | canned_food | 92.0% | 79.3% | **85.2%** | 29 | | ceramic | 97.5% | 97.5% | **97.5%** | 40 | | chemicals | 100% | 94.9% | **97.4%** | 39 | | cleaning | 91.7% | 91.7% | **91.7%** | 24 | | clothes | 91.8% | 96.3% | **94.0%** | 81 | | cooking_oil | 76.9% | 100% | **87.0%** | 10 | | cosmetics | 100% | 94.1% | **97.0%** | 17 | | electronics | 92.7% | 87.9% | **90.3%** | 58 | | fruits | 85.7% | 100% | **92.3%** | 6 | | furniture | 97.1% | 96.6% | **96.8%** | 174 | | glass | 95.2% | 100% | **97.6%** | 20 | | kitchenware | 100% | 100% | **100%** | 2 | | lubricants | 92.3% | 100% | **96.0%** | 12 | | machinery | 87.5% | 95.5% | **91.3%** | 66 | | meat | 92.3% | 92.3% | **92.3%** | 13 | | medical | 100% | 100% | **100%** | 3 | | milk | 98.4% | 98.4% | **98.4%** | 62 | | motorcycle | 100% | 66.7% | **80.0%** | 6 | | nuts | 92.9% | 100% | **96.3%** | 26 | **Training:** 30 epochs, AdamW (lr=1e-4), CosineAnnealing, Albumentations augmentation --- ## 🔍 Model 2: Concealment Detection (match vs no_match) **Task:** Detect hidden/smuggled items in X-ray containers | Model | Params | Accuracy | F1 Score | |-------|--------|----------|----------| | 🏆 **Swin-V2 Tiny** | 27.6M | 98.4% | **98.4%** | | 🥈 **DaViT Tiny** | 27.6M | 98.4% | **98.4%** | | 🥉 **EVA-02 Tiny** | 5.5M | 97.8% | **97.8%** | | 4️⃣ **MaxViT Tiny** | 30.4M | 96.7% | **96.8%** | ### Classes: - **match:** Container contents match declaration (6,348 images) - **no_match:** Concealed/smuggled items detected (702 images) --- ## ⚠️ Model 3: Risk Assessment (5 levels) **Task:** Assess risk level of container cargo | Model | Params | Accuracy | F1 Score | |-------|--------|----------|----------| | 🏆 **DaViT Tiny** | 27.6M | 97.2% | **97.3%** | | 🥈 **Swin-V2 Tiny** | 27.6M | 97.2% | **97.2%** | ### Risk Levels: | Level | Name (AR) | Name (EN) | Samples | F1 Score | |-------|-----------|-----------|---------|----------| | 0 | آمن | Safe | 6,355 | **99.1%** | | 1-2 | منخفض | Low | 5 | ⚠️ Limited | | 3 | متوسط | Medium | 387 | **79.5%** | | 4 | عالي | High | 297 | **84.5%** | | 5 | حرج | Critical | 6 | ⚠️ Limited | **Note:** Low and Critical levels have very few training samples. --- ## 📁 Files ``` SONAR-AI-Models/ ├── concealment/ │ ├── best_swinv2.pth (110 MB, 98.4% F1) │ ├── best_davit.pth (110 MB, 98.4% F1) │ ├── best_eva02.pth (22 MB, 97.8% F1) │ └── best_maxvit.pth (122 MB, 96.8% F1) ├── classification/ │ ├── best_swinv2_43cls.pth (110 MB, 94.1% F1) │ └── best_davit_43cls.pth (110 MB, 94.1% F1) ├── risk/ │ ├── best_swinv2_risk.pth (110 MB, 97.2% F1) │ └── best_davit_risk.pth (110 MB, 97.3% F1) └── results/ ├── classification_cm.png ├── classification_training.png ├── risk_cm.png └── risk_training.png ``` ## 🛠️ Usage ```python import timm, torch from torchvision import transforms from PIL import Image # Load model model = timm.create_model('swinv2_tiny_window8_256', pretrained=False, num_classes=43) ckpt = torch.load('classification/best_swinv2_43cls.pth', map_location='cpu') model.load_state_dict(ckpt['model_state_dict']) model.eval() # Inference tf = transforms.Compose([ transforms.Resize((256, 256)), transforms.ToTensor(), transforms.Normalize([0.485,0.456,0.406], [0.229,0.224,0.225]) ]) img = tf(Image.open('xray.jpg').convert('RGB')).unsqueeze(0) with torch.no_grad(): pred = model(img).argmax(1).item() ``` ## 📜 License Apache 2.0 ## 👨‍💻 Author **Dr. Abbas Fadel Jassim** - 2026