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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: safetensors
|
| 6 |
+
tags:
|
| 7 |
+
- image-classification
|
| 8 |
+
- satellite-imagery
|
| 9 |
+
- remote-sensing
|
| 10 |
+
- land-use
|
| 11 |
+
- resnet
|
| 12 |
+
- pytorch
|
| 13 |
+
- eurosat
|
| 14 |
+
- safetensors
|
| 15 |
+
- offline-inference
|
| 16 |
+
- edge-deployment
|
| 17 |
+
datasets:
|
| 18 |
+
- EuroSAT-7-subset
|
| 19 |
+
metrics:
|
| 20 |
+
- accuracy
|
| 21 |
+
pipeline_tag: image-classification
|
| 22 |
+
model-index:
|
| 23 |
+
- name: galaxeye-tile-classifier
|
| 24 |
+
results:
|
| 25 |
+
- task:
|
| 26 |
+
type: image-classification
|
| 27 |
+
name: Satellite Tile Land-Use Classification
|
| 28 |
+
dataset:
|
| 29 |
+
type: EuroSAT-7-subset
|
| 30 |
+
name: EuroSAT 7-Class Subset (64×64 RGB Tiles)
|
| 31 |
+
metrics:
|
| 32 |
+
- type: accuracy
|
| 33 |
+
value: 95.71
|
| 34 |
+
name: Holdout Accuracy
|
| 35 |
---
|
| 36 |
+
|
| 37 |
+
# 🛰️ GalaxEye Satellite Tile Land-Use Classifier
|
| 38 |
+
|
| 39 |
+
A fine-tuned **ResNet-18** model for classifying **64×64 RGB satellite tiles** into **7 land-use categories**, designed for **offline, edge-deployable inference on CPU**.
|
| 40 |
+
|
| 41 |
+
Built as part of the [GalaxEye](https://www.galaxeye.space/) Backend Engineer (ML Systems) take-home assignment.
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## 📊 Model Summary
|
| 46 |
+
|
| 47 |
+
| Property | Value |
|
| 48 |
+
|---|---|
|
| 49 |
+
| **Architecture** | ResNet-18 (ImageNet pretrained, fine-tuned) |
|
| 50 |
+
| **Parameters** | 11.19M (FP32) |
|
| 51 |
+
| **Input** | 64×64 RGB satellite tile (PNG) |
|
| 52 |
+
| **Output** | 7-class probability distribution |
|
| 53 |
+
| **Format** | Hugging Face `safetensors` (zero-copy, mmap-safe) |
|
| 54 |
+
| **Framework** | PyTorch 2.2+ |
|
| 55 |
+
| **License** | MIT |
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## 🏷️ Supported Classes
|
| 60 |
+
|
| 61 |
+
| Label ID | Class | Description |
|
| 62 |
+
|---|---|---|
|
| 63 |
+
| 0 | **AnnualCrop** | Seasonal agricultural fields |
|
| 64 |
+
| 1 | **Forest** | Dense tree cover / woodland |
|
| 65 |
+
| 2 | **Highway** | Road infrastructure and corridors |
|
| 66 |
+
| 3 | **Industrial** | Factories, warehouses, industrial zones |
|
| 67 |
+
| 4 | **Residential** | Urban housing and neighborhoods |
|
| 68 |
+
| 5 | **River** | Waterways and river channels |
|
| 69 |
+
| 6 | **SeaLake** | Large water bodies (seas, lakes) |
|
| 70 |
+
|
| 71 |
+
---
|
| 72 |
+
|
| 73 |
+
## 📈 Performance
|
| 74 |
+
|
| 75 |
+
Evaluated on a **210-tile holdout set** (30 tiles per class), unseen during training:
|
| 76 |
+
|
| 77 |
+
| Class | Accuracy |
|
| 78 |
+
|---|---|
|
| 79 |
+
| AnnualCrop | 29/30 (96.7%) |
|
| 80 |
+
| Forest | 28/30 (93.3%) |
|
| 81 |
+
| Highway | 28/30 (93.3%) |
|
| 82 |
+
| Industrial | 29/30 (96.7%) |
|
| 83 |
+
| **Residential** | **30/30 (100.0%)** |
|
| 84 |
+
| River | 29/30 (96.7%) |
|
| 85 |
+
| SeaLake | 28/30 (93.3%) |
|
| 86 |
+
| **Overall** | **201/210 (95.71%)** |
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
## 🚀 Quick Start
|
| 91 |
+
|
| 92 |
+
### Using PyTorch + Safetensors (Recommended)
|
| 93 |
+
|
| 94 |
+
```python
|
| 95 |
+
import torch
|
| 96 |
+
import torch.nn as nn
|
| 97 |
+
import json
|
| 98 |
+
from torchvision import models, transforms
|
| 99 |
+
from safetensors.torch import load_file
|
| 100 |
+
from PIL import Image
|
| 101 |
+
|
| 102 |
+
# Load config and model
|
| 103 |
+
with open("config.json") as f:
|
| 104 |
+
config = json.load(f)
|
| 105 |
+
|
| 106 |
+
classes = [config["id2label"][str(i)] for i in range(config["num_labels"])]
|
| 107 |
+
|
| 108 |
+
model = models.resnet18()
|
| 109 |
+
model.fc = nn.Linear(model.fc.in_features, len(classes))
|
| 110 |
+
model.load_state_dict(load_file("model.safetensors", device="cpu"))
|
| 111 |
+
model.eval()
|
| 112 |
+
|
| 113 |
+
# Preprocess and classify
|
| 114 |
+
transform = transforms.Compose([
|
| 115 |
+
transforms.Resize((64, 64)),
|
| 116 |
+
transforms.ToTensor(),
|
| 117 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
| 118 |
+
])
|
| 119 |
+
|
| 120 |
+
image = Image.open("tile.png").convert("RGB")
|
| 121 |
+
tensor = transform(image).unsqueeze(0)
|
| 122 |
+
|
| 123 |
+
with torch.no_grad():
|
| 124 |
+
probs = torch.softmax(model(tensor), dim=1)[0]
|
| 125 |
+
label = classes[probs.argmax().item()]
|
| 126 |
+
confidence = probs.max().item()
|
| 127 |
+
|
| 128 |
+
print(f"Prediction: {label} ({confidence:.2%})")
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
### Download from Hugging Face Hub
|
| 132 |
+
|
| 133 |
+
```python
|
| 134 |
+
from huggingface_hub import hf_hub_download
|
| 135 |
+
|
| 136 |
+
# Download model artifacts
|
| 137 |
+
safetensors_path = hf_hub_download("rishii100/galaxeye-tile-classifier", "model.safetensors")
|
| 138 |
+
config_path = hf_hub_download("rishii100/galaxeye-tile-classifier", "config.json")
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
---
|
| 142 |
+
|
| 143 |
+
## 🏗️ Training Details
|
| 144 |
+
|
| 145 |
+
| Property | Value |
|
| 146 |
+
|---|---|
|
| 147 |
+
| **Base Model** | `torchvision.models.resnet18(pretrained=True)` |
|
| 148 |
+
| **Dataset** | EuroSAT 7-class subset (1,050 tiles: 150 per class) |
|
| 149 |
+
| **Train / Eval Split** | 840 train / 210 holdout (80-20 stratified) |
|
| 150 |
+
| **Optimizer** | Adam (lr=1e-4) |
|
| 151 |
+
| **Loss** | CrossEntropyLoss |
|
| 152 |
+
| **Epochs** | 10 |
|
| 153 |
+
| **Augmentation** | RandomHorizontalFlip, RandomRotation(15), ColorJitter |
|
| 154 |
+
| **Hardware** | NVIDIA T4 GPU (Google Colab) |
|
| 155 |
+
| **Training Time** | ~2 minutes |
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
## 🔒 Why Safetensors?
|
| 160 |
+
|
| 161 |
+
This model uses the [safetensors](https://huggingface.co/docs/safetensors/) format instead of Python pickle (`.pth`) for critical safety and performance benefits:
|
| 162 |
+
|
| 163 |
+
- **🛡️ No Arbitrary Code Execution**: Unlike `.pth` files which use `pickle` (vulnerable to code injection), `safetensors` is a pure tensor serialization format with zero deserialization attack surface.
|
| 164 |
+
- **⚡ Zero-Copy Memory Mapping**: Supports `mmap` for instant model loading without full deserialization — ideal for resource-constrained edge hardware.
|
| 165 |
+
- **📦 Framework Agnostic**: Compatible across PyTorch, TensorFlow, JAX, and ONNX ecosystems.
|
| 166 |
+
|
| 167 |
+
---
|
| 168 |
+
|
| 169 |
+
## 🌍 Intended Use
|
| 170 |
+
|
| 171 |
+
This model is designed for **offline satellite tile classification** in isolated, internet-free environments such as:
|
| 172 |
+
- Edge base stations and field laboratories
|
| 173 |
+
- Satellite ground segment compute modules
|
| 174 |
+
- Disaster response and environmental monitoring units
|
| 175 |
+
|
| 176 |
+
It is part of a complete FastAPI-based inference service — see the [GitHub repository](https://github.com/rishii100/galaxeye-tile-classifier) for the full backend implementation.
|
| 177 |
+
|
| 178 |
+
---
|
| 179 |
+
|
| 180 |
+
## ⚠️ Limitations
|
| 181 |
+
|
| 182 |
+
- **Resolution**: Trained exclusively on 64×64 pixel tiles. Performance on other resolutions is not guaranteed.
|
| 183 |
+
- **Class Coverage**: Limited to 7 EuroSAT land-use categories. Novel terrain types (e.g., desert, glacier, wetland) will be misclassified.
|
| 184 |
+
- **Geographic Bias**: EuroSAT tiles are sourced from European Sentinel-2 imagery. Accuracy may degrade on tiles from other geographic regions with different spectral characteristics.
|
| 185 |
+
- **Small Training Set**: Only 840 training tiles (120 per class). Production deployments should fine-tune on larger, domain-specific datasets.
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
## 📎 Links
|
| 190 |
+
|
| 191 |
+
- 🔗 **GitHub Repository**: [rishii100/galaxeye-tile-classifier](https://github.com/rishii100/galaxeye-tile-classifier)
|
| 192 |
+
- 🏢 **GalaxEye Space**: [galaxeye.space](https://www.galaxeye.space/)
|
| 193 |
+
- 📄 **EuroSAT Dataset**: [Helber et al., 2019](https://github.com/phelber/EuroSAT)
|