This project builds a clean and practical image classifier for the Intel Natural Scenes dataset using PyTorch and transfer learning.
The goal is simple: take a strong pretrained model, adapt it to a 6-class scene-recognition task, and train it in a stable, structured way.
I kept everything focused on clarity, reproducibility, and solid engineering habits.
The Intel Natural Scenes dataset contains six scene types:
- buildings
- forest
- glacier
- mountain
- sea
- street
The dataset comes pre-split into seg_train, seg_test, and seg_pred.
Project structure expects the dataset to be placed under:
data/raw/intel/
seg_train/
seg_test/
seg_pred/ # optional, for inference
Each folder contains subfolders by class.
I used ResNet18 pretrained on ImageNet as the feature extractor.
The training process happens in two phases:
- Freeze the entire ResNet backbone
- Train only the final fully connected layer
- This lets the new head adapt to the 6 categories without disturbing pretrained weights
- Unfreeze
layer4+ the final head - Use two learning rates:
- small LR for the pretrained block
- higher LR for the classification head
- This typically gives a solid improvement in validation accuracy
This workflow mirrors how transfer learning is done in real projects:
stable first, then controlled fine-tuning.
intel-natural-scenes-resnet/
│
├── notebooks/
│ └── 01_intel_resnet18.ipynb
│
├── src/
│ ├── dataset.py
│ ├── model.py
│ ├── train.py
│ └── utils.py
│
├── models/
│ └── intel_resnet18.pt # exported checkpoint for inference (used by API project)
│
├── data/ # not included in repo
│ └── raw/
│ └── intel/
│
├── docs/
│
├── .gitignore
├── requirements.txt
├── README.md
├── ARCHITECTURE.md
└── system_design.md
I kept training logic inside src/ to keep the notebook clean and readable.
The final trained model achieves strong accuracy on the validation set (exact numbers depend on hardware and training time).
The notebook includes:
- training curves
- validation accuracy
- sample predictions with ground truth vs model output
This gives a clear sense of how well the model generalizes.
The final trained model is exported into a lightweight checkpoint suitable for inference. This file is included in the repository under: models/intel_resnet18.pt
It contains:
- the trained ResNet18 weights
- the six class labels used during inference
- no optimizer state (keeps file size small)
This checkpoint is used directly by the Intel Natural Scenes API project to serve real-time predictions.
API repository: https://github.com/msaleh1888/intel-natural-scenes-api
-
Install dependencies:
pip install -r requirements.txt
-
Place the dataset under:
data/raw/intel/ -
Run the notebook:
notebooks/01_intel_resnet18.ipynb
This will train the model, save the best checkpoint, and show prediction samples.
Some ideas I may explore later:
- Confusion matrix analysis
- Stronger augmentation
- Training a deeper backbone (ResNet34 / ResNet50)
- Running inference on the
seg_predfolder
— Mahmoud Saleh