Skip to content

Commit 49dba4a

Browse files
add set up via upload
1 parent e387867 commit 49dba4a

16 files changed

Lines changed: 10036 additions & 37 deletions

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
SHELL := /bin/bash
2+
3+
.PHONY: create_venv install install-torch lint help
4+
5+
help:
6+
@echo "Available targets:"
7+
@echo " create_venv - Create virtual environment and install dependencies (without torch)"
8+
@echo " install - Install package with dev dependencies (without torch)"
9+
@echo " install-torch - Install PyTorch CPU-only version"
10+
@echo " lint - Run pre-commit hooks on all files"
11+
12+
create_venv:
13+
@echo "Creating virtual environment..."
14+
python3 -m venv .venv
15+
@echo "Installing dependencies (without torch)..."
16+
.venv/bin/python3 -m pip install --upgrade pip
17+
.venv/bin/pip install -e .[dev]
18+
@echo ""
19+
@echo "Virtual environment created successfully!"
20+
@echo "To install PyTorch (CPU-only), run: make install-torch"
21+
@echo "Or manually install with:"
22+
@echo " pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu"
23+
24+
install:
25+
python3 -m pip install --upgrade pip
26+
pip install -e .[dev]
27+
@echo "Dependencies installed (without torch)."
28+
@echo "To install PyTorch (CPU-only), run: make install-torch"
29+
30+
install-torch:
31+
@echo "Installing PyTorch CPU-only version..."
32+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
33+
@echo "PyTorch installed successfully!"
34+
35+
lint:
36+
pre-commit run --all-files

README.md

