This repository provides state-of-the-art PyTorch implementations for camouflaged object detection using three architectures: IFBO-Net, SegNet, and UNet.
Adjust the num_epochs Accordingly
Lets First of All clone the repository: git clone https://github.com/Sarthak6o1/Camouflaged-Object-Detection-with-IFBO_Net-Model.git
-
Mount Google Drive (for Colab):
from google.colab import drive drive.mount('/content/drive')
-
Prepare COD10K dataset:
- Download from Kaggle:
https://www.kaggle.com/datasets/getcam/cod10k - Unzip into:
/content/drive/MyDrive/COD10K/(or adjust paths indataset_loader_cod10k.py)
- Download from Kaggle:
-
Run training and testing:
# For IFBO-Net python IFBO_Net_model_train.py python IFBO_Net_model_test.py # For SegNet python SegNet_model_train.py python SegNet_model_test.py # For UNet python UNet_model_train.py python UNet_model_test.py
├── IFBO_Net_architecture.py # IFBO-Net model definition ├── IFBO_Net_metrics.py # Metrics for IFBO-Net ├── IFBO_Net_model_train.py # Training pipeline (Adam optimizer) ├── IFBO_Net_model_test.py # Evaluation pipeline ├── IFBO_Net_original.py # Initial implementation ├──SARNet_architecture.py #Implemented the SARNet nodel architecture use the Similar metrics and training ,testing files of SegNet_metrics.py SegNet_model_train.py SegNet_model_test.py ├── SegNet_architecture.py # SegNet definition ├── SegNet_metrics.py # SegNet metrics ├── SegNet_model_train.py # Training pipeline (SGD optimizer) ├── SegNet_model_test.py # Evaluation pipeline ├── SegNet_Original.py # Initial Implementation ├── UNet_architecture.py # UNet definition ├── UNet_metrics.py # UNet metrics ├── UNet_model_train.py # Training pipeline (SGD + scheduler) ├── UNet_model_test.py # Evaluation pipeline ├── UNet_original.py # Initial Implementation ├── dataset_loader_cod10k.py # DataLoader & transforms (Resize 256×256) ├── cod10k_visualizer.py # Initial image visualizer (raw images & masks) ├── Mounting_drive.py # Utility for Google Drive mounting ├── requirements.txt # Python dependencies └── README.md # This file - Transforms: All images and masks are resized to
(256, 256)and converted to tensors. - Datasets:
COD10KDatasethandles reading image-mask pairs fromTrainandTestfolders. - DataLoader: Batches data (
batch_size=8), shuffles train set, usesnum_workers=2.
transform = transforms.Compose([ transforms.Resize((256, 256)), transforms.ToTensor() ]) mask_transform = transforms.Compose([ transforms.Resize((256, 256)), transforms.ToTensor() ]) train_loader = DataLoader(...) test_loader = DataLoader(...)- cod10k_visualizer.py provides an initial image visualization of raw images and corresponding ground-truth masks using matplotlib.
- For prediction heatmaps and advanced plotting, refer to your custom evaluation scripts.
Each training script follows this workflow:
- Setup: Check for CUDA, instantiate model on
device. - Optimizer & Scheduler (UNet, SegNet):
- SGD with momentum (0.9), weight decay (1e-4).
StepLRscheduler (step_size=10, gamma=0.1).- IFBO-Net uses Adam (lr=0.001).
- Loss Function:
- IFBO-Net:
BCEloss. - SegNet & UNet:
BCEDiceLoss(combines BCE + Dice).
- IFBO-Net:
- Training Loop:
for epoch in range(num_epochs): model.train() for images, masks in train_loader: outputs = model(images) loss = criterion(outputs, masks) optimizer.zero_grad() loss.backward() torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0) optimizer.step() scheduler.step() # if using scheduler
- Loss: BCE, Dice
- Accuracy: Pixel-level accuracy
- MAE: Mean absolute error
- S-measure (Sα): Structural similarity
- E-measure (Eϕ): Enhanced alignment
- Fβw: Weighted F-measure
- Dice Coefficient: Overlap measure
- IoU: Intersection over Union
- COD10K Dataset
- Zhao et al., EGNet: Edge Guidance Network for Salient Object Detection, ICCV 2019.
- Long et al., Fully Convolutional Networks, CVPR 2015.
- Camouflaged object detection with integrated feature fusion and boundary optimization Bin Ge1 · Xiaolong Peng1 · Chenxing Xia1
· Hailong Chen1