๐ฑ 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
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