Skip to content

msaleh1888/intel-natural-scenes-resnet18

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intel Natural Scenes Classification (ResNet18, Transfer Learning)

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.


Dataset

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.


Approach

I used ResNet18 pretrained on ImageNet as the feature extractor.
The training process happens in two phases:

Phase 1 — Train only the classification head

  • 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

Phase 2 — Fine-tune the last ResNet block

  • 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.


📂 Project Structure

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.


Results

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.


Model Checkpoint

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


How to Run

  1. Install dependencies:

    pip install -r requirements.txt
  2. Place the dataset under:

    data/raw/intel/
    
  3. Run the notebook:

    notebooks/01_intel_resnet18.ipynb
    

This will train the model, save the best checkpoint, and show prediction samples.


Next Steps

Some ideas I may explore later:

  • Confusion matrix analysis
  • Stronger augmentation
  • Training a deeper backbone (ResNet34 / ResNet50)
  • Running inference on the seg_pred folder

— Mahmoud Saleh

About

A clean, well-structured PyTorch project where I trained a ResNet18 model on the Intel Natural Scenes dataset. The repo includes modular code, a simple training pipeline, full documentation, and a reproducible process that reflects how I approach real ML work.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors