Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Officially migrated to Lightning/Hydra #52

Merged
merged 34 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7c6bda8
:wrench: fix small error, update project version
kaylode Apr 12, 2023
c71102c
:sparkles: add more classification metrics
kaylode May 4, 2023
4ec326c
:bug: fix bug when scheduler is not used
kaylode May 4, 2023
6bdc0d3
:memo: use inspect to get function kwargs
kaylode May 4, 2023
ed1d3f2
:sparkles: update custom vocabulary
kaylode May 4, 2023
d994ce0
:memo: add sklearn plots
kaylode May 4, 2023
86c4af3
:wrench: fix small bug
kaylode May 4, 2023
aabaae6
:wrench: fix small bug
kaylode May 4, 2023
1c2c728
Update clf.yml
kaylode May 5, 2023
22cf4f1
:bug: use python3.10
kaylode May 5, 2023
99c867e
:fire: update loss according to lightning
kaylode May 22, 2023
bd89072
:fire: update metrics, detach and move to cpu
kaylode May 22, 2023
fc4714e
:zap: Adapt CosineScheduler to match lightning
kaylode May 22, 2023
d638778
:art: Improve template to adapt lightning
kaylode May 22, 2023
6b23901
:art: Add lightning as template
kaylode May 22, 2023
ba41f54
:zap: :lightning: update lightning wrapper
kaylode May 23, 2023
c043df8
:bug: Small fix
kaylode May 23, 2023
0a3089f
:zap: Fix lightning
kaylode May 24, 2023
907dceb
:zap: :zap: fully migrate to lightning
kaylode May 30, 2023
d59b5b5
:memo: Update requiremnet
kaylode May 30, 2023
6088c7f
:memo: Update requiremnet
kaylode May 30, 2023
330b6c9
:beers: Tmp callbacks for ml
kaylode May 30, 2023
f8e5957
:fire: Rename tabular folder, fix minor issues in base, update precom…
kaylode Nov 3, 2023
3f3fb78
:art: Update nlp folders
kaylode Nov 3, 2023
600c6e3
:zap: Migrate cv to lightning
kaylode Nov 3, 2023
a006714
:art: Rename tabular to ml, also migrate to lightning
kaylode Nov 3, 2023
f8d4028
:stethoscope: Migrate tests to lightning
kaylode Nov 3, 2023
4142a4c
:rocket: Update github workflows, readme, setupfiles
kaylode Nov 3, 2023
c204b4d
Merge pull request #51 from kaylode/lightning-hydra
kaylode Nov 3, 2023
15ccc53
:bug: Remove reference between base and ml to fix error
kaylode Nov 4, 2023
c92f407
:fire: Change tests optimizer, workflow dependencies
kaylode Nov 4, 2023
5db8cc3
:art: Fix test image path, workflow
kaylode Nov 4, 2023
4fe8224
:art: Fix load segm model, workflow
kaylode Nov 4, 2023
1b1ea74
:bug: Fix xgboost error
kaylode Nov 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading