Skip to content

Commit 1d0b875

Browse files
Add badges, GCN architecture diagram, and GitHub Actions CI
- Add shield badges (Python, PyTorch, PyG, License, Sentinel-2, CI, Stars) - Add GCN model architecture diagram with layer details table - Add GitHub Actions CI workflow (flake8 linting + import checks) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0bab161 commit 1d0b875

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint-and-check:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python 3.9
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.9"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install flake8
26+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
27+
pip install torch_geometric
28+
pip install numpy pandas scikit-learn matplotlib seaborn rasterio
29+
30+
- name: Lint with flake8
31+
run: |
32+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
33+
flake8 . --count --exit-zero --max-line-length=120 --ignore=E501,W503,E203,E266,W504 --statistics
34+
35+
- name: Check imports
36+
run: |
37+
python -c "from gcn_crop_classification import GCN; print('GCN import OK')"
38+
python -c "import apply_gcn_to_raster; print('Raster script import OK')"

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Crop Classification with Graph Convolutional Networks (GCN)
22

3+
[![CI](https://github.com/Osman-Geomatics93/GCN-Crop-Classification/actions/workflows/ci.yml/badge.svg)](https://github.com/Osman-Geomatics93/GCN-Crop-Classification/actions/workflows/ci.yml)
4+
[![Python 3.9+](https://img.shields.io/badge/Python-3.9%2B-3776AB?logo=python&logoColor=white)](https://www.python.org/)
5+
[![PyTorch](https://img.shields.io/badge/PyTorch-2.0%2B-EE4C2C?logo=pytorch&logoColor=white)](https://pytorch.org/)
6+
[![PyG](https://img.shields.io/badge/PyTorch_Geometric-2.5%2B-3C2179?logo=pyg&logoColor=white)](https://pyg.org/)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8+
[![Sentinel-2](https://img.shields.io/badge/Satellite-Sentinel--2-1B4F72)](https://sentinel.esa.int/web/sentinel/missions/sentinel-2)
9+
[![Stars](https://img.shields.io/github/stars/Osman-Geomatics93/GCN-Crop-Classification?style=social)](https://github.com/Osman-Geomatics93/GCN-Crop-Classification)
10+
311
Pixel-level crop classification from **Sentinel-2** satellite imagery using a **Graph Convolutional Network** built with PyTorch Geometric. The model classifies agricultural land into 5 crop/land-cover classes at 10 m spatial resolution.
412

513
---
@@ -8,6 +16,7 @@ Pixel-level crop classification from **Sentinel-2** satellite imagery using a **
816

917
- [Overview](#overview)
1018
- [Method](#method)
19+
- [Model Architecture](#model-architecture)
1120
- [Project Structure](#project-structure)
1221
- [Results](#results)
1322
- [Exploratory Data Analysis](#1-exploratory-data-analysis)
@@ -63,6 +72,26 @@ Classified Crop Map (GeoTIFF + PNG)
6372
3. **GCN training** -- 3-layer GCN with batch normalization, dropout (0.5), and inverse-frequency class weighting
6473
4. **Raster inference** -- Tiled KNN-graph prediction over the full 2262x1424 Sentinel-2 composite
6574

75+
### Model Architecture
76+
77+
The GCN consists of 3 graph convolutional layers with batch normalization and dropout. The KNN graph (k=8) provides the edge connectivity, enabling each pixel to aggregate spectral information from its 8 most similar neighbors in feature space.
78+
79+
<p align="center">
80+
<img src="figures/gcn_architecture.png" alt="GCN Model Architecture" width="900">
81+
</p>
82+
83+
| Component | Details |
84+
|:----------|:--------|
85+
| **Input** | 23 features (10 spectral bands + 13 vegetation indices) |
86+
| **Layer 1** | GCNConv(23, 128) + BatchNorm + ReLU + Dropout(0.5) |
87+
| **Layer 2** | GCNConv(128, 128) + BatchNorm + ReLU + Dropout(0.5) |
88+
| **Layer 3** | GCNConv(128, 5) — output logits |
89+
| **Graph** | KNN (k=8), symmetric, undirected |
90+
| **Parameters** | 20,741 |
91+
| **Optimizer** | Adam (lr=0.01, weight_decay=5e-4) |
92+
| **Loss** | CrossEntropy with inverse-frequency class weights |
93+
| **Early stopping** | Patience = 30 epochs |
94+
6695
## Project Structure
6796

6897
```

figures/gcn_architecture.png

82.1 KB
Loading

0 commit comments

Comments
 (0)