diff --git a/app/streamlit_app.py b/app/streamlit_app.py index 67fe478b..21c41fa0 100644 --- a/app/streamlit_app.py +++ b/app/streamlit_app.py @@ -15,12 +15,12 @@ } TIP = """ -> **💡 TIP** -> -> To quickly adapt to the generated code structure, there are TODOs in the files that are needed to be edited. -> [PyCharm TODO comments](https://www.jetbrains.com/help/pycharm/using-todo.html) or -> [VSCode Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree) -> can help you find them easily. +**💡 TIP** + +To quickly adapt to the generated code structure, there are TODOs in the files that are needed to be edited. +[PyCharm TODO comments](https://www.jetbrains.com/help/pycharm/using-todo.html) or +[VSCode Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree) +can help you find them easily. """ diff --git a/templates/_base/_find_and_replace.sh b/templates/_base/_find_and_replace.sh deleted file mode 100644 index d3f353e1..00000000 --- a/templates/_base/_find_and_replace.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -xeu - -if [ $(uname) == "Darwin" ]; then - grep -rl "$1" . | xargs sed -i "" "s/$1/$2/g" -else - grep -rl "$1" . | xargs sed -i "s/$1/$2/g" -fi diff --git a/templates/single/README.md b/templates/single/README.md index ce89c5d5..078e60e2 100644 --- a/templates/single/README.md +++ b/templates/single/README.md @@ -18,8 +18,6 @@ Table of Contents ## Getting Started -- After downloaded and extracted an archive, there will be a folder named `single` (directory name). Inside that there will be an another folder named `single_cg` (package name). -
Detailed Directory List @@ -51,15 +49,7 @@ single
-- Folder names must be renamed by using `mv` command in Unix/macOS and Linux and `move` in Windows. Or simply rename them. - -- Since the generated code are using absolute imports, the package name must be renamed to the name you have changed in the above step. There is a `find_and_replace.sh` script (Unix and Linux only) to easily find and replace the package name in the generated code. Usage is: - - ```sh - bash find_and_replace.sh old_pkg_name new_pkg_name - ``` - -- Install the dependencies with `pip` and install the package in `editable` mode: +- Install the dependencies with `pip` and install the project in `editable` mode: ```sh pip install -r requirements.txt --progress-bar off -U @@ -75,8 +65,8 @@ single - Edit `datasets.py` for your custom datasets and dataloaders. - Edit `models.py` for your custom models. -- Extend `utils.py` for additional command line arguments. -- Extend `engines.py` for your custom models' forward pass, backward pass, and evaluation. +- Extend `config.py` for additional command line arguments. +- Extend `trainers.py` for your custom models' forward pass, backward pass, and evaluation. - Extend `handlers.py` for your custom handlers. _(**OPTIONAL**)_ ## Training diff --git a/templates/single/find_and_replace.sh b/templates/single/find_and_replace.sh deleted file mode 100644 index bb5b17b0..00000000 --- a/templates/single/find_and_replace.sh +++ /dev/null @@ -1 +0,0 @@ -{% extends "_find_and_replace.sh" %} diff --git a/templates/single/requirements.txt b/templates/single/requirements.txt index 801fcad6..d1eef9b6 100644 --- a/templates/single/requirements.txt +++ b/templates/single/requirements.txt @@ -1,3 +1,4 @@ +setuptools torch>=1.7.0 pytorch-ignite>=0.4.4 {{ handler_deps }} diff --git a/templates/single/single/config.pyi b/templates/single/single/config.pyi new file mode 100644 index 00000000..3c78ec0f --- /dev/null +++ b/templates/single/single/config.pyi @@ -0,0 +1 @@ +{% include "_argparse.pyi" %} diff --git a/templates/single/single/events.pyi b/templates/single/single/events.pyi deleted file mode 100644 index 9b2016ed..00000000 --- a/templates/single/single/events.pyi +++ /dev/null @@ -1 +0,0 @@ -{% include "_events.pyi" %} diff --git a/templates/single/single/main.pyi b/templates/single/single/main.pyi index 5d87a73f..137f1681 100644 --- a/templates/single/single/main.pyi +++ b/templates/single/single/main.pyi @@ -10,10 +10,10 @@ import ignite.distributed as idist from ignite.engine.events import Events from ignite.utils import manual_seed -from {{project_name}}.engines import create_engines -from {{project_name}}.events import TrainEvents +from {{project_name}}.trainers import create_trainers, TrainEvents from {{project_name}}.handlers import get_handlers, get_logger -from {{project_name}}.utils import get_default_parser, setup_logging, log_metrics, log_basic_info, initialize, resume_from +from {{project_name}}.utils import setup_logging, log_metrics, log_basic_info, initialize, resume_from +from {{project_name}}.config import get_default_parser def run(local_rank: int, config: Any, *args: Any, **kwargs: Any): @@ -43,7 +43,7 @@ def run(local_rank: int, config: Any, *args: Any, **kwargs: Any): # train_engine and eval_engine # ----------------------------- - train_engine, eval_engine = create_engines( + train_engine, eval_engine = create_trainers( config=config, model=model, optimizer=optimizer, diff --git a/templates/single/single/engines.pyi b/templates/single/single/trainers.pyi similarity index 96% rename from templates/single/single/engines.pyi rename to templates/single/single/trainers.pyi index 9ff42144..aaba40fb 100644 --- a/templates/single/single/engines.pyi +++ b/templates/single/single/trainers.pyi @@ -8,7 +8,8 @@ from ignite.engine import Engine from torch.cuda.amp import autocast from torch.optim.optimizer import Optimizer -from {{project_name}}.events import TrainEvents, train_events_to_attr + +{% include "_events.pyi" %} # Edit below functions the way how the model will be training @@ -116,7 +117,7 @@ def evaluate_function( # function for creating engines which will be used in main.py # any necessary arguments can be provided. -def create_engines(**kwargs) -> Tuple[Engine, Engine]: +def create_trainers(**kwargs) -> Tuple[Engine, Engine]: """Create Engines for training and evaluation. Parameters diff --git a/templates/single/single/utils.pyi b/templates/single/single/utils.pyi index c37632c7..151f1d1e 100644 --- a/templates/single/single/utils.pyi +++ b/templates/single/single/utils.pyi @@ -19,8 +19,6 @@ from torch.nn import Module from torch.optim.lr_scheduler import _LRScheduler from torch.optim.optimizer import Optimizer -{% include "_argparse.pyi" %} - # we can use `idist.auto_model` to handle distributed configurations # for your model : https://pytorch.org/ignite/distributed.html#ignite.distributed.auto.auto_model diff --git a/templates/single/tests/test_engines.pyi b/templates/single/tests/test_trainers.pyi similarity index 95% rename from templates/single/tests/test_engines.pyi rename to templates/single/tests/test_trainers.pyi index 50f1e275..c148cabc 100644 --- a/templates/single/tests/test_engines.pyi +++ b/templates/single/tests/test_trainers.pyi @@ -6,8 +6,7 @@ from unittest.mock import MagicMock import ignite.distributed as idist import torch from ignite.engine.engine import Engine -from {{project_name}}.engines import create_engines, evaluate_function, train_function -from {{project_name}}.events import TrainEvents, train_events_to_attr +from {{project_name}}.trainers import create_trainers, evaluate_function, train_function, TrainEvents, train_events_to_attr from torch import nn, optim @@ -110,8 +109,8 @@ class TestEngines(unittest.TestCase): output = evaluate_function(config, engine, self.batch, self.model, self.loss_fn, self.device) self.assertIsInstance(output, Number) - def test_create_engines(self): - train_engine, eval_engine = create_engines( + def test_create_trainers(self): + train_engine, eval_engine = create_trainers( config=Namespace(use_amp=True), model=self.model, loss_fn=self.loss_fn, diff --git a/templates/single/tests/test_utils.pyi b/templates/single/tests/test_utils.pyi index c8cb3dd4..2cf4a626 100644 --- a/templates/single/tests/test_utils.pyi +++ b/templates/single/tests/test_utils.pyi @@ -7,8 +7,8 @@ from tempfile import TemporaryDirectory import torch from ignite.engine import Engine from ignite.utils import setup_logger +from {{project_name}}.config import get_default_parser from {{project_name}}.utils import ( - get_default_parser, hash_checkpoint, log_metrics, resume_from,