Skip to content

Commit

Permalink
Fix ResourceWarning in Wandb and Update README.md (open-mmlab#8103)
Browse files Browse the repository at this point in the history
* add hint in wandb

* update readme

* update readme

* update hint of wandb
hhaAndroid authored Jun 1, 2022
1 parent 44af55f commit 51ad7cb
Showing 3 changed files with 129 additions and 64 deletions.
81 changes: 52 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,17 +2,17 @@
<img src="resources/mmdet-logo.png" width="600"/>
<div>&nbsp;</div>
<div align="center">
<b>OpenMMLab website</b>
<b><font size="5">OpenMMLab website</font></b>
<sup>
<a href="https://openmmlab.com">
<i>HOT</i>
<i><font size="4">HOT</font></i>
</a>
</sup>
&nbsp;&nbsp;&nbsp;&nbsp;
<b>OpenMMLab platform</b>
<b><font size="5">OpenMMLab platform</font></b>
<sup>
<a href="https://platform.openmmlab.com">
<i>TRY IT OUT</i>
<i><font size="4">TRY IT OUT</font></i>
</a>
</sup>
</div>
@@ -24,27 +24,32 @@
[![codecov](https://codecov.io/gh/open-mmlab/mmdetection/branch/master/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmdetection)
[![license](https://img.shields.io/github/license/open-mmlab/mmdetection.svg)](https://github.com/open-mmlab/mmdetection/blob/master/LICENSE)
[![open issues](https://isitmaintained.com/badge/open/open-mmlab/mmdetection.svg)](https://github.com/open-mmlab/mmdetection/issues)
[![issue resolution](https://isitmaintained.com/badge/resolution/open-mmlab/mmdetection.svg)](https://github.com/open-mmlab/mmdetection/issues)

<img src="https://user-images.githubusercontent.com/12907710/137271636-56ba1cd2-b110-4812-8221-b4c120320aa9.png"/>

[📘Documentation](https://mmdetection.readthedocs.io/en/v2.21.0/) |
[🛠️Installation](https://mmdetection.readthedocs.io/en/v2.21.0/get_started.html) |
[👀Model Zoo](https://mmdetection.readthedocs.io/en/v2.21.0/model_zoo.html) |
[🆕Update News](https://mmdetection.readthedocs.io/en/v2.21.0/changelog.html) |
[📘Documentation](https://mmdetection.readthedocs.io/en/stable/) |
[🛠️Installation](https://mmdetection.readthedocs.io/en/stable/get_started.html) |
[👀Model Zoo](https://mmdetection.readthedocs.io/en/stable/model_zoo.html) |
[🆕Update News](https://mmdetection.readthedocs.io/en/stable/changelog.html) |
[🚀Ongoing Projects](https://github.com/open-mmlab/mmdetection/projects) |
[🤔Reporting Issues](https://github.com/open-mmlab/mmdetection/issues/new/choose)

</div>

## Introduction
<div align="center">

English | [简体中文](README_zh-CN.md)

</div>

## Introduction

MMDetection is an open source object detection toolbox based on PyTorch. It is
a part of the [OpenMMLab](https://openmmlab.com/) project.

The master branch works with **PyTorch 1.5+**.

<img src="https://user-images.githubusercontent.com/12907710/137271636-56ba1cd2-b110-4812-8221-b4c120320aa9.png"/>

<details open>
<summary>Major features</summary>

@@ -68,22 +73,42 @@ The master branch works with **PyTorch 1.5+**.

Apart from MMDetection, we also released a library [mmcv](https://github.com/open-mmlab/mmcv) for computer vision research, which is heavily depended on by this toolbox.

## License
## What's New

This project is released under the [Apache 2.0 license](LICENSE).
**2.25.0** was released in 1/6/2022:

## Changelog

**2.24.1** was released in 30/4/2022:

- Support [Simple Copy Paste](configs/simple_copy_paste)
- Support automatically scaling LR according to GPU number and samples per GPU
- Support Class Aware Sampler that improves performance on OpenImages Dataset
- Support dedicated `MMDetWandbHook` hook
- Support [ConvNeXt](configs/convnext), [DDOD](configs/ddod), [SOLOv2](configs/solov2)
- Support [Mask2Former](configs/mask2former) for instance segmentation
- Rename [config files of Mask2Former](configs/mask2former)

Please refer to [changelog.md](docs/en/changelog.md) for details and release history.

For compatibility changes between different versions of MMDetection, please refer to [compatibility.md](docs/en/compatibility.md).

## Installation

Please refer to [Installation](docs/en/get_started.md/#Installation) for installation instructions.

## Getting Started

Please see [get_started.md](docs/en/get_started.md) for the basic usage of MMDetection. We provide [colab tutorial](demo/MMDet_Tutorial.ipynb) and [instance segmentation colab tutorial](demo/MMDet_InstanceSeg_Tutorial.ipynb), and other tutorials for:

- [with existing dataset](docs/en/1_exist_data_model.md)
- [with new dataset](docs/en/2_new_data_model.md)
- [with existing dataset_new_model](docs/en/3_exist_data_new_model.md)
- [learn about configs](docs/en/tutorials/config.md)
- [customize_datasets](docs/en/tutorials/customize_dataset.md)
- [customize data pipelines](docs/en/tutorials/data_pipeline.md)
- [customize_models](docs/en/tutorials/customize_models.md)
- [customize runtime settings](docs/en/tutorials/customize_runtime.md)
- [customize_losses](docs/en/tutorials/customize_losses.md)
- [finetuning models](docs/en/tutorials/finetune.md)
- [export a model to ONNX](docs/en/tutorials/pytorch2onnx.md)
- [export ONNX to TRT](docs/en/tutorials/onnx2tensorrt.md)
- [weight initialization](docs/en/tutorials/init_cfg.md)
- [how to xxx](docs/en/tutorials/how_to.md)

## Overview of Benchmark and Model Zoo

Results and models are available in the [model zoo](docs/en/model_zoo.md).
@@ -144,6 +169,7 @@ Results and models are available in the [model zoo](docs/en/model_zoo.md).
<li><a href="configs/yolox">YOLOX (CVPR'2021)</a></li>
<li><a href="configs/deformable_detr">Deformable DETR (ICLR'2021)</a></li>
<li><a href="configs/tood">TOOD (ICCV'2021)</a></li>
<li><a href="configs/ddod">DDOD (ACM MM'2021)</a></li>
</ul>
</td>
<td>
@@ -160,6 +186,7 @@ Results and models are available in the [model zoo](docs/en/model_zoo.md).
<li><a href="configs/solov2">SOLOv2 (NeurIPS'2020)</a></li>
<li><a href="configs/scnet">SCNet (AAAI'2021)</a></li>
<li><a href="configs/queryinst">QueryInst (ICCV'2021)</a></li>
<li><a href="configs/mask2former">Mask2Former (ArXiv'2021)</a></li>
</ul>
</td>
<td>
@@ -272,15 +299,7 @@ Results and models are available in the [model zoo](docs/en/model_zoo.md).

Some other methods are also supported in [projects using MMDetection](./docs/en/projects.md).

## Installation

Please refer to [get_started.md](docs/en/get_started.md) for installation.

## Getting Started

Please see [get_started.md](docs/en/get_started.md) for the basic usage of MMDetection.
We provide [detection colab tutorial](demo/MMDet_Tutorial.ipynb) and [instance segmentation colab tutorial](demo/MMDet_InstanceSeg_Tutorial.ipynb), and full guidance for quick run [with existing dataset](docs/en/1_exist_data_model.md) and [with new dataset](docs/en/2_new_data_model.md) for beginners.
There are also tutorials for [finetuning models](docs/en/tutorials/finetune.md), [adding new dataset](docs/en/tutorials/customize_dataset.md), [designing data pipeline](docs/en/tutorials/data_pipeline.md), [customizing models](docs/en/tutorials/customize_models.md), [customizing runtime settings](docs/en/tutorials/customize_runtime.md) and [useful tools](docs/en/useful_tools.md).
## FAQ

Please refer to [FAQ](docs/en/faq.md) for frequently asked questions.

@@ -311,6 +330,10 @@ If you use this toolbox or benchmark in your research, please cite this project.
}
```

## License

This project is released under the [Apache 2.0 license](LICENSE).

## Projects in OpenMMLab

- [MMCV](https://github.com/open-mmlab/mmcv): OpenMMLab foundational library for computer vision.
83 changes: 52 additions & 31 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
@@ -24,26 +24,31 @@
[![codecov](https://codecov.io/gh/open-mmlab/mmdetection/branch/master/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmdetection)
[![license](https://img.shields.io/github/license/open-mmlab/mmdetection.svg)](https://github.com/open-mmlab/mmdetection/blob/master/LICENSE)
[![open issues](https://isitmaintained.com/badge/open/open-mmlab/mmdetection.svg)](https://github.com/open-mmlab/mmdetection/issues)
[![issue resolution](https://isitmaintained.com/badge/resolution/open-mmlab/mmdetection.svg)](https://github.com/open-mmlab/mmdetection/issues)

<img src="https://user-images.githubusercontent.com/12907710/137271636-56ba1cd2-b110-4812-8221-b4c120320aa9.png"/>

[📘使用文档](https://mmdetection.readthedocs.io/zh_CN/v2.21.0/) |
[🛠️安装教程](https://mmdetection.readthedocs.io/zh_CN/v2.21.0/get_started.html) |
[👀模型库](https://mmdetection.readthedocs.io/zh_CN/v2.21.0/model_zoo.html) |
[🆕更新日志](https://mmdetection.readthedocs.io/en/v2.21.0/changelog.html) |
[📘使用文档](https://mmdetection.readthedocs.io/zh_CN/stable/) |
[🛠️安装教程](https://mmdetection.readthedocs.io/zh_CN/stable/get_started.html) |
[👀模型库](https://mmdetection.readthedocs.io/zh_CN/stable/model_zoo.html) |
[🆕更新日志](https://mmdetection.readthedocs.io/en/stable/changelog.html) |
[🚀进行中的项目](https://github.com/open-mmlab/mmdetection/projects) |
[🤔报告问题](https://github.com/open-mmlab/mmdetection/issues/new/choose)

</div>

## 简介
<div align="center">

[English](README.md) | 简体中文

</div>

## 简介

MMDetection 是一个基于 PyTorch 的目标检测开源工具箱。它是 [OpenMMLab](https://openmmlab.com/) 项目的一部分。

主分支代码目前支持 PyTorch 1.5 以上的版本。

<img src="https://user-images.githubusercontent.com/12907710/137271636-56ba1cd2-b110-4812-8221-b4c120320aa9.png"/>

<details open>
<summary>主要特性</summary>

@@ -67,22 +72,45 @@ MMDetection 是一个基于 PyTorch 的目标检测开源工具箱。它是 [Ope

除了 MMDetection 之外,我们还开源了计算机视觉基础库 [MMCV](https://github.com/open-mmlab/mmcv),MMCV 是 MMDetection 的主要依赖。

## 开源许可证

该项目采用 [Apache 2.0 开源许可证](LICENSE)

## 更新日志
## 最新进展

最新的 **2.24.1** 版本已经在 2022.04.30 发布:
最新的 **2.25.0** 版本已经在 2022.06.01 发布:

- 支持算法 [Simple Copy Paste](configs/simple_copy_paste)
- 支持训练时根据总 batch 数自动缩放学习率
- 支持类别可知的采样器来提高算法在 OpenImages 数据集上的性能
- 支持功能更丰富的 `MMDetWandbHook`
- 支持算法 [ConvNeXt](configs/convnext), [DDOD](configs/ddod)[SOLOv2](configs/solov2)
- [Mask2Former](configs/mask2former) 支持实例分割
- 为了加入 Mask2Former 实例分割的模型,对 Mask2Former 原有的全景分割的配置文件进行了重命名

如果想了解更多版本更新细节和历史信息,请阅读[更新日志](docs/en/changelog.md)

如果想了解 MMDetection 不同版本之间的兼容性, 请参考[兼容性说明文档](docs/zh_cn/compatibility.md)

## 安装

请参考[安装指令](docs/zh_cn/get_started.md/#Installation)进行安装。

## 教程

请参考[快速入门文档](docs/zh_cn/get_started.md)学习 MMDetection 的基本使用。
我们提供了 [检测的 colab 教程](demo/MMDet_Tutorial.ipynb)[实例分割的 colab 教程](demo/MMDet_InstanceSeg_Tutorial.ipynb),也为新手提供了完整的运行教程,其他教程如下

- [使用已有模型在标准数据集上进行推理](docs/zh_cn/1_exist_data_model.md)
- [在自定义数据集上进行训练](docs/zh_cn/2_new_data_model.md)
- [在标准数据集上训练自定义模型](docs/zh_cn/3_exist_data_new_model.md)
- [学习配置文件](docs/zh_cn/tutorials/config.md)
- [自定义数据集](docs/zh_cn/tutorials/customize_dataset.md)
- [自定义数据预处理流程](docs/zh_cn/tutorials/data_pipeline.md)
- [自定义模型](docs/zh_cn/tutorials/customize_models.md)
- [自定义训练配置](docs/zh_cn/tutorials/customize_runtime.md)
- [自定义损失函数](docs/zh_cn/tutorials/customize_losses.md)
- [模型微调](docs/zh_cn/tutorials/finetune.md)
- [Pytorch 到 ONNX 的模型转换](docs/zh_cn/tutorials/pytorch2onnx.md)
- [ONNX 到 TensorRT 的模型转换](docs/zh_cn/tutorials/onnx2tensorrt.md)
- [权重初始化](docs/zh_cn/tutorials/init_cfg.md)
- [how to xxx](docs/zh_cn/tutorials/how_to.md)

同时,我们还提供了 [MMDetection 中文解读文案汇总](docs/zh_cn/article.md)

## 基准测试和模型库

测试结果和模型可以在[模型库](docs/zh_cn/model_zoo.md)中找到。
@@ -143,6 +171,7 @@ MMDetection 是一个基于 PyTorch 的目标检测开源工具箱。它是 [Ope
<li><a href="configs/yolox">YOLOX (CVPR'2021)</a></li>
<li><a href="configs/deformable_detr">Deformable DETR (ICLR'2021)</a></li>
<li><a href="configs/tood">TOOD (ICCV'2021)</a></li>
<li><a href="configs/ddod">DDOD (ACM MM'2021)</a></li>
</ul>
</td>
<td>
@@ -159,6 +188,7 @@ MMDetection 是一个基于 PyTorch 的目标检测开源工具箱。它是 [Ope
<li><a href="configs/solov2">SOLOv2 (NeurIPS'2020)</a></li>
<li><a href="configs/scnet">SCNet (AAAI'2021)</a></li>
<li><a href="configs/queryinst">QueryInst (ICCV'2021)</a></li>
<li><a href="configs/mask2former">Mask2Former (ArXiv'2021)</a></li>
</ul>
</td>
<td>
@@ -271,22 +301,9 @@ MMDetection 是一个基于 PyTorch 的目标检测开源工具箱。它是 [Ope

我们在[基于 MMDetection 的项目](./docs/zh_cn/projects.md)中列举了一些其他的支持的算法。

## 安装

请参考[快速入门文档](docs/zh_cn/get_started.md)进行安装。

## 快速入门

请参考[快速入门文档](docs/zh_cn/get_started.md)学习 MMDetection 的基本使用。
我们提供了 [检测的 colab 教程](demo/MMDet_Tutorial.ipynb)[实例分割的 colab 教程](demo/MMDet_InstanceSeg_Tutorial.ipynb),也为新手提供了完整的运行教程,分别针对[已有数据集](docs/zh_cn/1_exist_data_model.md)[新数据集](docs/zh_cn/2_new_data_model.md) 完整的使用指南

我们也提供了一些进阶教程,内容覆盖了 [finetune 模型](docs/zh_cn/tutorials/finetune.md)[增加新数据集支持](docs/zh_cn/tutorials/customize_dataset.md)[设计新的数据预处理流程](docs/zh_cn/tutorials/data_pipeline.md)[增加自定义模型](docs/zh_cn/tutorials/customize_models.md)[增加自定义的运行时配置](docs/zh_cn/tutorials/customize_runtime.md)[常用工具和脚本](docs/zh_cn/useful_tools.md)

如果遇到问题,请参考 [常见问题解答](docs/zh_cn/faq.md)

## 相关教程
## 常见问题

请参考 [MMDetection 中文解读文案汇总](docs/zh_cn/article.md)
请参考 [FAQ](docs/zh_cn/faq.md) 了解其他用户的常见问题。

## 贡献指南

@@ -314,6 +331,10 @@ MMDetection 是一款由来自不同高校和企业的研发人员共同参与
}
```

## 开源许可证

该项目采用 [Apache 2.0 开源许可证](LICENSE)

## OpenMMLab 的其他项目

- [MMCV](https://github.com/open-mmlab/mmcv): OpenMMLab 计算机视觉基础库
29 changes: 25 additions & 4 deletions mmdet/core/hook/wandblogger_hook.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import importlib
import os.path as osp
import sys
import warnings

import mmcv
import numpy as np
@@ -10,6 +11,7 @@
from mmcv.runner.dist_utils import master_only
from mmcv.runner.hooks.checkpoint import CheckpointHook
from mmcv.runner.hooks.logger.wandb import WandbLoggerHook
from mmcv.utils import digit_version

from mmdet.core import DistEvalHook, EvalHook
from mmdet.core.mask.structures import polygon_to_bitmap
@@ -109,6 +111,25 @@ def __init__(self,
self.ckpt_hook: CheckpointHook = None
self.eval_hook: EvalHook = None

def import_wandb(self):
try:
import wandb
from wandb import init # noqa

# Fix ResourceWarning when calling wandb.log in wandb v0.12.10.
# https://github.com/wandb/client/issues/2837
if digit_version(wandb.__version__) < digit_version('0.12.10'):
warnings.warn(
f'The current wandb {wandb.__version__} is '
f'lower than v0.12.10 will cause ResourceWarning '
f'when calling wandb.log, Please run '
f'"pip install --upgrade wandb"')

except ImportError:
raise ImportError(
'Please run "pip install "wandb>=0.12.10"" to install wandb')
self.wandb = wandb

@master_only
def before_run(self, runner):
super(MMDetWandbHook, self).before_run(runner)
@@ -198,9 +219,9 @@ def after_train_epoch(self, runner):
}
else:
metadata = None
aliases = [f'epoch_{runner.epoch+1}', 'latest']
aliases = [f'epoch_{runner.epoch + 1}', 'latest']
model_path = osp.join(self.ckpt_hook.out_dir,
f'epoch_{runner.epoch+1}.pth')
f'epoch_{runner.epoch + 1}.pth')
self._log_ckpt_as_artifact(model_path, aliases, metadata)

# Save prediction table
@@ -238,9 +259,9 @@ def after_train_iter(self, runner):
}
else:
metadata = None
aliases = [f'iter_{runner.iter+1}', 'latest']
aliases = [f'iter_{runner.iter + 1}', 'latest']
model_path = osp.join(self.ckpt_hook.out_dir,
f'iter_{runner.iter+1}.pth')
f'iter_{runner.iter + 1}.pth')
self._log_ckpt_as_artifact(model_path, aliases, metadata)

# Save prediction table

0 comments on commit 51ad7cb

Please sign in to comment.