Lines changed: 98 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,98 @@
1-
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/15CTOpCR)
2-
# Deep Learning E1394 - Tutorial
3-
4-
## Submitting your work
5-
6-
Once the deadline has passed, you are not able to push to your repository anymore or update it in any other way and all changes on the main branch will be considered for grading. In other words, there is no "submit" button which you need to press. You just need to ensure that all your work has been pushed / uploaded to GitHub before the deadline.
7-
8-
Uploading a new or edited file to GitHub involves three steps:
9-
1. Add the file to the staging area:
10-
```
11-
git add <file to be added>
12-
```
13-
2. Create a commit:
14-
```
15-
git commit -m <commit msg - briefly describe your change>
16-
```
17-
3. Push the local commit to GitHub:
18-
```
19-
git push
20-
```
21-
22-
To avoid conflicts when multiple people are working on the same file, we recommend to push your changes as frequently as possible and always pull the latest changes from GitHub before you start working. Also, as a nice teammate, test your changes before you push them and use meaninful commit messages to make it easy to understand your changes.
23-
24-
## Asking for help
25-
26-
If you have important questions or believe to have spotted an error, please open an issue on your repository and mention the teaching assistant with @chiara-fb and @henrycgbaker.
27-
28-
## Useful Links
29-
* Git best practices: https://gist.github.com/luismts/495d982e8c5b1a0ced4a57cf3d93cf60
30-
* How to write a good git commit message: https://cbea.ms/git-commit/
31-
* Book "Dive into Deep Learning": https://d2l.ai/
32-
* Tutorial on pushing and submitting work with GitHub classroom: https://www.youtube.com/watch?v=jXpT8eOzzCM
33-
* Neural network from scratch:
34-
* https://towardsdatascience.com/math-neural-network-from-scratch-in-python-d6da9f29ce65
35-
* https://pythonalgos.com/create-a-neural-network-from-scratch-in-python-3/
36-
* https://github.com/casperbh96/Neural-Network-From-Scratch/blob/master/NN_From_Scratch.ipynb
37-
* https://www.codingame.com/playgrounds/59631/neural-network-xor-example-from-scratch-no-libs
1+
# Few-Shot Learning for Rooftop Detection in Satellite Imagery
2+
3+
## Tutorial Overview
4+
5+
This tutorial demonstrates few-shot learning techniques for semantic segmentation of satellite imagery. The dataset contains high-resolution satellite images of Geneva, Switzerland, with corresponding segmentation labels for rooftop detection.
6+
7+
📓 **[View Tutorial Notebook (HTML)](docs/tutorial_few_shot_learning.html)**
8+
9+
### Learning Outcomes
10+
- Understanding few-shot learning concepts for image segmentation
11+
- Working with satellite imagery and segmentation masks
12+
- Implementing and evaluating few-shot learning models for rooftop detection
13+
14+
## Video Tutorial
15+
16+
<!-- VIDEO PLACEHOLDER: Replace the link below with your tutorial video -->
17+
[![Tutorial Video](https://img.youtube.com/vi/VIDEO_ID/0.jpg)](https://www.youtube.com/watch?v=VIDEO_ID)
18+
19+
*Click the image above to watch the tutorial video*
20+
21+
## Quick Start
22+
23+
### Installation
24+
25+
```bash
26+
# Clone the repository
27+
git clone https://github.com/elenaivadreyer/tutorial-group-1.git
28+
cd tutorial-group-1
29+
30+
# Create virtual environment
31+
python3 -m venv .venv
32+
source .venv/bin/activate
33+
34+
# Install the package (without PyTorch)
35+
pip install -e .
36+
37+
# Install PyTorch (CPU-only version recommended to save disk space)
38+
# CPU-only: ~730MB vs CUDA version: ~7GB
39+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
40+
41+
# Or use the Makefile
42+
make install
43+
make install-torch
44+
```
45+
46+
**Note:** PyTorch is not installed by default due to its large size. The CPU-only version is recommended for most use cases and saves significant disk space.
47+
48+
### Running the Tutorial
49+
50+
Open the main tutorial notebook:
51+
```bash
52+
jupyter notebook notebooks/tutorial_few_shot_learning.ipynb
53+
```
54+
55+
## Project Structure
56+
57+
```
58+
├── notebooks/
59+
│ └── tutorial_few_shot_learning.ipynb # Main tutorial notebook
60+
├── src/few_shot_utils/
61+
│ ├── __init__.py # Package initialization
62+
│ ├── data.py # Data loading utilities
63+
│ ├── models.py # Model architectures
64+
│ ├── train.py # Training functions
65+
│ └── evaluate.py # Evaluation metrics
66+
└── docs/ # Documentation
67+
```
68+
69+
## Dataset Description
70+
71+
The dataset consists of:
72+
- **Satellite Images**: High-resolution RGB satellite images of Geneva, Switzerland
73+
- **Segmentation Labels**: Binary masks indicating rooftop locations
74+
- **Resolution**: Images at various resolutions suitable for few-shot learning
75+
76+
## Development
77+
78+
### Linting and Formatting
79+
80+
This project uses [Ruff](https://docs.astral.sh/ruff/) for linting and formatting, including Jupyter notebooks.
81+
82+
```bash
83+
# Run linting with automatic fixes
84+
ruff check . --fix
85+
ruff format .
86+
87+
# Run pre-commit hooks
88+
pre-commit run --all-files
89+
```
90+
91+
## References
92+
93+
-
94+
-
95+
96+
## License
97+
98+
This project is licensed under the MIT License - see the LICENSE file for details.

docs/_config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: Few-Shot Learning Tutorial
2+
description: Few-shot learning for rooftop detection in satellite imagery
3+
theme: jekyll-theme-primer
4+
baseurl: "/tutorial-group-1"
5+
url: "https://elenaivadreyer.github.io"
6+
7+
# remote_theme: pages-themes/primer@v0.6.0
8+
# plugins:
9+
# - jekyll-remote-theme # add this line to the plugins list if you already have one

docs/index.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
layout: default
3+
title: Few-Shot Learning for Rooftop Detection
4+
---
5+
6+
# Few-Shot Learning for Rooftop Detection in Satellite Imagery
7+
8+
Welcome to the tutorial on few-shot learning for semantic segmentation of satellite imagery, focusing on rooftop detection in Geneva, Switzerland.
9+
10+
## Tutorial Overview
11+
12+
This tutorial demonstrates:
13+
- Few-shot learning concepts for image segmentation
14+
- Working with satellite imagery and segmentation masks
15+
- Implementing and evaluating few-shot learning models for rooftop detection
16+
17+
## Getting Started
18+
19+
### Prerequisites
20+
- Python 3.11+
21+
- PyTorch 2.0+
22+
23+
### Installation
24+
25+
```bash
26+
git clone https://github.com/elenaivadreyer/tutorial-group-1.git
27+
cd tutorial-group-1
28+
pip install -e .
29+
```
30+
31+
### Running the Tutorial
32+
33+
Open the main tutorial notebook:
34+
```bash
35+
jupyter notebook notebooks/tutorial_few_shot_learning.ipynb
36+
```
37+
38+
## Video Tutorial
39+
40+
<!-- VIDEO PLACEHOLDER: Add your video here -->
41+
*Video coming soon...*
42+
43+
## Dataset
44+
45+
The dataset contains high-resolution satellite imagery of Geneva, Switzerland, with corresponding segmentation labels for rooftop detection.
46+
47+
## Resources
48+
49+
- [GitHub Repository](https://github.com/elenaivadreyer/tutorial-group-1)
50+
- [Tutorial Notebook](https://github.com/elenaivadreyer/tutorial-group-1/blob/main/notebooks/tutorial_few_shot_learning.ipynb)
51+
52+
## License
53+
54+
This project is licensed under the MIT License.

docs/installation.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Installation Guide
2+
3+
This guide explains how to set up the tutorial environment.
4+
5+
## Quick Start
6+
7+
### Using Makefile (Recommended)
8+
9+
```bash
10+
# Create virtual environment and install dependencies
11+
make create_venv
12+
13+
# Activate virtual environment
14+
source .venv/bin/activate
15+
16+
# Install PyTorch (CPU-only)
17+
make install-torch
18+
```
19+
20+
### Manual Installation
21+
22+
```bash
23+
# Create and activate virtual environment
24+
python3 -m venv .venv
25+
source .venv/bin/activate
26+
27+
# Install package dependencies (without PyTorch)
28+
pip install -e .
29+
30+
# Install PyTorch CPU-only version
31+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
32+
```
33+
34+
## Why PyTorch is Optional
35+
36+
PyTorch is not included as a direct dependency because:
37+
38+
1. **Size**: The CUDA version is ~7GB, which can cause disk space issues
39+
2. **CPU-only alternative**: The CPU-only version is ~730MB and sufficient for this tutorial
40+
3. **Flexibility**: Users can choose between CPU and GPU versions based on their needs
41+
42+
## PyTorch Installation Options
43+
44+
### CPU-only (Recommended for most users)
45+
```bash
46+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
47+
```
48+
49+
### CUDA (If you have an NVIDIA GPU)
50+
```bash
51+
# For CUDA 11.8
52+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
53+
54+
# For CUDA 12.1
55+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
56+
```
57+
58+
For more installation options, see the [official PyTorch installation guide](https://pytorch.org/get-started/locally/).
59+
60+
## Development Setup
61+
62+
### Pre-commit Hooks
63+
64+
This project uses pre-commit hooks for code quality. To set them up:
65+
66+
```bash
67+
# Install development dependencies
68+
pip install -e .[dev]
69+
70+
# Install pre-commit hooks
71+
pre-commit install
72+
73+
# Run hooks manually on all files
74+
pre-commit run --all-files
75+
```
76+
77+
### Makefile Targets
78+
79+
- `make help` - Show available targets
80+
- `make create_venv` - Create virtual environment and install dependencies
81+
- `make install` - Install package with dev dependencies
82+
- `make install-torch` - Install PyTorch CPU-only version
83+
- `make lint` - Run pre-commit hooks on all files
84+
85+
## Devcontainer Setup
86+
87+
If you're using VS Code with devcontainers:
88+
89+
1. Open the repository in VS Code
90+
2. Click "Reopen in Container" when prompted
91+
3. The container will build and install dependencies automatically
92+
4. **Important**: PyTorch is not installed by default. To install it, run:
93+
```bash
94+
source .venv/bin/activate && make install-torch
95+
```
96+
97+
## Troubleshooting
98+
99+
### Disk Space Issues
100+
101+
If you encounter disk space issues during installation:
102+
- Make sure you're using the CPU-only version of PyTorch
103+
- Clear pip cache: `pip cache purge`
104+
- Consider using a cloud development environment with more storage
105+
106+
### Import Errors
107+
108+
If you get import errors for torch:
109+
- Make sure PyTorch is installed: `pip list | grep torch`
110+
- Verify you're using the correct virtual environment: `which python`
111+
- Reinstall if necessary: `make install-torch`

docs/memo.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Few-shot learning for satellite image segmentation is crucial for urban planning and disaster response. Traditional deep learning requires thousands of labeled samples, but few-shot learning enables rapid adaptation to new geographic regions with minimal labeled data.
2+
3+
**Policy Applications:**
4+
- Urban development monitoring
5+
- Disaster damage assessment
6+
- Property tax assessment
7+
- Solar panel installation planning

0 commit comments

Comments
 (0)