Hyperspectral Image Classification using Deep Learning
HyperScape is a deep learning-based project that focuses on classifying hyperspectral images (HSI) by capturing both spectral and spatial features. The project explores multiple CNN architectures including a custom 2D CNN, VGG16 with transfer learning, and a 3D CNN to achieve high accuracy and generalization across datasets like Indian Pines and Salinas-A.
- Custom-built 2D CNN architecture
- Transfer learning with VGG16 using PCA-reduced HSI data
- 3D CNN for volumetric spectral-spatial analysis
- Preprocessing techniques: Band selection, patch extraction, normalization, PCA
- Evaluation on Indian Pines; generalization tested on Salinas-A dataset
- EarlyStopping and learning rate scheduling for stable training
- H5 model and pickle file saving for future inference
| Model | Highlights |
|---|---|
| 2D CNN | Built from scratch; flexible and efficient |
| VGG16 | Transfer learning with 3-channel PCA input |
| 3D CNN | Captures detailed spatial + spectral features (Salinas-A) |
-
Indian Pines:
- Size: 145 × 145 pixels
- Bands: 224 (200 used)
- Classes: 16 land-cover types
-
Salinas-A (used for generalization):
- Size: 83 × 86 pixels
- Bands: 204
- Classes: 6 vegetation types
Both datasets were captured by the AVIRIS sensor.
- Band removal (e.g., water absorption bands)
- Spectral normalization
- PCA for dimensionality reduction (for VGG)
- Patch extraction (e.g., 11×11 or 5×5×30)
- Data augmentation: rotation & flipping
- Optimizer: Adam
- Loss Function: Categorical Crossentropy
- Batch Size: 32
- Epochs: 75
- Callbacks: EarlyStopping, ReduceLROnPlateau
- Model Output: Saved as
.h5 - Test Data: Saved as
.pkl
- 3D CNN achieved the highest accuracy, generalizing well across unseen data.
- The hybrid approach (2D + 3D features) demonstrated strong potential for real-world application.
- Applied to Hyperion satellite imagery for urban land classification, supporting smart city planning and environmental monitoring.
| Model | Accuracy (Indian Pines) | Accuracy (Salinas-A) | Notes |
|---|---|---|---|
| 2D CNN | ~93% | N/A | Good baseline performance |
| VGG16 (TL) | ~90% | N/A | Fast training, PCA required |
| 3D CNN | ~95% | ~96–97% | Best spatial-spectral model |
This project is deployed on Hugging Face Spaces using Gradio as the frontend framework.
👉 Click here to launch HyperScape
app.py– Main Python script containing the Gradio interface and model inference logic.requirements.txt– Lists all required Python dependencies.Models/– Pretrained 2D and 3D CNN models (e.g., for Indian Pines, Salinas-A).dataset/- Containing the datasets and their respective RGB images.Test_data/– Test set data and coordinate points.utils/– Helper scripts for preprocessing, visualization, and prediction.
- Frontend: Gradio
- Backend: Python (TensorFlow/Keras, NumPy, SciPy, OpenCV, Matplotlib)
- Platform: Hugging Face Spaces
To deploy this app on your own Hugging Face Space:
- Create a new Space at huggingface.co/spaces.
- Choose Gradio as the SDK.
- Upload the following files to your Space:
app.pyrequirements.txt- Any model/data files your app depends on
- Click "Commit" and the app will build and launch automatically.
Once deployed, the app will be accessible via a public URL and automatically re-run on any code or file updates.
- Public and live
- Supports multiple datasets and models
- Provides real-time predictions and visualization
- ✅ Feature fusion: Combine 2D and 3D features for robust classification
- ✅ Apply on additional benchmark and real-world datasets
- ✅ Scale to remote sensing applications in agriculture, city planning, and sustainability
- Ommooley10
- Vaishnavi Paswan
- Vedika Agrawal
- Laxmikant Dubey
This project is open-source under the MIT License.
Suggestions and improvements are welcome!! 🙂 For queries, suggestions, or collaborations, feel free to reach out via GitHub Issues or email.