Skip to content

Commit

Permalink
Migrate tutorial to use the quarto framework (#63)
Browse files Browse the repository at this point in the history
* Minimal quarto setup (#56)

minimal setup to generate the tutorials with quarto

* Add front matter (#57)

* add missing front matters (#58)

* add thumbnails (#59)

* fix typo categories tags (#60)

* Update theme customization (#61)

Co-authored-by: Paolla Olsen <paollaolsen@gmail.com>

* move to quarto actions

* cleanup

* add contribution guide

---------

Co-authored-by: Paolla Olsen <paollaolsen@gmail.com>
  • Loading branch information
johnnv1 and PaollaOlsen authored Aug 22, 2023
1 parent 355d33b commit 4f5e239
Show file tree
Hide file tree
Showing 102 changed files with 1,044 additions and 824 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tutorials/assets/* binary
tutorial/_static/img/* binary
17 changes: 11 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
matrix:
os: ['Ubuntu']
python-version: ['3.10']
pytorch-version: ['1.13.1']
pytorch-version: ['2.0.1']

steps:
- uses: actions/checkout@v3
Expand All @@ -74,13 +74,18 @@ jobs:
- name: Install dependencies
shell: bash -l {0}
run: |
conda install pytorch=${{ matrix.pytorch-version }} cpuonly -c pytorch
make setup
conda install pytorch=${{ matrix.pytorch-version }} torchvision cpuonly -c pytorch
pip install -r requirements.txt
pip install -r requirements-dev.txt;
- uses: quarto-dev/quarto-actions/setup@v2

- name: Check deps
shell: bash -l {0}
run: make check-deps

- name: Build tutorials pages
shell: bash -l {0}
run: make generate
- name: Render Quarto Project
uses: quarto-dev/quarto-actions/render@v2
with:
to: html
path: .
49 changes: 49 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Generate docs and deploy to GitHub Pages
on:
workflow_dispatch:
push:
branches: [master]

jobs:
deploy:
name: Deploy tutorials - ${{ matrix.os }}, ${{ matrix.python-version }}, ${{ matrix.pytorch-version }}
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: true
matrix:
os: ['Ubuntu']
python-version: ['3.10']
pytorch-version: ['2.0.1']

steps:
- uses: actions/checkout@v3
- name: Setup conda dependencies
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

- name: Install dependencies
shell: bash -l {0}
run: |
conda install pytorch=${{ matrix.pytorch-version }} torchvision cpuonly -c pytorch
pip install -r requirements.txt
pip install -r requirements-dev.txt;
- uses: quarto-dev/quarto-actions/setup@v2

- name: Render Quarto Project
uses: quarto-dev/quarto-actions/render@v2
with:
to: html
path: .

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force_orphan: true
publish_dir: ./_site
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Temp files created when building the pages
_nbs/
_build/
/.quarto/
_site/

# Allows just notebooks inside nbs/
!nbs/**.ipynb
Expand Down
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ repos:
- id: detect-private-key
- id: debug-statements
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-pyupgrade
args: [--py37-plus]
args: [--py38-plus]
- id: nbqa-isort
args: ['--profile=black']
- id: nbqa-black
args: ['--nbqa-dont-skip-bad-cells', '--line-length=128']

- repo: https://github.com/fastai/nbdev/
rev: 2.3.11
hooks:
- id: nbdev_clean
args: ['--fname', './']

19 changes: 0 additions & 19 deletions .readthedocs.yaml

This file was deleted.

33 changes: 17 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
SOURCEDIR = nbs
DOCSDIR = tutorials
DOCSDIRNBS = $(DOCSDIR)/_nbs

.PHONY: purge generate execute sphinx build setup check-deps

purge:
@echo "\n\nRemoving all notebooks under '$(DOCSDIRNBS)'...\n"
rm -f $(DOCSDIRNBS)/*.ipynb
@echo "\nRemoving all files that are not notebooks on '$(SOURCEDIR)'...\n"
find $(SOURCEDIR) -type f ! -name "*.ipynb" -delete
@echo "\n"
@cd $(DOCSDIR); make purge

generate:
@echo "\n\nGenerating all tutorials notebooks to '$(DOCSDIRNBS)'...\n"
jupyter nbconvert $(SOURCEDIR)/**.ipynb --to notebook --output-dir $(DOCSDIRNBS)
@echo "\n\nGenerating all tutorials notebooks to '$(SOURCEDIR)'...\n"
jupyter nbconvert $(SOURCEDIR)/**.ipynb --to notebook --output-dir $(SOURCEDIR)

execute:
@echo "\n\nExecuting all tutorials notebooks under '$(DOCSDIRNBS)'...\n"
jupyter nbconvert $(DOCSDIRNBS)/**.ipynb --execute --inplace
@echo "\n\nExecuting all tutorials notebooks under '$(SOURCEDIR)'...\n"
jupyter nbconvert $(SOURCEDIR)/**.ipynb --execute --inplace

sphinx:
cd $(DOCSDIR); make clean html
build: purge generate render

build: purge generate sphinx
setup-quarto:
curl -LO https://www.quarto.org/download/latest/quarto-linux-amd64.deb
sudo dpkg -i quarto-linux-amd64.deb
rm quarto-linux-amd64.deb

setup:
pip install -r requirements.txt && pip install -r requirements-dev.txt
pip install -r requirements.txt && pip install -r requirements-dev.txt;
make setup-quarto

preview:
quarto preview .

render:
quarto render .

check-deps:
@which python
Expand All @@ -35,5 +38,3 @@ check-deps:
@python -c "import torch;print('Pytorch version: ', torch.__version__)"
@python -c "import torchvision;print('Pytorch vision version: ', torchvision.__version__)"
@python -c "import cv2;print('OpenCV version: ', cv2.__version__)"


128 changes: 122 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,126 @@
# tutorials
# Kornia tutorials

## development
The kornia tutorials provide from basic to advanced tutorials for [kornia library](https://github.com/kornia/kornia).

To compile the docs in local to debug
These tutorials are made by the community for the community. To shows how to use the Kornia API, and also show how these
computer vision algorithms can be used in a variety of scenarios.

```bash
make setup
make build
The kornia tutorials uses the [quarto](https://quarto.org/) framework to generate the website from jupyter notebooks.

## Guide


### Step-by-step setup environment
1. Install [quarto](https://quarto.org/) following the official docs: https://quarto.org/docs/get-started/
1. Create a virtual environment
```console
# with virtual env
$ virtualenv venv -p python3.10
# with conda
$ conda create -p venv python=3.10
```
1. Install the dependencies
```console
$ pip install -r requirements.txt
$ pip install -r requirements-dev.txt
```
1. Run quarto on preview mode. Which automatically reloads the browser when input files or document resources change.
```console
# Using our makefile command
$ make preview
# Using the quarto cli directly
$ quarto preview .
```

For Linux users, you can use the `make setup` which will download and install the quarto binary for linux. And pip install
the requirements.

### How to add a new tutorial

The kornia tutorials are jupyter notebooks (you can find them into [./nbs/](./nbs/) directory). Each notebook corresponds into a
"blogpost" page within the same content. The notebook is compiled into a webpage by quarto, which means you can write a
tutorial using a jupyter notebook with the normal pattern of Python and Markdown cells. This enable some special features
, for use it we recomment you to check the [quarto docs](https://quarto.org/docs/).

Aside from the content of the tutorial, the first cell of the notebook should have a header content (markdown cell). This header
allow us to have thumbmail, author, categories, etc. This header should look like:

```txt
---
title: "<YOUR TUTORIAL TITLE HERE>"
description: "<YOUR TUTORIAL DESCRIPTION HERE>"
author:
- "<YOUR NAME HERE>"
date: "<TUTORIAL DATE INTO FORMAT MM-DD-YYYY>"
categories:
- "<CATEGORY HERE: basic, itermediate or advanced>"
- "<CATEGORY HERE, based on the kornia module used: kornia.color, kornia.augmentation, etc>"
- "<OTHER CATEGORY: checkout the readme list of categories>"
- "<OTHER CATEGORY: checkout the readme list of categories>"
- "<OTHER CATEGORY: checkout the readme list of categories>"
image: "../tutorials/assets/<YOUR TUTORIAL THUMBMAIL FILENAME HERE>.png"
---
<a href="https://colab.sandbox.google.com/github/kornia/tutorials/blob/master/nbs/<YOUR TUTORIAL FILENAME HERE>.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open in google colab"></a>
```

For this header you should generate a image to be used as thumbmail, and save it into the [tutorials/assets/](./tutorials/assets/)
directory. Also update the link for the colab, for user can be able to directly open your tutorial into the colab. You can add
`N` categories, look at the categories already available in the README, if you want to use a different one, please update the
README too.


### Tutorials categories
If you add a new category on the tutorials frontmatter, update this too.

By Levels
- Basic
- Intermediate
- Advanced

By module
- kornia.augmentation
- Kornia.feature
- kornia.contrib
- kornia.filters
- kornia.color
- kornia.io
- kornia.geometry
- kornia.enhance

By generic type/category
- Data augmentation
- Segmentation
- Edge Detection
- Labeling
- Denoising
- Color spaces
- Local features
- Filters
- Blur
- Line
- Plane
- Keypoints
- Homography
- Image matching
- Image Registration
- Warp image
- Augmentation container
- Augmentation Sequential
- Line detection
- Line matching
- Rescale
- Affine
- 2D
- Unsupervised
- Self-supervised

By specific names of models / API
- SOLD2
- KeyNet
- Adalam
- HardNet
- DISK
- Patches
- LAF
- LoFTR
Loading

0 comments on commit 4f5e239

Please sign in to comment.