Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] New config type #787

Open
wants to merge 2 commits into
base: new_config
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions mmyolo/configs/_base_/default_runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmdet.engine.hooks import DetVisualizationHook
from mmdet.visualization import DetLocalVisualizer
from mmengine.hooks import (CheckpointHook, DistSamplerSeedHook, IterTimerHook,
LoggerHook, ParamSchedulerHook)
from mmengine.runner import LogProcessor
from mmengine.visualization import LocalVisBackend

default_scope = None
default_hooks = dict(
timer=dict(type=IterTimerHook),
logger=dict(type=LoggerHook, interval=50),
param_scheduler=dict(type=ParamSchedulerHook),
checkpoint=dict(type=CheckpointHook, interval=1),
sampler_seed=dict(type=DistSamplerSeedHook),
visualization=dict(type=DetVisualizationHook))

env_cfg = dict(
cudnn_benchmark=False,
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
dist_cfg=dict(backend='nccl'),
)

vis_backends = [dict(type=LocalVisBackend)]
visualizer = dict(
type=DetLocalVisualizer, vis_backends=vis_backends, name='visualizer')
log_processor = dict(type=LogProcessor, window_size=50, by_epoch=True)

log_level = 'INFO'
load_from = None
resume = False

# file_client_args = dict(
# backend='petrel',
# path_mapping=dict({
# './data/': 's3://openmmlab/datasets/detection/',
# 'data/': 's3://openmmlab/datasets/detection/'
# }))
file_client_args = dict(backend='disk')
65 changes: 65 additions & 0 deletions mmyolo/configs/_base_/det_p5_tta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmcv.ops import nms
from mmcv.transforms import Compose, LoadImageFromFile, TestTimeAug
from mmdet.datasets.transforms import (LoadAnnotations, PackDetInputs,
RandomFlip)
from mmdet.models import DetTTAModel

from mmyolo.datasets.transforms import LetterResize, YOLOv5KeepRatioResize

# TODO: Need to solve the problem of multiple file_client_args parameters
# _file_client_args = dict(
# backend='petrel',
# path_mapping=dict({
# './data/': 's3://openmmlab/datasets/detection/',
# 'data/': 's3://openmmlab/datasets/detection/'
# }))
_file_client_args = dict(backend='disk')

tta_model = dict(
type=DetTTAModel,
tta_cfg=dict(nms=dict(type=nms, iou_threshold=0.65), max_per_img=300))

img_scales = [(640, 640), (320, 320), (960, 960)]

# LoadImageFromFile
# / | \
# (RatioResize,LetterResize) (RatioResize,LetterResize) (RatioResize,LetterResize) # noqa
# / \ / \ / \
# RandomFlip RandomFlip RandomFlip RandomFlip RandomFlip RandomFlip # noqa
# | | | | | |
# LoadAnn LoadAnn LoadAnn LoadAnn LoadAnn LoadAnn
# | | | | | |
# PackDetIn PackDetIn PackDetIn PackDetIn PackDetIn PackDetIn # noqa

_multiscale_resize_transforms = [
dict(
type=Compose,
transforms=[
dict(type=YOLOv5KeepRatioResize, scale=s),
dict(
type=LetterResize,
scale=s,
allow_scale_up=False,
pad_val=dict(img=114))
]) for s in img_scales
]

tta_pipeline = [
dict(type=LoadImageFromFile, file_client_args=_file_client_args),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是 backend_args

dict(
type=TestTimeAug,
transforms=[
_multiscale_resize_transforms,
[dict(type=RandomFlip, prob=1.),
dict(type=RandomFlip, prob=0.)],
[dict(type=LoadAnnotations, with_bbox=True)],
[
dict(
type=PackDetInputs,
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'pad_param', 'flip',
'flip_direction'))
]
])
]
Loading