Skip to content

Commit

Permalink
Merge pull request #52 from kaylode/dev
Browse files Browse the repository at this point in the history
Officially migrated to Lightning/Hydra
  • Loading branch information
kaylode committed Nov 4, 2023
2 parents 9cbc62b + 1b1ea74 commit f551e39
Show file tree
Hide file tree
Showing 167 changed files with 2,213 additions and 1,889 deletions.
1 change: 1 addition & 0 deletions .dvc/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
remote = gdrive
['remote "gdrive"']
url = gdrive://155tBftKDG8VSAWojOWT3exax3hz0Xuwg
gdrive_acknowledge_abuse = true
8 changes: 6 additions & 2 deletions .github/workflows/clf.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: autobuild_clf
on:
pull_request:
branches:
- master
- dev
push:
branches:
- master
Expand All @@ -14,10 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'
architecture: 'x64'
- uses: actions/setup-node@v3
with:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ on:
pull_request:
branches:
- master
- 'V**'
- dev

env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -16,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'
architecture: 'x64'
- uses: iterative/setup-cml@v1
- uses: iterative/setup-dvc@v1
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/segm.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: autobuild_segm
on:
pull_request:
branches:
- master
- dev
push:
branches:
- master
Expand All @@ -14,10 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'
architecture: 'x64'
- uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -48,5 +52,7 @@ jobs:
cat runs/pytest_segm/Validation/metrics.json | md-table >> report.md
echo >> report.md
echo "#### Prediction" >> report.md
echo "![Prediction](runs/pytest_segm/Validation/prediction.png)" >> report.md
echo "![Prediction](runs/pytest_segm/overlays/fc9399fafb30_01.jpg)" >> report.md
echo "![Prediction](runs/pytest_segm/overlays/fcac2903b622_06.jpg)" >> report.md
echo "![Prediction](runs/pytest_segm/overlays/fcac2903b622_11.jpg)" >> report.md
cml comment create report.md
10 changes: 7 additions & 3 deletions .github/workflows/tablr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: autobuild_tablr
on:
pull_request:
branches:
- master
- dev
push:
branches:
- master
Expand All @@ -14,10 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'
architecture: 'x64'
- uses: actions/setup-node@v3
with:
Expand All @@ -29,7 +33,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu
pip install -e '.[dev,tabular,tabular_classification]'
pip install -e '.[dev,ml]'
pip install dvc dvc-gdrive
npm install -g markdown-table-cli
- name: Download data
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.11.2
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,40 @@
# :pencil: Instructions

### Installation
- Install Pytorch:
- For conda: `conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia`
- For PIP: `pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116`
- Create virtual environment: `conda create -n myenv python=3.10`
- Install [Pytorch](https://pytorch.org/). Currently support `torch==1.13.1`
- Inside your project, install this package by `git+https://github.com/kaylode/theseus.git@master#egg=theseus[cv,cv.classification,cv.detection,cv.semantic]`
***extra packages can be identified from the project's folder structure***.
***extra packages can be identified from the pyproject.toml***.

### To adapt for personal project
1. Create your own dataset, dataloader, model, loss function, metric function, ... and register it to the registry so that it can be generated from config at runtime.
2. Customize inherited trainer and pipeline to your need, such as what to do before/after training/validating step,...
3. Modify configuration file
3. Write custom callbacks (recommended!), follow [Lightning](https://lightning.ai/docs/pytorch/latest/)
4. Modify configuration file

*See ```theseus/classification``` for example*
*See ```theseus/cv/classification``` for example*

### To execute scripts with arguments
- Run the script with `-c` flag with specified config file. Example:
- Run the script with `--config-dir` flag with a specified config folder that contains the yaml file. And `--config-name` is that file's name.

Example:
```
python train.py -c pipeline.yaml
python train.py \
--config-dir configs \
--config-name pipeline.yaml
```

- To override arguments inside the .yaml file, use flag `-o` with key and value. For example, to train 50 epochs and resume training from checkpoints:
- To override arguments inside the .yaml file, follow the instructions from [Hydra](https://hydra.cc/docs/intro/). For example, to train 50 epochs and resume training from checkpoints:

```
python train.py \
-c pipeline.yaml \
-o trainer.args.num_iterations=5000 \
--config-dir configs \
--config-name pipeline.yaml \
trainer.args.max_epochs=5000 \
global.resume=checkpoint.pth
```
**Notice: There are no spaces between keys and values in -o flag**

- Also, if you want to do inference, you need to write your own script. For example see ```configs/classification/infer.py```

# :school_satchel: Resources
- Example colab notebooks for classification tasks: [![Notebook](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1mZmT1B5zI1j_0w1MbP-kq8_Tbcx_tIFq?usp=sharing)
Expand Down
15 changes: 0 additions & 15 deletions configs/base/globals.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions configs/classification/eval.py

This file was deleted.

24 changes: 0 additions & 24 deletions configs/classification/optuna/pipeline.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions configs/classification/train.py

This file was deleted.

10 changes: 0 additions & 10 deletions configs/detection/eval.py

This file was deleted.

70 changes: 0 additions & 70 deletions configs/detection/pipeline.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions configs/detection/train.py

This file was deleted.

Loading

0 comments on commit f551e39

Please sign in to comment.