Skip to content

Commit

Permalink
Bump version to v0.1.3
Browse files Browse the repository at this point in the history
Bump version to v0.1.3
  • Loading branch information
hhaAndroid authored Nov 10, 2022
2 parents 0b48313 + abcde76 commit 178b0bf
Show file tree
Hide file tree
Showing 47 changed files with 753 additions and 323 deletions.
4 changes: 2 additions & 2 deletions .circleci/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
name: Install mmyolo dependencies
command: |
pip install -U openmim
mim install 'mmengine >= 0.3.0'
mim install 'mmengine >= 0.3.1'
mim install 'mmcv >= 2.0.0rc1'
pip install git+https://github.com/open-mmlab/[email protected]
pip install -r requirements/albu.txt
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
name: Install mmyolo dependencies
command: |
docker exec mmyolo pip install -U openmim
docker exec mmyolo mim install 'mmengine >= 0.3.0'
docker exec mmyolo mim install 'mmengine >= 0.3.1'
docker exec mmyolo mim install 'mmcv >= 2.0.0rc1'
docker exec mmyolo pip install -e /mmdetection
docker exec mmyolo pip install -r requirements/albu.txt
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@ The master branch works with **PyTorch 1.6+**.

MMYOLO decomposes the framework into different components where users can easily customize a model by combining different modules with various training and testing strategies.

<img src="https://user-images.githubusercontent.com/27466624/190986949-01414a91-baae-4228-8828-c59db58dcf36.jpg" alt="BaseModule"/>
The figure is contributed by RangeKing@GitHub, thank you very much!
<img src="https://user-images.githubusercontent.com/27466624/199999337-0544a4cb-3cbd-4f3e-be26-bcd9e74db7ff.jpg" alt="BaseModule-P5"/>
The figure above is contributed by RangeKing@GitHub, thank you very much!

And the figure of P6 model is in [model_design.md](docs/en/algorithm_descriptions/model_design.md).

</details>

## What's New

💎 **v0.1.3** was released on 10/11/2022:

1. Fix training failure when saving best weights based on mmengine 0.3.1
2. Fix `add_dump_metric` error based on mmdet 3.0.0rc3

💎 **v0.1.2** was released on 3/11/2022:

