Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
lijiancheng0614 committed May 7, 2020
1 parent 50ced98 commit 5074927
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 137 deletions.
2 changes: 0 additions & 2 deletions configs/fashion_parsing_segmentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ mmfashion
├── data
└── ...
```


5 changes: 2 additions & 3 deletions configs/fashion_parsing_segmentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
from .coco import CocoDataset
from .custom import CustomDataset
from .dataset_wrappers import ConcatDataset, RepeatDataset
from .mmfashion import mmfashionDataset
from .registry import DATASETS
from .samplers import DistributedGroupSampler, DistributedSampler, GroupSampler
from .voc import VOCDataset
from .wider_face import WIDERFaceDataset
from .xml_style import XMLDataset
from .mmfashion import mmfashionDataset

__all__ = [
'CustomDataset', 'XMLDataset', 'CocoDataset', 'VOCDataset',
'CityscapesDataset', 'GroupSampler', 'DistributedGroupSampler',
'DistributedSampler', 'build_dataloader', 'ConcatDataset', 'RepeatDataset',
'mmfashionDataset',
'WIDERFaceDataset', 'DATASETS', 'build_dataset'
'mmfashionDataset', 'WIDERFaceDataset', 'DATASETS', 'build_dataset'
]
8 changes: 4 additions & 4 deletions configs/fashion_parsing_segmentation/demo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from mmdet.apis import init_detector, inference_detector, show_result
import mmcv
import argparse

from mmdet.apis import inference_detector, init_detector, show_result


def parse_args():
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -34,5 +34,5 @@ def main():

# visualize the results in a new window
# or save the visualization results to image files
show_result(img, result, model.CLASSES, out_file=img.split('.')[0]+'_result.jpg')

show_result(
img, result, model.CLASSES, out_file=img.split('.')[0] + '_result.jpg')
3 changes: 1 addition & 2 deletions configs/fashion_parsing_segmentation/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import torch
from mmcv.parallel import collate, scatter
from mmcv.runner import load_checkpoint

from mmdet.core import get_classes
from mmdet.datasets.pipelines import Compose
from mmdet.models import build_detector
Expand Down Expand Up @@ -152,7 +151,7 @@ def show_result(img,
# remove duplicate
new_bbox_result = []
for ti, temp in enumerate(bbox_result):
if len(temp) <=1:
if len(temp) <= 1:
new_bbox_result.append(temp)
continue
new_temp = sorted(temp, key=lambda x: x[-1])[-1]
Expand Down
213 changes: 105 additions & 108 deletions configs/fashion_parsing_segmentation/mask_rcnn_r50_fpn_1x.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# model settings
model = dict(
type='MaskRCNN',
pretrained='checkpoint/resnet50.pth',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0,1,2,3),
frozen_stages=1,
norm_cfg = dict(type='BN', requires_grad=True),
style='pytorch'),
neck=dict(
type='MaskRCNN',
pretrained='checkpoint/resnet50.pth',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
style='pytorch'),
neck=dict(
type='FPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
num_outs=5),
rpn_head=dict(
rpn_head=dict(
type='RPNHead',
in_channels=256,
feat_channels=256,
Expand All @@ -27,79 +27,79 @@
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)),
bbox_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', out_size=7, sample_num=2),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
bbox_head=dict(
type='SharedFCBBoxHead',
num_fcs=2,
in_channels=256,
fc_out_channels=1024,
roi_feat_size=7,
num_classes=81,
target_means=[0., 0., 0., 0.],
target_stds=[0.1, 0.1, 0.2, 0.2],
reg_class_agnostic=False,
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0, loss_weight=1.0)),
mask_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', out_size=14, sample_num=2),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
mask_head=dict(
type='FCNMaskHead',
num_convs=4,
in_channels=256,
conv_out_channels=256,
num_classes=81,
loss_mask=dict(
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0)))
bbox_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', out_size=7, sample_num=2),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
bbox_head=dict(
type='SharedFCBBoxHead',
num_fcs=2,
in_channels=256,
fc_out_channels=1024,
roi_feat_size=7,
num_classes=81,
target_means=[0., 0., 0., 0.],
target_stds=[0.1, 0.1, 0.2, 0.2],
reg_class_agnostic=False,
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0, loss_weight=1.0)),
mask_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', out_size=14, sample_num=2),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
mask_head=dict(
type='FCNMaskHead',
num_convs=4,
in_channels=256,
conv_out_channels=256,
num_classes=81,
loss_mask=dict(
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0)))

# model training and testing settings
train_cfg = dict(
rpn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.7,
neg_iou_thr=0.3,
min_pos_iou=0.3,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=256,
pos_fraction=0.5,
neg_pos_ub=-1,
add_gt_as_proposals=False),
allowed_border=0,
pos_weight=-1,
debug=False),
rpn_proposal=dict(
nms_across_levels=False,
nms_pre=2000,
nms_post=2000,
max_num=2000,
nms_thr=0.7,
min_bbox_size=0),
rcnn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.5,
min_pos_iou=0.5,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
mask_size=28,
pos_weight=-1,
debug=False))
rpn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.7,
neg_iou_thr=0.3,
min_pos_iou=0.3,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=256,
pos_fraction=0.5,
neg_pos_ub=-1,
add_gt_as_proposals=False),
allowed_border=0,
pos_weight=-1,
debug=False),
rpn_proposal=dict(
nms_across_levels=False,
nms_pre=2000,
nms_post=2000,
max_num=2000,
nms_thr=0.7,
min_bbox_size=0),
rcnn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.5,
min_pos_iou=0.5,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
mask_size=28,
pos_weight=-1,
debug=False))

test_cfg = dict(
rpn=dict(
Expand All @@ -115,9 +115,8 @@
max_per_img=100,
mask_thr_binary=0.5))


# dataset settings
dataset_type= 'mmfashionDataset'
dataset_type = 'mmfashionDataset'
data_root = '/data/dataset/DeepFashion/In-shop/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
Expand Down Expand Up @@ -149,26 +148,27 @@
]

data = dict(
imgs_per_gpu=2,
workers_per_gpu=1,
train=dict(
type=dataset_type,
ann_file=data_root+'annotations/DeepFashion_segmentation_query.json',
img_prefix=data_root+'Img/',
pipeline=train_pipeline,
data_root=data_root),
val=dict(
type=dataset_type,
ann_file=data_root+'annotations/DeepFashion_segmentation_query.json',
img_prefix=data_root+'Img/',
pipeline=test_pipeline,
data_root=data_root),
test=dict(
type=dataset_type,
ann_file=data_root+'annotations/DeepFashion_segmentation_gallery.json',
img_prefix=data_root+'Img/',
pipeline=test_pipeline,
data_root=data_root))
imgs_per_gpu=2,
workers_per_gpu=1,
train=dict(
type=dataset_type,
ann_file=data_root + 'annotations/DeepFashion_segmentation_query.json',
img_prefix=data_root + 'Img/',
pipeline=train_pipeline,
data_root=data_root),
val=dict(
type=dataset_type,
ann_file=data_root + 'annotations/DeepFashion_segmentation_query.json',
img_prefix=data_root + 'Img/',
pipeline=test_pipeline,
data_root=data_root),
test=dict(
type=dataset_type,
ann_file=data_root +
'annotations/DeepFashion_segmentation_gallery.json',
img_prefix=data_root + 'Img/',
pipeline=test_pipeline,
data_root=data_root))
evaluation = dict(interval=5, metric=['bbox', 'segm'])

# optimizer
Expand All @@ -182,14 +182,12 @@
warmup_ratio=1.0 / 3,
step=[8, 11])
checkpoint_config = dict(interval=1)
# yapf:disable
log_config=dict(
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook')
])
# yapf:enable
# runtime settings
total_epochs = 12
dist_params = dict(backend='nccl')
Expand All @@ -198,4 +196,3 @@
load_from = None
resume_from = None
workflow = [('train', 5)]

4 changes: 3 additions & 1 deletion configs/fashion_parsing_segmentation/mmfashion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

@DATASETS.register_module
class mmfashionDataset(CocoDataset):
CLASSES=('top', 'skirt', 'leggings', 'dress', 'outer', 'pants', 'bag', 'neckwear', 'headwear', 'eyeglass','belt', 'footwear', 'hair', 'skin', 'face')
CLASSES = ('top', 'skirt', 'leggings', 'dress', 'outer', 'pants', 'bag',
'neckwear', 'headwear', 'eyeglass', 'belt', 'footwear', 'hair',
'skin', 'face')
Loading

0 comments on commit 5074927

Please sign in to comment.