Commit Graph

82 Commits (f5425ab7611ab2376ddb478b57cb2f46f6054e13)

Author SHA1 Message Date
Zaida Zhou 45fa3e44a2
Add pyupgrade pre-commit hook (#1937)
* add pyupgrade

* add options for pyupgrade

* minor refinement
2022-05-18 11:47:14 +08:00
pc e70a318ae9
[Fix] Fix parrots unit tests (#1913) 2022-05-09 16:59:32 +08:00
Artem 94c071b310
[Feature] Add ClearMLLoggerHook (#1906)
* added clearml logger support

* review fixes

* review fixes
2022-04-24 13:20:09 +08:00
Sharpiless 969e2af866
[Feature] Support for linearly learning rate decay (#1627)
* update support for linearly learning rate decay

* Fix LinearAnnealingLrUpdaterHook, update LinearAnnealingMomentumUpdaterHook, add unit test

add docstring

add docstring

update linear lr momentum schedule test

fix ci

Fix CI

* add lr and momentum hook to runner and hooks package

add lr and momentum hook to runner and hooks package

* replace multi_optimziers with multi_optimizers

Co-authored-by: HAOCHENYE <21724054@zju.edu.cn>
Co-authored-by: Mashiro <57566630+HAOCHENYE@users.noreply.github.com>
2022-03-31 09:39:40 +08:00
saurbhc 34f227efbd
[Feature] Add SegmindLoggerHook (#1650)
* add SegmindLoggerHook

* update linting for segmind.py

* ran pre-commit

* add test_segmind_hook

- add SegmindLoggerHook import in:
  mmcv/runner/__init__.py
  mmcv/runner/hooks/__init__.py
  mmcv/runner/hooks/logger/__init__.py

* update test_segmind_hook

- Add Docstring to SegmindLoggerHook
- Use get_loggable_tags(...)

* update test_hooks.py & segmind.py

- mmcv/runner/hooks/logger/segmind.py
  moved docs from __init__ to class ...
  update ImportError line-indentation
  remove unwanted method
- tests/test_runner/test_hooks.py
  update assert_called_with only on hook.segmind_mlflow_log

* Update tests/test_runner/test_hooks.py

disable yapf on test_hooks.py imports

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>

* Update mmcv/runner/hooks/logger/segmind.py

Update SegmindLoggerHook docstring

Co-authored-by: Jiazhen Wang <47851024+teamwong111@users.noreply.github.com>

* update before_run method in segmind.py

removed un-used statements

* updated imports in SegmindLoggerHook

* update SegmindLoggerHook

- code cleanup

* update SegmindLoggerHook

- add interval parameter in __init__ method

* update SegmindLoggerHook

- more arguments passes to __init__ method
  - interval
  - ignore_last
  - reset_flag
  - by_epoch

* Update mmcv/runner/hooks/logger/segmind.py

Co-authored-by: Mashiro <57566630+HAOCHENYE@users.noreply.github.com>

* Update mmcv/runner/hooks/logger/segmind.py

Co-authored-by: Mashiro <57566630+HAOCHENYE@users.noreply.github.com>

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
Co-authored-by: Jiazhen Wang <47851024+teamwong111@users.noreply.github.com>
Co-authored-by: Mashiro <57566630+HAOCHENYE@users.noreply.github.com>
2022-03-03 10:01:46 +08:00
Zaida Zhou 6e9ce18323
Add copyright pre-commit-hook (#1742)
* first commit

* Add copyright pre-commit-hook
2022-02-24 09:24:25 +08:00
Zaida Zhou dd82ab1497
Upgrade the version of isort (#1705)
* Upgrade the version of isort

* sort the order of importing modules
2022-02-09 21:29:21 +08:00
Hakjin Lee 7df4ebedb3
[Fix] Fix the mismatch torch version of MlflowLoggerHook(#1680)
* [Fix] mlflow logger error

* [Update] mlflow hook test arguments

* Replace torch.__version__ with mmcv.TORCH_VERSION

* update test code
2022-02-07 23:14:46 +08:00
Hakjin Lee 26c095dc11
[Fix] Fix the undefined name error (#1695) 2022-01-27 20:11:32 +08:00
Zaida Zhou 9dedc44555
[Fix] Fix the cast_tensor_type (#1639)
* [Fix] Fix the cast_tensor_type when the type of inputs is not the same as src_type

* Add note

* improve comments
2022-01-24 21:21:37 +08:00
Mashiro 580e374eae
Add decay to CyclicLrUpdater (#1655)
* Add decay to cyclic LR

* Simplify tests

* Fix error in tests

* fix cyclic lr

* add weight decay CyclicLrUpdate test

* Update mmcv/runner/hooks/lr_updater.py

update docstring

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>

* update CyclicLrUpdater unit test

* add comments to CyclicLrUpdaterHook

* fix CyclicLrUpdater. Support peak_lr decay when target[0] < 1

* add momentum decay to CyclicMomentumUpdater

* update momentum unit test

* Fix CyclicMomentum comment

Fix CyclicMomentum comment

Co-authored-by: Dmytro Panchenko <panchenkodmytry@gmail.com>
Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
2022-01-24 19:34:25 +08:00
imyhxy 37121bf4f4
[Fix] Fix the bug of momentum updater with warmup policy (#1626)
* fix momentum updater typo bug

* Add unit test for 'constant', 'linear' and 'exp' momentum warmup policy
2022-01-18 17:33:07 +08:00
fatih 40518322b6
add artifact logging to wandb hook (#1616)
* add artifact logging to wandb hook

* upload artifacts wiwth only specified suffix

* update docstring

* Update mmcv/runner/hooks/logger/wandb.py

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>

* fix linting

* add tests for wandb artifact logging

* remove redundant lines

* fix wandb tests

* init `WandbLoggerHook` with `log_artifact=True` in tests

* remove redundant lines from wandb tests

* add docstring for `with_step`

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
2022-01-10 16:52:38 +08:00
David de la Iglesia Castro ac92a1116f
`DvcliveLoggerHook` updates to work with `DVC` (#1208)
* Updates to work with DVC

* Update docstrings

* Updated test

* Updated DVCLiveLoggerHook

* Fix name

* Added missing next_step call

* Fix expected call

* Implicit next_step

* Suggestions from review

* Update test_hooks.py

* Updated to last dvclive version

* Cleaned docstring

* Update mmcv/runner/hooks/logger/dvclive.py

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>

* Update dvclive.py

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
2021-12-22 19:35:06 +08:00
Jiazhen Wang fb486b96fd
[Fix] Fix some warnings in unittest (#1522)
* [Fix] fix some warnings in unittest

* [Impl] standardize some warnings

* [Fix] fix warning type in test_deprecation

* [Fix] fix warning type

* [Fix] continue fixing

* [Fix] fix some details

* [Fix] fix docstring

* [Fix] del useless statement

* [Fix] keep compatibility for torch < 1.5.0
2021-12-22 10:57:10 +08:00
Jiazhen Wang 250fadc210
[Fix] Fix checkpoint local files detect (#1549)
* [fix] fix checkpoint local files detect

* [Fix] add support for path like '~/xx/file'

* [Fix] fix some details

* [Fix] fix unittest
2021-12-14 13:17:29 +08:00
Zaida Zhou 84c7dc3436
[Fix] Fix the path of ceph containing cluster name (#1577)
* [Fix] Fix the path of ceph containing cluster name

* fix corner cases

* fix format

* add note
2021-12-14 10:41:27 +08:00
Shilong Zhang 22e73d6986
[Feature] Detect anomalous parameters (#1547)
* detect detect_anomalous_params

* fix default value

* merge two case

* fix none case

* add unitest

* fix typo

* change level to error

* fix type

* add more details in docstr
2021-12-14 10:28:36 +08:00
Luting Wang 56e9f73c58
[Feature] Add ModuleDict inherited from BaseModule and ModuleDict (#1542)
* improve: add module dict

* Update __init__.py

* docs: add module dict zh

* docs: add module dict

* Update test_basemodule.py

* Update __init__.py

* lint

* lint

* docs

* docs

* Update base_module.py

* lint
2021-12-06 11:56:12 +08:00
zhouzaida 0633f91139 print a warning information when eval_res is an empty dict 2021-11-10 15:44:48 +08:00
zhouzaida f2d11076eb [Fix] Raise AssertError when eval_res is a null dict 2021-11-10 15:44:48 +08:00
Zaida Zhou 32e09f4933
[Feature] Upload checkpoints and logs to ceph (#1375)
* [Feature] Choose storage backend by the prefix of filepath

* refactor FileClient and add unittest

* support loading from different backends

* polish docstring

* fix unittet

* rename attribute str_like_obj to is_str_like_obj

* [Docs] Upload checkpoint to petrel oss

* add infer_client method

* Support uploading checkpoint to petrel oss

* add check_exist method

* refactor CheckpointHook

* support uploading logs to ceph

* rename var client to file_client

* polish docstring

* enhance load_from_ceph

* refactor load_from_ceph

* refactor TextLoggerHook

* change the meaning of out_dir argument

* fix test_checkpoint_hook.py

* add join_paths method

* remove join_paths and add _format_path

* enhance unittest

* refactor unittest

* add a unittest for EvalHook when file backend is petrel

* singleton pattern

* fix test_clientio.py

* deprecate CephBackend

* add warning in load_from_ceph

* fix type of out_suffix

* enhance docstring

* refactor unittest for petrel

* refactor unittest for disk backend

* update io.md

* add concat_paths method

* fix CI

* mock check_exist

* improve docstring

* improve docstring

* improve docstring

* improve docstring

* add isdir and copyfile for file backend

* delete copyfile and add get_local_path

* remove isdir method of petrel

* fix typo

* rename check_exists to exists

* refactor code and polish docstring

* fix windows ci

* add comment and polish docstring

* polish docstring

* polish docstring

* rename _path_mapping to _map_path

* polish docstring and fix typo

* refactor get_local_path

* add list_dir_or_file for FileClient

* add list_dir_or_file for PetrelBackend

* fix windows ci

* Add return docstring

* polish docstring

* fix typo

* fix typo

* fix typo

* fix error when mocking PetrelBackend

* deprecate the conversion from Path to str

* add docs for loading checkpoints with FileClient

* rename keep_log to keep_local

* refactor map_path

* add _ensure_methods to ensure methods have been implemented

* fix list_dir_or_file

* rename _ensure_method_implemented to has_method

* refactor

* polish information

* format information
2021-10-24 14:26:52 +08:00
Zaida Zhou f22c9eb4a4
Add code spell hook to pre-commit and fix typos (#1384)
* Add code-spell hook to pre-commit

* Add code-spell hook to pre-commit and fix typos

* fix setup.cfg
2021-10-04 20:13:54 +08:00
Ma Zerun f5c28a6e08
[Fix] Fix missing `state_dict._metadata` when saving and loading checkpoints. (#1294)
* Fix missing `state_dict._metadata` when saving & loading checkpoints.

* Add unit tests.

* Fix default value and variable names in unit tests.
2021-09-07 17:53:33 +08:00
Wenwei Zhang 979a355d2a
[Feature] Add windows CI (#1023)
* add windows CI

* clean versions

* only allow pt1.7 on windows

* fix windows install issue

* add win cpu

* fix win command

* clean unnecessary command

* resolve turbojpeg & tempfile on win

* replace os.readlink with os.path.realpath

* fix windows ci

* close file before removing it

* fix windows ci

* fix symlink on windows

* fix windows ci

* fix windows ci

* fix windows ci

* fix windows ci

* fix windows ci

* fix windows ci

* fix windows ci

* fix windows ci

* fix windows ci

* modify according to comment

Co-authored-by: zhouzaida <zhouzaida@163.com>
2021-08-24 10:07:31 +08:00
Ma Zerun 357b0dfb36
[WIP] continue PR #784 (#1221)
* Add gradient cumulative optimizer

fixes #190

* Update optimizer.py

* Update optimizer.py

* fix loss scale improperly in last equivalent_iter

* Add `GradientCumulativeOptimizerHook` in `__init__.py`.

* Add docstring of `GradientCumulativeOptimizerHook`.

* Add type check, BN warning and resume warning. And fix typo, lint the
code.

* Add unit test

* Update docstring example.

* Change GradientCumulativeOptimizerHook `__init__` arguments.

* Add GradientCumulativeOptimzierHook unit tests with IterBasedRunner.

* Add GradientCumulativeFp16OptimizerHook.

* Add unit tests of GradientCumulativeFp16OptimizerHook

* Use '!=' instead of '>' to determine resume

Co-authored-by: Zhiyuan Chen <this@zyc.ai>
2021-08-23 11:18:36 +08:00
Zaida Zhou 846d3a4ac6
[Fix] Fix the bug that the training log and evaluating log are mixed (#1252)
* [Fix] Fix the bug that training log and evaluating log are mixed

* [Fix] Fix the bug that training log and evaluating log are mixed

* fix comment

* fix import error

* refactor

* refactor

* refactor

* clear log_buffer before evaluation

* fix error

* add unittest
2021-08-11 22:41:21 +08:00
Shilong Zhang 18c64d5fb0
Fix potential bugs of basemodule when record the initilization information (#1217)
* add logger for init

* change init_info of oevrload init_weight

* add judgement for params_init_info

* add delete comments for params_init_info

* add docstr and more comments

* add docstr and more comments

* resolve comments

* dump to a file

* add unitest

* fix unitest

* fix unitest

* write to ori log

* fix typo

* resolve commnets

* fix call initweights twice in topmost module

* fix the potential bug of recursive import

* fix unitest

* fix potiential bugs

* remove unneccesary change

* add more unitest

* fix add param in initweights

* add more comments

* raise error

* add more detail assert error
2021-08-11 22:05:44 +08:00
Jerry Jiarui XU c47c9196d0
[Docs] Add header for files (#1181)
* [Docs] Add header for files

* change to OpenMMLab

* add headers for .cpp, .cu, .h, .cuh

* replace Open-MMLab with OpenMMLab
2021-08-08 22:10:55 +08:00
Shilong Zhang 17fa6670eb
[Features] Add logger for initialization of parameters (#1150)
* add logger for init

* change init_info of oevrload init_weight

* add judgement for params_init_info

* add delete comments for params_init_info

* add docstr and more comments

* add docstr and more comments

* resolve comments

* dump to a file

* add unitest

* fix unitest

* fix unitest

* write to ori log

* fix typo

* resolve commnets
2021-07-23 21:07:54 +08:00
Haodong Duan ef48a47389
[Improvement] Improve digit_version & use it for version_checking (#1185)
* improve digit_version & use it for version_checking

* more testing for digit_version

* setuptools >= 50 is needed

* fix CI

* add debuging log

* >= to ==

* fix lint

* remove

* add failure case

* replace

* fix

* consider TORCH_VERSION == 'parrots'

* add unittest

* digit_version do not deal with the case if 'parrots' in version name.
2021-07-23 21:03:33 +08:00
Gu Wang 025ee9f5e6
[Feature] Add flat cosine lr updater (#1066)
* add flat cosine lr updater

* add test

* add doc

* update doc

* reformat

* update unittest

* update test flat cos

* remove momentum hook test

* update test

* change assert to ValueError

* fix unittest

* add by_epoch=True unittest

* change to start_percent

* change to start_percent in test
2021-07-20 17:16:50 +08:00
Y_Xuan 2dc0a219c1
[Feature] Porting mmcv for hip (#1022)
* porting mmcv for hip

* add nvcc

* fix format

* fix format

* fix bug for carafe

* fix test_utils because rocm_torch not allow set torch.backends.cudnn.benchmark to false

* add LOOSEVERSION

* fix format

* fix format of version

* fix code format

* test for yaml

* fix bug for citest

* fix bug for how to get torch._version_ at setup.py
2021-07-09 21:02:10 +08:00
Ma Zerun 1b15f02220
support print hooks before running. (#1123)
* support print using hooks before running.

* Support to print hook trigger stages.

* Print stage-wise hook infos. And make `stages` as class attribute of
`Hook`

* Add util function `is_method_overriden` and use it in
`Hook.get_trigger_stages`.

* Add unit tests.

* Move `is_method_overriden` to `mmcv/utils/misc.py`

* Improve hook info text.

* Add base_class argument type assertion, and fix some typos.

* Remove `get_trigger_stages` to `get_triggered_stages`

* Use f-string.
2021-06-25 20:49:24 +08:00
Ma Zerun 6fe3722510
Refine default hooks and custom hooks priority rank. (#1120)
* Refine default hooks and custom hooks priority rank.

* Add unit tests for custom hooks with string priority.

* Use priority `ABOVE_NORMAL` and `BELOW_NORMAL` instead of `HIGHER` and
`LOWER`.

And add unit tests for custom hook with the same priority as
default hooks.
2021-06-25 15:07:32 +08:00
Yining Li 560719da41
EvalHook uses case-insensitive key indicator matching and configurabl… (#1076)
* EvalHook uses case-insensitive key indicator matching and configurable test functions

* * fix docstring

* * move test_fn import into __init__
* configurable greater/less keys

* * update unittest
* update DistEvalHook

* fix comments and remove debug code

* support single greater/less key
2021-06-24 22:08:48 +08:00
David de la Iglesia Castro bdd7022143
Add DvcliveLoggerHook (#1075)
* Add dvclive logger hook

* Move docstring to class

* docstring updates
2021-06-08 22:20:33 +08:00
fcakyon e9f2a02b47
add neptune.ai logger hook (#1025)
* add neptune.ai logger hook

* add docstring

* move docstring

* update docstr

* update before_run
2021-05-23 15:28:21 +08:00
Ma Zerun 15bcaa9c05
Add custom hook by config file (#970)
* Assign different priority to default hooks, and add custom hook register in base runner.

* Add custom hook register in example train file

* Add unittest of custom hook

* Code format
2021-05-13 20:29:17 +08:00
Jintao Lin 4c2b05f9b8
Load `hook_msgs` when resume checkpoint (#962) 2021-05-13 09:54:38 +08:00
Ziyi Wu c77e95a65f
[Enhance] Add step momentum updater to support MMDet3D (#1011)
* add StepMomentumUpdaterHook

* add unit test

* fix typos

* refactor step updater

* replace stage with exp

* fix linting error

* use all() operation
2021-05-11 20:06:04 +08:00
gengenkai 1a5bf76237
[Enhancement] LR triangular (#1001)
* [Fix] lr add triangular

* [Fix] lr_triangular

* lr add docstring

* lr add docstring

* add unittest of triangular lr update
2021-05-11 13:25:43 +08:00
Ziyi Wu 04346fc7d0
[Feature] Support clipping min_lr in StepLrUpdaterHook to help MMDet3D (#995)
* support clipping min_lr in StepLrUpdaterHook

* add docstring for StepLrUpdaterHook

* fix small bugs

* add unit test for StepLrUpdaterHook

* fix linting error
2021-04-27 20:53:29 +08:00
Miao Zheng a76416393c
[Fix] Rename init_weight to init_weights (#971)
* [Fix] Rename init_weight to init_weights

* warning msg
2021-04-20 14:49:42 +08:00
Miao Zheng 47825b194e
[Refactoring] Revise init_weight in BaseModule (#905)
* [Refactoring] Add deprecated API warning

* revise test

* fix lint

* fix lint
2021-04-10 21:20:53 +08:00
Miao Zheng 89efc607ef
[Fix] OneCycleLrUpdaterHook adds total_steps (#929)
* [Fix] OneCycleLrUpdaterHook interface

* revise according to comments

* revise according to comments

* add test

* fix lint

* revise according to comments

* minors

* add pytest param

* fix lint

* ci
2021-04-10 21:19:45 +08:00
zhouzaida d525cfde10
[Fix] Fix bug of lr updater hook (#907)
* [Fix] fix bug of lr update hook

* [Fix] fix bug of lr update hook

* [Fix] Fix bug of lr updater hook
2021-04-09 10:13:32 +08:00
Jintao Lin be6541d480
[Feature] Add EvalHook which will be used in downstream projects (#739)
* add EvalHook

* add EvalHook

* refactor docstring

* polish

* use cp instead symlink

* add error info

* Update eval.py

* Update eval.py

* update

* add engine depandancy

* add comments

* fix unittest

* fix

* update unittest

* update unittest

* add docstring

* fix docstring
2021-04-08 16:42:30 +08:00
zhouzaida f0c43fdc32
[Feature] Add OneCycleLrUpdaterHook (#906)
* [Feature] Add OneCycleLrUpdaterHook

* fix docstring

* fix docstring

* Remove redundant code
2021-04-02 09:44:18 +08:00
Miao Zheng 65fec73509
[Refactoring] Revise function of layers and override keys in init_cfg (#893)
* [Refactoring]Approve init_cfg

* revise unit test

* revise according to comments

* add comment for wholemodule
2021-03-26 16:57:59 +08:00