1. Support [YOLOv5/YOLOv6/YOLOX/RTMDet deployments](https://github.com/open-mmlab/mmyolo/blob/main/configs/deploy) for ONNXRuntime and TensorRT
Expand All @@ -88,9 +95,9 @@ MMYOLO relies on PyTorch, MMCV, MMEngine, and MMDetection. Below are quick steps
conda create -n open-mmlab python=3.8 pytorch==1.10.1 torchvision==0.11.2 cudatoolkit=11.3 -c pytorch -y
conda activate open-mmlab
pip install openmim
mim install "mmengine>=0.3.0"
mim install "mmengine>=0.3.1"
mim install "mmcv>=2.0.0rc1,<2.1.0"
mim install "mmdet>=3.0.0rc2,<3.1.0"
mim install "mmdet>=3.0.0rc3,<3.1.0"
git clone https://github.com/open-mmlab/mmyolo.git
cd mmyolo
# Install albumentations
Expand Down Expand Up @@ -135,6 +142,7 @@ For different parts from MMDetection, we have also prepared user guides and adva

- [Data flow](docs/en/advanced_guides/data_flow.md)
- [How to](docs/en/advanced_guides/how_to.md)
- [Plugins](docs/en/advanced_guides/plugins.md)

## Overview of Benchmark and Model Zoo

Expand Down
14 changes: 11 additions & 3 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@ MMYOLO 是一个基于 PyTorch 和 MMDetection 的 YOLO 系列算法开源工具

MMYOLO 将框架解耦成不同的模块组件,通过组合不同的模块和训练测试策略,用户可以便捷地构建自定义模型。

<img src="https://user-images.githubusercontent.com/27466624/190986949-01414a91-baae-4228-8828-c59db58dcf36.jpg" alt="基类"/>
<img src="https://user-images.githubusercontent.com/27466624/199999337-0544a4cb-3cbd-4f3e-be26-bcd9e74db7ff.jpg" alt="基类-P5"/>
图为 RangeKing@GitHub 提供,非常感谢!

P6 模型图详见 [model_design.md](docs/zh_CN/algorithm_descriptions/model_design.md)

</details>

## 最新进展

💎 **v0.1.3** 版本已经在 2022.11.10 发布:

1. 基于 mmengine 0.3.1 修复保存最好权重时训练失败问题
2. 基于 mmdet 3.0.0rc3 修复 `add_dump_metric` 报错 (#253)

💎 **v0.1.2** 版本已经在 2022.11.3 发布:

1. 支持 ONNXRuntime 和 TensorRT 的 [YOLOv5/YOLOv6/YOLOX/RTMDet 部署](https://github.com/open-mmlab/mmyolo/blob/main/configs/deploy)
Expand Down Expand Up @@ -97,9 +104,9 @@ MMYOLO 依赖 PyTorch, MMCV, MMEngine 和 MMDetection,以下是安装的简要
conda create -n open-mmlab python=3.8 pytorch==1.10.1 torchvision==0.11.2 cudatoolkit=11.3 -c pytorch -y
conda activate open-mmlab
pip install openmim
mim install "mmengine>=0.3.0"
mim install "mmengine>=0.3.1"
mim install "mmcv>=2.0.0rc1,<2.1.0"
mim install "mmdet>=3.0.0rc2,<3.1.0"
mim install "mmdet>=3.0.0rc3,<3.1.0"
git clone https://github.com/open-mmlab/mmyolo.git
cd mmyolo
# Install albumentations
Expand Down Expand Up @@ -145,6 +152,7 @@ MMYOLO 用法和 MMDetection 几乎一致,所有教程都是通用的,你也

- [数据流](docs/zh_cn/advanced_guides/data_flow.md)
- [How to](docs/zh_cn/advanced_guides/how_to.md)
- [插件](docs/zh_cn/advanced_guides/plugins.md)

- [解读文章和资源汇总](docs/zh_cn/article.md)

Expand Down
14 changes: 7 additions & 7 deletions configs/rtmdet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Our tech-report will be released soon.

## Results and Models

| Backbone | size | SyncBN | ox AP | Params(M) | FLOPS(G) | TRT-FP16-Latency(ms) | Config | Download |
| :---------: | :--: | :----: | ----: | :-------: | :------: | :------------------: | :-----------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| RTMDet-tiny | 640 | Yes | 40.9 | 4.8 | 8.1 | 0.98 | [config](./rtmdet_tiny_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_tiny_syncbn_8xb32-300e_coco/rtmdet_tiny_syncbn_8xb32-300e_coco_20220902_112414-259f3241.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_tiny_8xb32-300e_coco/rtmdet_tiny_8xb32-300e_coco_20220902_112414.log.json) |
| RTMDet-s | 640 | Yes | 44.5 | 8.89 | 14.8 | 1.22 | [config](./rtmdet_s_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_s_syncbn_8xb32-300e_coco/rtmdet_s_syncbn_8xb32-300e_coco_20220905_161602-fd1cacb9.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_s_8xb32-300e_coco/rtmdet_s_8xb32-300e_coco_20220905_161602.log.json) |
| RTMDet-m | 640 | Yes | 49.1 | 24.71 | 39.27 | 1.62 | [config](./rtmdet_m_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_m_syncbn_8xb32-300e_coco/rtmdet_m_syncbn_8xb32-300e_coco_20220924_132959-d9f2e90d.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_m_8xb32-300e_coco/rtmdet_m_8xb32-300e_coco_20220924_132959.log.json) |
| RTMDet-l | 640 | Yes | 51.3 | 52.3 | 80.23 | 2.44 | [config](./rtmdet_l_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_l_syncbn_8xb32-300e_coco/rtmdet_l_syncbn_8xb32-300e_coco_20220926_150401-40c754b5.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_l_8xb32-300e_coco/rtmdet_l_8xb32-300e_coco_20220926_150401.log.json) |
| RTMDet-x | 640 | Yes | 52.6 | 94.86 | 141.67 | 3.10 | [config](./rtmdet_x_syncbn_8xb32-300e_coco.py) | [model](<>) \| [log](<>) |
| Backbone | size | SyncBN | box AP | Params(M) | FLOPS(G) | TRT-FP16-Latency(ms) | Config | Download |
| :---------: | :--: | :----: | -----: | :-------: | :------: | :------------------: | :-----------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| RTMDet-tiny | 640 | Yes | 40.9 | 4.8 | 8.1 | 0.98 | [config](./rtmdet_tiny_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_tiny_syncbn_8xb32-300e_coco/rtmdet_tiny_syncbn_8xb32-300e_coco_20220902_112414-259f3241.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_tiny_8xb32-300e_coco/rtmdet_tiny_8xb32-300e_coco_20220902_112414.log.json) |
| RTMDet-s | 640 | Yes | 44.5 | 8.89 | 14.8 | 1.22 | [config](./rtmdet_s_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_s_syncbn_8xb32-300e_coco/rtmdet_s_syncbn_8xb32-300e_coco_20220905_161602-fd1cacb9.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_s_8xb32-300e_coco/rtmdet_s_8xb32-300e_coco_20220905_161602.log.json) |
| RTMDet-m | 640 | Yes | 49.1 | 24.71 | 39.27 | 1.62 | [config](./rtmdet_m_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_m_syncbn_8xb32-300e_coco/rtmdet_m_syncbn_8xb32-300e_coco_20220924_132959-d9f2e90d.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_m_8xb32-300e_coco/rtmdet_m_8xb32-300e_coco_20220924_132959.log.json) |
| RTMDet-l | 640 | Yes | 51.3 | 52.3 | 80.23 | 2.44 | [config](./rtmdet_l_syncbn_8xb32-300e_coco.py) | [model](https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_l_syncbn_8xb32-300e_coco/rtmdet_l_syncbn_8xb32-300e_coco_20220926_150401-40c754b5.pth) \| [log](https://download.openmmlab.com/mmdetection/v3.0/rtmdet/rtmdet_l_8xb32-300e_coco/rtmdet_l_8xb32-300e_coco_20220926_150401.log.json) |
| RTMDet-x | 640 | Yes | 52.6 | 94.86 | 141.67 | 3.10 | [config](./rtmdet_x_syncbn_8xb32-300e_coco.py) | [model](<>) \| [log](<>) |

**Note**:

Expand Down
81 changes: 41 additions & 40 deletions demo/featmap_vis_demo.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
# Copyright (c) OpenMMLab. All rights reserved.
import argparse
import os
from typing import Sequence

import mmcv
import numpy as np
from mmdet.apis import inference_detector, init_detector
from mmengine import Config, DictAction
from mmengine.utils import ProgressBar

from mmyolo.registry import VISUALIZERS
from mmyolo.utils import register_all_modules
from mmyolo.utils.misc import auto_arrange_images, get_file_list


# TODO: Refine
def parse_args():
parser = argparse.ArgumentParser(description='Visualize Featmaps')
parser.add_argument('img', help='Image file')
parser = argparse.ArgumentParser(description='Visualize feature map')
parser.add_argument(
'img', help='Image path, include image file, dir and URL.')
parser.add_argument('config', help='Config file')
parser.add_argument('checkpoint', help='Checkpoint file')
parser.add_argument(
'--out-dir', default='./output', help='Path to output file')
parser.add_argument(
'--target-layers',
default=['backbone'],
nargs='+',
type=str,
help='The target layers to get featmap, if not set, the tool will '
help='The target layers to get feature map, if not set, the tool will '
'specify the backbone')
parser.add_argument(
'--preview-model',
default=False,
action='store_true',
help='To preview all the model layers')
parser.add_argument('--out-file', default=None, help='Path to output file')
parser.add_argument(
'--device', default='cuda:0', help='Device used for inference')
parser.add_argument(
'--score-thr', type=float, default=0.3, help='Bbox score threshold')
parser.add_argument(
'--show', action='store_true', help='Show the featmap results')
parser.add_argument(
'--channel-reduction',
default='select_max',
Expand Down Expand Up @@ -88,28 +94,9 @@ def release(self):
handle.remove()


def auto_arrange_imgs(imgs):
len_img = len(imgs)
col = 2
if len_img <= col:
imgs = np.concatenate(imgs, axis=1)
else:
row = len_img // col + 1
fill_img_list = [np.ones(imgs[0].shape, dtype=np.uint8) * 255] * (
row * col - len_img)
imgs.extend(fill_img_list)
merge_imgs_col = []
for i in range(row):
start = col * i
end = col * (i + 1)
merge_col = np.hstack(imgs[start:end])
merge_imgs_col.append(merge_col)

imgs = np.vstack(merge_imgs_col)
return imgs


def main(args):
def main():
args = parse_args()

# register all modules in mmdet into the registries
register_all_modules()

Expand All @@ -124,9 +111,13 @@ def main(args):

model = init_detector(args.config, args.checkpoint, device=args.device)

if not os.path.exists(args.out_dir) and not args.show:
os.mkdir(args.out_dir)

if args.preview_model:
print(model)
print('\n Please remove `--preview-model` to get the AM.')
print('\n This flag is only show model, if you want to continue, '
'please remove `--preview-model` to get the feature map.')
return

target_layers = []
Expand All @@ -143,11 +134,11 @@ def main(args):
visualizer = VISUALIZERS.build(model.cfg.visualizer)
visualizer.dataset_meta = model.dataset_meta

images = args.img
if not isinstance(images, list):
images = [images]
# get file list
image_list, source_type = get_file_list(args.img)

for image_path in images:
progress_bar = ProgressBar(len(image_list))
for image_path in image_list:
result, featmaps = activations_wrapper(image_path)
if not isinstance(featmaps, Sequence):
featmaps = [featmaps]
Expand All @@ -159,10 +150,16 @@ def main(args):
else:
flatten_featmaps.append(featmap)

# show the results
img = mmcv.imread(args.img)
img = mmcv.imread(image_path)
img = mmcv.imconvert(img, 'bgr', 'rgb')

if source_type['is_dir']:
filename = os.path.relpath(image_path, args.img).replace('/', '_')
else:
filename = os.path.basename(image_path)
out_file = None if args.show else os.path.join(args.out_dir, filename)

# show the results
shown_imgs = []
visualizer.add_datasample(
'result',
Expand All @@ -184,16 +181,20 @@ def main(args):
arrangement=args.arrangement)
shown_imgs.append(shown_img)

shown_imgs = auto_arrange_imgs(shown_imgs)
shown_imgs = auto_arrange_images(shown_imgs)

if args.out_file is not None:
mmcv.imwrite(shown_imgs[..., ::-1], args.out_file)
else:
progress_bar.update()
if out_file:
mmcv.imwrite(shown_imgs[..., ::-1], out_file)

if args.show:
visualizer.show(shown_imgs)

print(f'All done!'
f'\nResults have been saved at {os.path.abspath(args.out_dir)}')


# Please refer to the usage tutorial:
# https://github.com/open-mmlab/mmyolo/blob/main/docs/zh_cn/user_guides/visualization.md # noqa
if __name__ == '__main__':
args = parse_args()
main(args)
main()
50 changes: 17 additions & 33 deletions demo/image_demo.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# Copyright (c) OpenMMLab. All rights reserved.
import logging
import os
import urllib
from argparse import ArgumentParser

import mmcv
import torch
from mmdet.apis import inference_detector, init_detector
from mmengine.logging import print_log
from mmengine.utils import ProgressBar, scandir
from mmengine.utils import ProgressBar

from mmyolo.registry import VISUALIZERS
from mmyolo.utils import register_all_modules, switch_to_deploy

IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif',
'.tiff', '.webp')
from mmyolo.utils.misc import get_file_list


def parse_args():
Expand All @@ -39,7 +34,9 @@ def parse_args():
return args


def main(args):
def main():
args = parse_args()

# register all modules in mmdet into the registries
register_all_modules()

Expand All @@ -49,45 +46,32 @@ def main(args):
if args.deploy:
switch_to_deploy(model)

if not os.path.exists(args.out_dir) and not args.show:
os.mkdir(args.out_dir)

# init visualizer
visualizer = VISUALIZERS.build(model.cfg.visualizer)
visualizer.dataset_meta = model.dataset_meta

is_dir = os.path.isdir(args.img)
is_url = args.img.startswith(('http:/', 'https:/'))
is_file = os.path.splitext(args.img)[-1] in (IMG_EXTENSIONS)

files = []
if is_dir:
# when input source is dir
for file in scandir(args.img, IMG_EXTENSIONS, recursive=True):
files.append(os.path.join(args.img, file))
elif is_url:
# when input source is url
filename = os.path.basename(
urllib.parse.unquote(args.img).split('?')[0])
torch.hub.download_url_to_file(args.img, filename)
files = [os.path.join(os.getcwd(), filename)]
elif is_file:
# when input source is single image
files = [args.img]
else:
print_log(
'Cannot find image file.', logger='current', level=logging.WARNING)
# get file list
files, source_type = get_file_list(args.img)

# start detector inference
progress_bar = ProgressBar(len(files))
for file in files:
result = inference_detector(model, file)

img = mmcv.imread(file)
img = mmcv.imconvert(img, 'bgr', 'rgb')
if is_dir:

if source_type['is_dir']:
filename = os.path.relpath(file, args.img).replace('/', '_')
else:
filename = os.path.basename(file)
out_file = None if args.show else os.path.join(args.out_dir, filename)

visualizer.add_datasample(
filename,
os.path.basename(out_file),
img,
data_sample=result,
draw_gt=False,
Expand All @@ -96,11 +80,11 @@ def main(args):
out_file=out_file,
pred_score_thr=args.score_thr)
progress_bar.update()

if not args.show:
print_log(
f'\nResults have been saved at {os.path.abspath(args.out_dir)}')


if __name__ == '__main__':
args = parse_args()
main(args)
main()
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN apt-get update \

# Install MMEngine , MMCV and MMDet
RUN pip install --no-cache-dir openmim && \
mim install --no-cache-dir "mmengine>=0.3.0" "mmcv>=2.0.0rc1,<2.1.0" "mmdet>=3.0.0rc2,<3.1.0"
mim install --no-cache-dir "mmengine>=0.3.1" "mmcv>=2.0.0rc1,<2.1.0" "mmdet>=3.0.0rc3,<3.1.0"

# Install MMYOLO
RUN git clone https://github.com/open-mmlab/mmyolo.git /mmyolo && \
Expand Down
Loading

0 comments on commit 178b0bf

Please sign in to comment.