diff --git a/.gitignore b/.gitignore index 5e8df67f..5a48f344 100644 --- a/.gitignore +++ b/.gitignore @@ -64,7 +64,9 @@ instance/ # Sphinx documentation docs/en/_build/ +docs/en/api/generated/ docs/zh_cn/_build/ +docs/zh_cn/api/generated/ src/ # PyBuilder diff --git a/docs/en/_static/css/readthedocs.css b/docs/en/_static/css/readthedocs.css new file mode 100644 index 00000000..f872dfa1 --- /dev/null +++ b/docs/en/_static/css/readthedocs.css @@ -0,0 +1,3 @@ +table.colwidths-auto td { + width: 50% +} diff --git a/docs/en/_templates/classtemplate.rst b/docs/en/_templates/classtemplate.rst new file mode 100644 index 00000000..4f748423 --- /dev/null +++ b/docs/en/_templates/classtemplate.rst @@ -0,0 +1,14 @@ +.. role:: hidden + :class: hidden-section +.. currentmodule:: {{ module }} + + +{{ name | underline}} + +.. autoclass:: {{ name }} + :members: + + +.. + autogenerated from source/_templates/classtemplate.rst + note it does not have :inherited-members: diff --git a/docs/en/api.rst b/docs/en/api.rst deleted file mode 100644 index 48254b97..00000000 --- a/docs/en/api.rst +++ /dev/null @@ -1,59 +0,0 @@ -Registry --------- -.. automodule:: mmengine.registry - :members: - -Config --------- -.. automodule:: mmengine.config - :members: - -Runner --------- -.. automodule:: mmengine.runner - :members: - -Hook --------- -.. automodule:: mmengine.hooks - :members: - -Optimizer ----------- -.. automodule:: mmengine.optim - :members: - -Data Structures ----------------- -.. automodule:: mmengine.structures - :members: - -Dataset ------------- -.. automodule:: mmengine.dataset - :members: - -Distributed ------------ -.. automodule:: mmengine.dist - :members: - -Logging --------- -.. automodule:: mmengine.logging - :members: - -Model --------- -.. automodule:: mmengine.model - :members: - -Visualization --------- -.. automodule:: mmengine.visualization - :members: - -Utils --------- -.. automodule:: mmengine.utils - :members: diff --git a/docs/en/api/config.rst b/docs/en/api/config.rst new file mode 100644 index 00000000..c6c066e6 --- /dev/null +++ b/docs/en/api/config.rst @@ -0,0 +1,16 @@ +.. role:: hidden + :class: hidden-section + +mmengine.config +=================================== + +.. currentmodule:: mmengine.config + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Config + ConfigDict + DictAction diff --git a/docs/en/api/dataset.rst b/docs/en/api/dataset.rst new file mode 100644 index 00000000..7f702b81 --- /dev/null +++ b/docs/en/api/dataset.rst @@ -0,0 +1,59 @@ +.. role:: hidden + :class: hidden-section + +mmengine.dataset +=================================== + +.. contents:: mmengine.dataset + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.dataset + +Dataset +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseDataset + Compose + force_full_init + +Dataset Wrapper +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + ClassBalancedDataset + ConcatDataset + RepeatDataset + +Sampler +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + DefaultSampler + InfiniteSampler + +Utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + default_collate + pseudo_collate + worker_init_fn diff --git a/docs/en/api/device.rst b/docs/en/api/device.rst new file mode 100644 index 00000000..2ae7c4e1 --- /dev/null +++ b/docs/en/api/device.rst @@ -0,0 +1,18 @@ +.. role:: hidden + :class: hidden-section + +mmengine.device +=================================== + +.. currentmodule:: mmengine.device + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_device + get_max_cuda_memory + is_cuda_available + is_mlu_available + is_mps_available diff --git a/docs/en/api/dist.rst b/docs/en/api/dist.rst new file mode 100644 index 00000000..e2d8487e --- /dev/null +++ b/docs/en/api/dist.rst @@ -0,0 +1,60 @@ +.. role:: hidden + :class: hidden-section + +mmengine.dist +=================================== + +.. contents:: mmengine.dist + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.dist + +dist +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + gather + gather_object + all_gather + all_gather_object + all_reduce + all_reduce_dict + all_reduce_params + broadcast + sync_random_seed + broadcast_object_list + collect_results + collect_results_cpu + collect_results_gpu + +utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_dist_info + init_dist + init_local_group + get_backend + get_world_size + get_rank + get_local_size + get_local_rank + is_main_process + master_only + barrier + is_distributed + get_local_group + get_default_group + get_data_device + get_comm_device + cast_data_device diff --git a/docs/en/api/evaluator.rst b/docs/en/api/evaluator.rst new file mode 100644 index 00000000..64c1beb1 --- /dev/null +++ b/docs/en/api/evaluator.rst @@ -0,0 +1,44 @@ +.. role:: hidden + :class: hidden-section + +mmengine.evaluator +=================================== + +.. contents:: mmengine.evaluator + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.evaluator + +Evaluator +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Evaluator + +Metric +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseMetric + + DumpResults + +Utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_metric_value diff --git a/docs/en/api/fileio.rst b/docs/en/api/fileio.rst new file mode 100644 index 00000000..a0e14518 --- /dev/null +++ b/docs/en/api/fileio.rst @@ -0,0 +1,64 @@ +.. role:: hidden + :class: hidden-section + +mmengine.fileio +=================================== + +.. contents:: mmengine.fileio + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.fileio + +File Client +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseStorageBackend + FileClient + HardDiskBackend + HTTPBackend + LmdbBackend + MemcachedBackend + PetrelBackend + +File Handler +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseFileHandler + JsonHandler + PickleHandler + YamlHandler + +File IO +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + dump + load + register_handler + +Parse File +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + dict_from_file + list_from_file diff --git a/docs/en/api/hooks.rst b/docs/en/api/hooks.rst new file mode 100644 index 00000000..c061246b --- /dev/null +++ b/docs/en/api/hooks.rst @@ -0,0 +1,24 @@ +.. role:: hidden + :class: hidden-section + +mmengine.hooks +=================================== + +.. currentmodule:: mmengine.hooks + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Hook + CheckpointHook + EMAHook + LoggerHook + NaiveVisualizationHook + ParamSchedulerHook + RuntimeInfoHook + DistSamplerSeedHook + IterTimerHook + SyncBuffersHook + EmptyCacheHook diff --git a/docs/en/api/hub.rst b/docs/en/api/hub.rst new file mode 100644 index 00000000..768cea48 --- /dev/null +++ b/docs/en/api/hub.rst @@ -0,0 +1,15 @@ +.. role:: hidden + :class: hidden-section + +mmengine.hub +=================================== + +.. currentmodule:: mmengine.hub + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_config + get_config diff --git a/docs/en/api/logging.rst b/docs/en/api/logging.rst new file mode 100644 index 00000000..8ed5512d --- /dev/null +++ b/docs/en/api/logging.rst @@ -0,0 +1,17 @@ +.. role:: hidden + :class: hidden-section + +mmengine.logging +=================================== + +.. currentmodule:: mmengine.logging + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + MMLogger + MessageHub + HistoryBuffer + print_log diff --git a/docs/en/api/model.rst b/docs/en/api/model.rst new file mode 100644 index 00000000..3299dea2 --- /dev/null +++ b/docs/en/api/model.rst @@ -0,0 +1,104 @@ +.. role:: hidden + :class: hidden-section + +mmengine.model +=================================== + +.. contents:: mmengine.model + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.model + +Module +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseModule + ModuleDict + ModuleList + Sequential + +Model +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseModel + BaseDataPreprocessor + ImgDataPreprocessor + +EMA +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseAveragedModel + ExponentialMovingAverage + MomentumAnnealingEMA + StochasticWeightAverage + +Model Wrapper +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + MMDistributedDataParallel + MMSeparateDistributedDataParallel + MMFullyShardedDataParallel + is_model_wrapper + +Weight Initialization +---------------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseInit + Caffe2XavierInit + ConstantInit + KaimingInit + NormalInit + PretrainedInit + TruncNormalInit + UniformInit + XavierInit + bias_init_with_prob + caffe2_xavier_init + constant_init + initialize + kaiming_init + normal_init + trunc_normal_init + uniform_init + update_init_info + xavier_init + +Utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + detect_anomalous_params + merge_dict + stack_batch + revert_sync_batchnorm diff --git a/docs/en/api/optim.rst b/docs/en/api/optim.rst new file mode 100644 index 00000000..4e21a62d --- /dev/null +++ b/docs/en/api/optim.rst @@ -0,0 +1,59 @@ +.. role:: hidden + :class: hidden-section + +mmengine.optim +=================================== + +.. contents:: mmengine.optim + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.optim + +Optimizer +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + AmpOptimWrapper + OptimWrapper + OptimWrapperDict + DefaultOptimWrapperConstructor + build_optim_wrapper + +Scheduler +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + _ParamScheduler + ConstantLR + ConstantMomentum + ConstantParamScheduler + CosineAnnealingLR + CosineAnnealingMomentum + CosineAnnealingParamScheduler + ExponentialLR + ExponentialMomentum + ExponentialParamScheduler + LinearLR + LinearMomentum + LinearParamScheduler + MultiStepLR + MultiStepMomentum + MultiStepParamScheduler + OneCycleLR + OneCycleParamScheduler + PolyLR + PolyMomentum + PolyParamScheduler + StepLR + StepMomentum + StepParamScheduler diff --git a/docs/en/api/registry.rst b/docs/en/api/registry.rst new file mode 100644 index 00000000..fc3cbb52 --- /dev/null +++ b/docs/en/api/registry.rst @@ -0,0 +1,21 @@ +.. role:: hidden + :class: hidden-section + +mmengine.registry +=================================== + +.. currentmodule:: mmengine.registry + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Registry + DefaultScope + build_from_cfg + build_model_from_cfg + build_runner_from_cfg + build_scheduler_from_cfg + count_registered_modules + traverse_registry_tree diff --git a/docs/en/api/runner.rst b/docs/en/api/runner.rst new file mode 100644 index 00000000..bc25d987 --- /dev/null +++ b/docs/en/api/runner.rst @@ -0,0 +1,78 @@ +.. role:: hidden + :class: hidden-section + +mmengine.runner +=================================== + +.. contents:: mmengine.runner + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.runner + +Runner +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Runner + +Loop +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseLoop + EpochBasedTrainLoop + IterBasedTrainLoop + ValLoop + TestLoop + +Checkpoints +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + CheckpointLoader + find_latest_checkpoint + get_deprecated_model_names + get_external_models + get_mmcls_models + get_state_dict + get_torchvision_models + load_checkpoint + load_state_dict + save_checkpoint + weights_to_cpu + +AMP +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + autocast + +Miscellaneous +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + LogProcessor + Priority + get_priority diff --git a/docs/en/api/structures.rst b/docs/en/api/structures.rst new file mode 100644 index 00000000..bfb651be --- /dev/null +++ b/docs/en/api/structures.rst @@ -0,0 +1,22 @@ +.. role:: hidden + :class: hidden-section + +mmengine.structures +=================================== + +.. contents:: mmengine.structures + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.structures + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseDataElement + InstanceData + LabelData + PixelData diff --git a/docs/en/api/utils.dl_utils.rst b/docs/en/api/utils.dl_utils.rst new file mode 100644 index 00000000..772fe6d9 --- /dev/null +++ b/docs/en/api/utils.dl_utils.rst @@ -0,0 +1,24 @@ +.. role:: hidden + :class: hidden-section + +mmengine.utils.dl_utils +=================================== + +.. currentmodule:: mmengine.utils.dl_utils + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + collect_env + load_url + has_batch_norm + is_norm + mmcv_full_available + tensor2imgs + TORCH_VERSION + set_multi_processing + TimeCounter + torch_meshgrid + is_jit_tracing diff --git a/docs/en/api/utils.rst b/docs/en/api/utils.rst new file mode 100644 index 00000000..07617da9 --- /dev/null +++ b/docs/en/api/utils.rst @@ -0,0 +1,110 @@ +.. role:: hidden + :class: hidden-section + +mmengine.utils +=================================== + +.. contents:: mmengine.utils + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.utils + +Manager +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + ManagerMeta + ManagerMixin + +Path +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + check_file_exist + fopen + is_abs + is_filepath + mkdir_or_exist + scandir + symlink + +Package +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + call_command + check_install_package + get_installed_path + is_installed + +Version +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + digit_version + get_git_hash + +Progress Bar +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + ProgressBar + track_iter_progress + track_parallel_progress + track_progress + + +Miscellaneous +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + is_list_of + is_tuple_of + is_seq_of + is_str + iter_cast + list_cast + tuple_cast + concat_list + slice_list + to_1tuple + to_2tuple + to_3tuple + to_4tuple + to_ntuple + check_prerequisites + deprecated_api_warning + has_method + is_method_overridden + import_modules_from_strings + requires_executable + requires_package + Timer + TimerError + check_time diff --git a/docs/en/api/visualization.rst b/docs/en/api/visualization.rst new file mode 100644 index 00000000..5265dc6e --- /dev/null +++ b/docs/en/api/visualization.rst @@ -0,0 +1,35 @@ +.. role:: hidden + :class: hidden-section + +mmengine.visualization +=================================== + +.. contents:: mmengine.visualization + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.visualization + +Visualizer +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Visualizer + +visualization Backend +--------------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseVisBackend + LocalVisBackend + TensorboardVisBackend + WandbVisBackend diff --git a/docs/en/conf.py b/docs/en/conf.py index d0045bc6..aeb1d31e 100644 --- a/docs/en/conf.py +++ b/docs/en/conf.py @@ -40,6 +40,8 @@ release = __version__ extensions = [ 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', 'sphinx.ext.napoleon', 'sphinx.ext.viewcode', 'sphinx.ext.autosectionlabel', @@ -50,6 +52,14 @@ extensions = [ ] # yapf: disable autodoc_typehints = 'description' +# Configuration for intersphinx +intersphinx_mapping = { + 'python': ('https://docs.python.org/3', None), + 'numpy': ('https://numpy.org/doc/stable', None), + 'torch': ('https://pytorch.org/docs/stable/', None), + 'mmcv': ('https://mmcv.readthedocs.io/en/dev-2.x/', None), +} + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -81,6 +91,7 @@ html_theme_options = { # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] +html_css_files = ['css/readthedocs.css'] # -- Extension configuration ------------------------------------------------- # Ignore >>> when copying code diff --git a/docs/en/docutils.conf b/docs/en/docutils.conf new file mode 100644 index 00000000..0c00c846 --- /dev/null +++ b/docs/en/docutils.conf @@ -0,0 +1,2 @@ +[html writers] +table_style: colwidths-auto diff --git a/docs/en/index.rst b/docs/en/index.rst index 5d55908c..c97efb63 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -9,10 +9,26 @@ You can switch between Chinese and English documents in the lower-left corner of tutorials/registry.md .. toctree:: - :maxdepth: 2 + :maxdepth: 1 :caption: API Reference - api.rst + mmengine.registry <api/registry> + mmengine.config <api/config> + mmengine.runner <api/runner> + mmengine.hooks <api/hooks> + mmengine.model <api/model> + mmengine.optim <api/optim> + mmengine.evaluator <api/evaluator> + mmengine.structures <api/structures> + mmengine.dataset <api/dataset> + mmengine.device <api/device> + mmengine.hub <api/hub> + mmengine.logging <api/logging> + mmengine.visualization <api/visualization> + mmengine.fileio <api/fileio> + mmengine.dist <api/dist> + mmengine.utils <api/utils> + mmengine.utils.dl_utils <api/utils.dl_utils> .. toctree:: :caption: Switch Language diff --git a/docs/zh_cn/_static/css/readthedocs.css b/docs/zh_cn/_static/css/readthedocs.css new file mode 100644 index 00000000..f872dfa1 --- /dev/null +++ b/docs/zh_cn/_static/css/readthedocs.css @@ -0,0 +1,3 @@ +table.colwidths-auto td { + width: 50% +} diff --git a/docs/zh_cn/_templates/classtemplate.rst b/docs/zh_cn/_templates/classtemplate.rst new file mode 100644 index 00000000..4f748423 --- /dev/null +++ b/docs/zh_cn/_templates/classtemplate.rst @@ -0,0 +1,14 @@ +.. role:: hidden + :class: hidden-section +.. currentmodule:: {{ module }} + + +{{ name | underline}} + +.. autoclass:: {{ name }} + :members: + + +.. + autogenerated from source/_templates/classtemplate.rst + note it does not have :inherited-members: diff --git a/docs/zh_cn/api.rst b/docs/zh_cn/api.rst deleted file mode 100644 index 48254b97..00000000 --- a/docs/zh_cn/api.rst +++ /dev/null @@ -1,59 +0,0 @@ -Registry --------- -.. automodule:: mmengine.registry - :members: - -Config --------- -.. automodule:: mmengine.config - :members: - -Runner --------- -.. automodule:: mmengine.runner - :members: - -Hook --------- -.. automodule:: mmengine.hooks - :members: - -Optimizer ----------- -.. automodule:: mmengine.optim - :members: - -Data Structures ----------------- -.. automodule:: mmengine.structures - :members: - -Dataset ------------- -.. automodule:: mmengine.dataset - :members: - -Distributed ------------ -.. automodule:: mmengine.dist - :members: - -Logging --------- -.. automodule:: mmengine.logging - :members: - -Model --------- -.. automodule:: mmengine.model - :members: - -Visualization --------- -.. automodule:: mmengine.visualization - :members: - -Utils --------- -.. automodule:: mmengine.utils - :members: diff --git a/docs/zh_cn/api/config.rst b/docs/zh_cn/api/config.rst new file mode 100644 index 00000000..c6c066e6 --- /dev/null +++ b/docs/zh_cn/api/config.rst @@ -0,0 +1,16 @@ +.. role:: hidden + :class: hidden-section + +mmengine.config +=================================== + +.. currentmodule:: mmengine.config + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Config + ConfigDict + DictAction diff --git a/docs/zh_cn/api/dataset.rst b/docs/zh_cn/api/dataset.rst new file mode 100644 index 00000000..7f702b81 --- /dev/null +++ b/docs/zh_cn/api/dataset.rst @@ -0,0 +1,59 @@ +.. role:: hidden + :class: hidden-section + +mmengine.dataset +=================================== + +.. contents:: mmengine.dataset + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.dataset + +Dataset +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseDataset + Compose + force_full_init + +Dataset Wrapper +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + ClassBalancedDataset + ConcatDataset + RepeatDataset + +Sampler +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + DefaultSampler + InfiniteSampler + +Utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + default_collate + pseudo_collate + worker_init_fn diff --git a/docs/zh_cn/api/device.rst b/docs/zh_cn/api/device.rst new file mode 100644 index 00000000..2ae7c4e1 --- /dev/null +++ b/docs/zh_cn/api/device.rst @@ -0,0 +1,18 @@ +.. role:: hidden + :class: hidden-section + +mmengine.device +=================================== + +.. currentmodule:: mmengine.device + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_device + get_max_cuda_memory + is_cuda_available + is_mlu_available + is_mps_available diff --git a/docs/zh_cn/api/dist.rst b/docs/zh_cn/api/dist.rst new file mode 100644 index 00000000..e2d8487e --- /dev/null +++ b/docs/zh_cn/api/dist.rst @@ -0,0 +1,60 @@ +.. role:: hidden + :class: hidden-section + +mmengine.dist +=================================== + +.. contents:: mmengine.dist + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.dist + +dist +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + gather + gather_object + all_gather + all_gather_object + all_reduce + all_reduce_dict + all_reduce_params + broadcast + sync_random_seed + broadcast_object_list + collect_results + collect_results_cpu + collect_results_gpu + +utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_dist_info + init_dist + init_local_group + get_backend + get_world_size + get_rank + get_local_size + get_local_rank + is_main_process + master_only + barrier + is_distributed + get_local_group + get_default_group + get_data_device + get_comm_device + cast_data_device diff --git a/docs/zh_cn/api/evaluator.rst b/docs/zh_cn/api/evaluator.rst new file mode 100644 index 00000000..64c1beb1 --- /dev/null +++ b/docs/zh_cn/api/evaluator.rst @@ -0,0 +1,44 @@ +.. role:: hidden + :class: hidden-section + +mmengine.evaluator +=================================== + +.. contents:: mmengine.evaluator + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.evaluator + +Evaluator +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Evaluator + +Metric +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseMetric + + DumpResults + +Utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_metric_value diff --git a/docs/zh_cn/api/fileio.rst b/docs/zh_cn/api/fileio.rst new file mode 100644 index 00000000..a0e14518 --- /dev/null +++ b/docs/zh_cn/api/fileio.rst @@ -0,0 +1,64 @@ +.. role:: hidden + :class: hidden-section + +mmengine.fileio +=================================== + +.. contents:: mmengine.fileio + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.fileio + +File Client +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseStorageBackend + FileClient + HardDiskBackend + HTTPBackend + LmdbBackend + MemcachedBackend + PetrelBackend + +File Handler +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseFileHandler + JsonHandler + PickleHandler + YamlHandler + +File IO +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + dump + load + register_handler + +Parse File +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + dict_from_file + list_from_file diff --git a/docs/zh_cn/api/hooks.rst b/docs/zh_cn/api/hooks.rst new file mode 100644 index 00000000..c061246b --- /dev/null +++ b/docs/zh_cn/api/hooks.rst @@ -0,0 +1,24 @@ +.. role:: hidden + :class: hidden-section + +mmengine.hooks +=================================== + +.. currentmodule:: mmengine.hooks + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Hook + CheckpointHook + EMAHook + LoggerHook + NaiveVisualizationHook + ParamSchedulerHook + RuntimeInfoHook + DistSamplerSeedHook + IterTimerHook + SyncBuffersHook + EmptyCacheHook diff --git a/docs/zh_cn/api/hub.rst b/docs/zh_cn/api/hub.rst new file mode 100644 index 00000000..768cea48 --- /dev/null +++ b/docs/zh_cn/api/hub.rst @@ -0,0 +1,15 @@ +.. role:: hidden + :class: hidden-section + +mmengine.hub +=================================== + +.. currentmodule:: mmengine.hub + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + get_config + get_config diff --git a/docs/zh_cn/api/logging.rst b/docs/zh_cn/api/logging.rst new file mode 100644 index 00000000..8ed5512d --- /dev/null +++ b/docs/zh_cn/api/logging.rst @@ -0,0 +1,17 @@ +.. role:: hidden + :class: hidden-section + +mmengine.logging +=================================== + +.. currentmodule:: mmengine.logging + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + MMLogger + MessageHub + HistoryBuffer + print_log diff --git a/docs/zh_cn/api/model.rst b/docs/zh_cn/api/model.rst new file mode 100644 index 00000000..3299dea2 --- /dev/null +++ b/docs/zh_cn/api/model.rst @@ -0,0 +1,104 @@ +.. role:: hidden + :class: hidden-section + +mmengine.model +=================================== + +.. contents:: mmengine.model + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.model + +Module +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseModule + ModuleDict + ModuleList + Sequential + +Model +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseModel + BaseDataPreprocessor + ImgDataPreprocessor + +EMA +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseAveragedModel + ExponentialMovingAverage + MomentumAnnealingEMA + StochasticWeightAverage + +Model Wrapper +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + MMDistributedDataParallel + MMSeparateDistributedDataParallel + MMFullyShardedDataParallel + is_model_wrapper + +Weight Initialization +---------------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseInit + Caffe2XavierInit + ConstantInit + KaimingInit + NormalInit + PretrainedInit + TruncNormalInit + UniformInit + XavierInit + bias_init_with_prob + caffe2_xavier_init + constant_init + initialize + kaiming_init + normal_init + trunc_normal_init + uniform_init + update_init_info + xavier_init + +Utils +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + detect_anomalous_params + merge_dict + stack_batch + revert_sync_batchnorm diff --git a/docs/zh_cn/api/optim.rst b/docs/zh_cn/api/optim.rst new file mode 100644 index 00000000..4e21a62d --- /dev/null +++ b/docs/zh_cn/api/optim.rst @@ -0,0 +1,59 @@ +.. role:: hidden + :class: hidden-section + +mmengine.optim +=================================== + +.. contents:: mmengine.optim + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.optim + +Optimizer +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + AmpOptimWrapper + OptimWrapper + OptimWrapperDict + DefaultOptimWrapperConstructor + build_optim_wrapper + +Scheduler +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + _ParamScheduler + ConstantLR + ConstantMomentum + ConstantParamScheduler + CosineAnnealingLR + CosineAnnealingMomentum + CosineAnnealingParamScheduler + ExponentialLR + ExponentialMomentum + ExponentialParamScheduler + LinearLR + LinearMomentum + LinearParamScheduler + MultiStepLR + MultiStepMomentum + MultiStepParamScheduler + OneCycleLR + OneCycleParamScheduler + PolyLR + PolyMomentum + PolyParamScheduler + StepLR + StepMomentum + StepParamScheduler diff --git a/docs/zh_cn/api/registry.rst b/docs/zh_cn/api/registry.rst new file mode 100644 index 00000000..fc3cbb52 --- /dev/null +++ b/docs/zh_cn/api/registry.rst @@ -0,0 +1,21 @@ +.. role:: hidden + :class: hidden-section + +mmengine.registry +=================================== + +.. currentmodule:: mmengine.registry + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Registry + DefaultScope + build_from_cfg + build_model_from_cfg + build_runner_from_cfg + build_scheduler_from_cfg + count_registered_modules + traverse_registry_tree diff --git a/docs/zh_cn/api/runner.rst b/docs/zh_cn/api/runner.rst new file mode 100644 index 00000000..bc25d987 --- /dev/null +++ b/docs/zh_cn/api/runner.rst @@ -0,0 +1,78 @@ +.. role:: hidden + :class: hidden-section + +mmengine.runner +=================================== + +.. contents:: mmengine.runner + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.runner + +Runner +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Runner + +Loop +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseLoop + EpochBasedTrainLoop + IterBasedTrainLoop + ValLoop + TestLoop + +Checkpoints +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + CheckpointLoader + find_latest_checkpoint + get_deprecated_model_names + get_external_models + get_mmcls_models + get_state_dict + get_torchvision_models + load_checkpoint + load_state_dict + save_checkpoint + weights_to_cpu + +AMP +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + autocast + +Miscellaneous +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + LogProcessor + Priority + get_priority diff --git a/docs/zh_cn/api/structures.rst b/docs/zh_cn/api/structures.rst new file mode 100644 index 00000000..bfb651be --- /dev/null +++ b/docs/zh_cn/api/structures.rst @@ -0,0 +1,22 @@ +.. role:: hidden + :class: hidden-section + +mmengine.structures +=================================== + +.. contents:: mmengine.structures + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.structures + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseDataElement + InstanceData + LabelData + PixelData diff --git a/docs/zh_cn/api/utils.dl_utils.rst b/docs/zh_cn/api/utils.dl_utils.rst new file mode 100644 index 00000000..772fe6d9 --- /dev/null +++ b/docs/zh_cn/api/utils.dl_utils.rst @@ -0,0 +1,24 @@ +.. role:: hidden + :class: hidden-section + +mmengine.utils.dl_utils +=================================== + +.. currentmodule:: mmengine.utils.dl_utils + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + collect_env + load_url + has_batch_norm + is_norm + mmcv_full_available + tensor2imgs + TORCH_VERSION + set_multi_processing + TimeCounter + torch_meshgrid + is_jit_tracing diff --git a/docs/zh_cn/api/utils.rst b/docs/zh_cn/api/utils.rst new file mode 100644 index 00000000..07617da9 --- /dev/null +++ b/docs/zh_cn/api/utils.rst @@ -0,0 +1,110 @@ +.. role:: hidden + :class: hidden-section + +mmengine.utils +=================================== + +.. contents:: mmengine.utils + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.utils + +Manager +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + ManagerMeta + ManagerMixin + +Path +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + check_file_exist + fopen + is_abs + is_filepath + mkdir_or_exist + scandir + symlink + +Package +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + call_command + check_install_package + get_installed_path + is_installed + +Version +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + digit_version + get_git_hash + +Progress Bar +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + ProgressBar + track_iter_progress + track_parallel_progress + track_progress + + +Miscellaneous +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + is_list_of + is_tuple_of + is_seq_of + is_str + iter_cast + list_cast + tuple_cast + concat_list + slice_list + to_1tuple + to_2tuple + to_3tuple + to_4tuple + to_ntuple + check_prerequisites + deprecated_api_warning + has_method + is_method_overridden + import_modules_from_strings + requires_executable + requires_package + Timer + TimerError + check_time diff --git a/docs/zh_cn/api/visualization.rst b/docs/zh_cn/api/visualization.rst new file mode 100644 index 00000000..5265dc6e --- /dev/null +++ b/docs/zh_cn/api/visualization.rst @@ -0,0 +1,35 @@ +.. role:: hidden + :class: hidden-section + +mmengine.visualization +=================================== + +.. contents:: mmengine.visualization + :depth: 2 + :local: + :backlinks: top + +.. currentmodule:: mmengine.visualization + +Visualizer +---------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + Visualizer + +visualization Backend +--------------------- + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: classtemplate.rst + + BaseVisBackend + LocalVisBackend + TensorboardVisBackend + WandbVisBackend diff --git a/docs/zh_cn/conf.py b/docs/zh_cn/conf.py index 809f8f4e..7906eac4 100644 --- a/docs/zh_cn/conf.py +++ b/docs/zh_cn/conf.py @@ -44,6 +44,8 @@ language = 'zh_CN' extensions = [ 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', 'sphinx.ext.napoleon', 'sphinx.ext.viewcode', 'sphinx.ext.autosectionlabel', @@ -54,6 +56,14 @@ extensions = [ ] # yapf: disable autodoc_typehints = 'description' +# Configuration for intersphinx +intersphinx_mapping = { + 'python': ('https://docs.python.org/3', None), + 'numpy': ('https://numpy.org/doc/stable', None), + 'torch': ('https://pytorch.org/docs/stable/', None), + 'mmcv': ('https://mmcv.readthedocs.io/en/dev-2.x/', None), +} + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -85,6 +95,7 @@ html_theme_options = { # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] +html_css_files = ['css/readthedocs.css'] # -- Extension configuration ------------------------------------------------- # Ignore >>> when copying code diff --git a/docs/zh_cn/design/metric_and_evaluator.md b/docs/zh_cn/design/evaluation.md similarity index 100% rename from docs/zh_cn/design/metric_and_evaluator.md rename to docs/zh_cn/design/evaluation.md diff --git a/docs/zh_cn/docutils.conf b/docs/zh_cn/docutils.conf new file mode 100644 index 00000000..0c00c846 --- /dev/null +++ b/docs/zh_cn/docutils.conf @@ -0,0 +1,2 @@ +[html writers] +table_style: colwidths-auto diff --git a/docs/zh_cn/get_started/introduction.md b/docs/zh_cn/get_started/introduction.md index 0838f67b..73e1cde2 100644 --- a/docs/zh_cn/get_started/introduction.md +++ b/docs/zh_cn/get_started/introduction.md @@ -3,18 +3,22 @@ MMEngine 是一个用于深度学习模型训练的基础库,基于 PyTorch,支持在 Linux、Windows、MacOS 上运行。它具有如下三个亮点: 1. 通用:MMEngine 实现了一个高级的通用训练器,它能够: - - 支持用少量代码训练不同的任务,例如仅使用 80 行代码就可以训练 imagenet(pytorch example 400 行) - - 轻松兼容流行的算法库如 TIMM、TorchVision 和 Detectron2 中的模型 + + - 支持用少量代码训练不同的任务,例如仅使用 80 行代码就可以训练 imagenet(pytorch example 400 行) + - 轻松兼容流行的算法库如 TIMM、TorchVision 和 Detectron2 中的模型 2. 统一:MMEngine 设计了一个接口统一的开放架构,使得 - - 用户可以仅依赖一份代码实现所有任务的轻量化,例如 MMRazor 1.x 相比 MMRazor 0.x 优化了 40% 的代码量 - - 上下游的对接更加统一便捷,在为上层算法库提供统一抽象的同时,支持多种后端设备。目前 MMEngine 支持 Nvidia CUDA、Mac MPS、AMD、MLU 等设备进行模型训练。 + + - 用户可以仅依赖一份代码实现所有任务的轻量化,例如 MMRazor 1.x 相比 MMRazor 0.x 优化了 40% 的代码量 + - 上下游的对接更加统一便捷,在为上层算法库提供统一抽象的同时,支持多种后端设备。目前 MMEngine 支持 Nvidia CUDA、Mac MPS、AMD、MLU 等设备进行模型训练。 + 3. 灵活:MMEngine 实现了“乐高”式的训练流程,支持了 - - 根据迭代数、 loss 和评测结果等动态调整的训练流程、优化策略和数据增强策略,例如早停(early stopping)机制等 - - 任意形式的模型权重平均,如 Exponential Momentum Average (EMA) 和 Stochastic Weight Averaging (SWA) - - 训练过程中针对任意数据和任意节点的灵活可视化和日志控制 - - 对神经网络模型中各个层的优化配置进行细粒度调整 - - 混合精度训练的灵活控制 + + - 根据迭代数、 loss 和评测结果等动态调整的训练流程、优化策略和数据增强策略,例如早停(early stopping)机制等 + - 任意形式的模型权重平均,如 Exponential Momentum Average (EMA) 和 Stochastic Weight Averaging (SWA) + - 训练过程中针对任意数据和任意节点的灵活可视化和日志控制 + - 对神经网络模型中各个层的优化配置进行细粒度调整 + - 混合精度训练的灵活控制 ### 架构 @@ -53,4 +57,4 @@ MMEngine 中还实现了各种算法模型执行过程中需要用到的公共 - [分布式通信原语(Distributed Communication Primitives)](../tutorials/distributed.md):负责在程序分布式运行过程中不同进程间的通信。这套接口屏蔽了分布式和非分布式环境的区别,同时也自动处理了数据的设备和通信后端。 - [其他工具(Utils)](../tutorials/utils.md):还有一些工具性的模块,如 ManagerMixin,它实现了一种全局变量的创建和获取方式,执行器内很多全局可见对象的基类就是 ManagerMixin。 -用户可以进一步阅读[教程]()来了解这些模块的高级用法,也可以参考[设计文档]() 了解它们的设计思路与细节。 +用户可以进一步阅读[教程](<>)来了解这些模块的高级用法,也可以参考[设计文档](<>) 了解它们的设计思路与细节。 diff --git a/docs/zh_cn/index.rst b/docs/zh_cn/index.rst index ad5c1791..6f0d4884 100644 --- a/docs/zh_cn/index.rst +++ b/docs/zh_cn/index.rst @@ -6,7 +6,9 @@ :maxdepth: 1 :caption: 开始你的第一步 + get_started/introduction.md get_started/installation.md + get_started/15_minutes.md .. toctree:: :maxdepth: 1 @@ -16,14 +18,16 @@ tutorials/config.md tutorials/runner.md tutorials/hook.md - tutorials/optimizer.md + tutorials/optim_wrapper.md tutorials/param_scheduler.md + tutorials/evaluation.md tutorials/data_element.md tutorials/basedataset.md - tutorials/evaluator.md tutorials/distributed.md tutorials/logging.md - tutorials/visualizer.md + tutorials/visualization.md + tutorials/fileio.md + tutorials/utils.md .. toctree:: :maxdepth: 1 @@ -32,12 +36,14 @@ examples/resume_training.md examples/speed_up_training.md examples/save_gpu_memory.md + examples/cross_library.md .. toctree:: :maxdepth: 1 :caption: 迁移指南 migration/migrate_hook_from_mmcv.md + migration/migrate_transform.md migration/migrate_param_scheduler_from_mmcv.md .. toctree:: @@ -46,6 +52,7 @@ design/hook.md design/runner.md + design/metric_and_evaluator.md design/visualization.md design/logging.md @@ -53,7 +60,23 @@ :maxdepth: 2 :caption: API 文档 - api.rst + mmengine.registry <api/registry> + mmengine.config <api/config> + mmengine.runner <api/runner> + mmengine.hooks <api/hooks> + mmengine.model <api/model> + mmengine.optim <api/optim> + mmengine.evaluator <api/evaluator> + mmengine.structures <api/structures> + mmengine.dataset <api/dataset> + mmengine.device <api/device> + mmengine.hub <api/hub> + mmengine.logging <api/logging> + mmengine.visualization <api/visualization> + mmengine.fileio <api/fileio> + mmengine.dist <api/dist> + mmengine.utils <api/utils> + mmengine.utils.dl_utils <api/utils.dl_utils> .. toctree:: :caption: 语言切换 diff --git a/docs/zh_cn/tutorials/evaluation.md b/docs/zh_cn/tutorials/evaluation.md index 01480584..8fd9e5c6 100644 --- a/docs/zh_cn/tutorials/evaluation.md +++ b/docs/zh_cn/tutorials/evaluation.md @@ -4,7 +4,7 @@ - 评测指标: 用于根据测试数据和模型预测结果,完成模型特定精度指标的计算。在 OpenMMLab 各算法库中提供了对应任务的常用评测指标,如 [MMClassification](https://github.com/open-mmlab/mmclassification) 中提供了[分类正确率指标(Accuracy)](https://mmclassification.readthedocs.io/zh_CN/dev-1.x/generated/mmcls.evaluation.Accuracy.html) 用于计算分类模型的 Top-k 分类正确率。 -- 评测器: 是评测指标的上层模块,用于在数据输入评测指标前完成必要的格式转换,并提供分布式支持。在模型训练和测试中,评测器由[执行器(Runner)](https://mmengine.readthedocs.io/zh_CN/latest/api/runner.html)自动构建。用户亦可根据需求手动创建评测器,进行离线评测。 +- 评测器: 是评测指标的上层模块,用于在数据输入评测指标前完成必要的格式转换,并提供分布式支持。在模型训练和测试中,评测器由[执行器(Runner)](runner.md)自动构建。用户亦可根据需求手动创建评测器,进行离线评测。 ## 在模型训练或测试中进行评测 @@ -37,7 +37,7 @@ test_evaluator = [ ### 自定义评测指标 -如果算法库中提供的常用评测指标无法满足需求,用户也可以增加自定义的评测指标。具体的方法可以参考[评测指标和评测器设计](/docs/zh_cn/design/metric_and_evaluator.md)。 +如果算法库中提供的常用评测指标无法满足需求,用户也可以增加自定义的评测指标。具体的方法可以参考[评测指标和评测器设计](../design/evaluation.md)。 ## 使用离线结果进行评测