Skip to content

Commit

Permalink
final-battle
Browse files Browse the repository at this point in the history
  • Loading branch information
HiKapok committed May 17, 2018
1 parent bffd3f9 commit e90c5b0
Show file tree
Hide file tree
Showing 19 changed files with 1,529 additions and 2,289 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ All the codes was writen by myself and tested under TensorFlow 1.6, Python 3.5,

There are still other ways to further improve the performance but I didn't try those in this competition because of their limitations in applications, for example:

- More large input image size
- More larger input image size
- More deeper backbone networks
- Locate clothes first by detection networks
- Multi-scale supervision for Stacked Hourglass Models
- Extra-regressor to refine the location of keypoints
- Multi-crop ensemble for single image predictions
- Multi-crop or multi-scale ensemble for single image predictions

If you find it's useful to your research or competitions, any contribution or star to this repo is welcomed.

Expand Down
2 changes: 1 addition & 1 deletion ensemble_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# 'sub_2_hg_4_256_64-half_epoch.csv',
# 'sub_2_hg_8_256_64_v1-half_epoch.csv']#['cpn_2_320_160_1e-3.csv', 'sub_2_hg_4_256_64.csv', 'sub_2_cpn_320_100_1e-3.csv', 'sub_2_hg_8_256_64.csv']

ensemble_subs = ['det-cpn-ohkm-384-96-lr1e-4-b10_predv1_finetune.csv', 'sext_cpn_v1_fine.csv']
ensemble_subs = ['sext_cpn_flip.csv', 'detxt_cpn_flip.csv']


def parse_comma_list(args):
Expand Down
6 changes: 5 additions & 1 deletion eval_all_cpn_onepass.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'gpu_memory_fraction', 1., 'GPU memory fraction to use.')
# scaffold related configuration
tf.app.flags.DEFINE_string(
'data_dir', '../Datasets/tfrecords_test_stage1_b',#tfrecords_test tfrecords_test_stage1_b
'data_dir', '../Datasets/tfrecords_test',#tfrecords_test tfrecords_test_stage1_b
'The directory where the dataset input data is stored.')
tf.app.flags.DEFINE_string(
'dataset_name', '{}_*.tfrecord', 'The pattern of the dataset name to load.')
Expand Down Expand Up @@ -112,6 +112,10 @@
'seresnet50_cpn': {'backbone': seresnet_cpn.cascaded_pyramid_net, 'logs_sub_dir': 'logs_se_cpn'},
'seresnext50_cpn': {'backbone': seresnet_cpn.xt_cascaded_pyramid_net, 'logs_sub_dir': 'logs_sext_cpn'},
'detnext50_cpn': {'backbone': detxt_cpn.cascaded_pyramid_net, 'logs_sub_dir': 'logs_detxt_cpn'},
'large_seresnext_cpn': {'backbone': lambda inputs, output_channals, heatmap_size, istraining, data_format : seresnet_cpn.xt_cascaded_pyramid_net(inputs, output_channals, heatmap_size, istraining, data_format, net_depth=50),
'logs_sub_dir': 'logs_large_sext_cpn'},
'large_detnext_cpn': {'backbone': lambda inputs, output_channals, heatmap_size, istraining, data_format : detxt_cpn.cascaded_pyramid_net(inputs, output_channals, heatmap_size, istraining, data_format, net_depth=50),
'logs_sub_dir': 'logs_large_detxt_cpn'},
'head_seresnext50_cpn': {'backbone': seresnet_cpn.head_xt_cascaded_pyramid_net, 'logs_sub_dir': 'logs_head_sext_cpn'},
}

Expand Down
16 changes: 16 additions & 0 deletions eval_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash

# export CUDA_VISIBLE_DEVICES='0'
# source /home/kapok/pyenv35/bin/activate
# cd /media/rs/0E06CD1706CD0127/Kapok/Chi/fashionAI/Codes
python eval_all_cpn_onepass.py --run_on_cloud=False --backbone=seresnext50_cpn
python eval_all_cpn_onepass.py --run_on_cloud=False --backbone=detnext50_cpn
python eval_all_cpn_onepass.py --run_on_cloud=False --backbone=large_seresnext_cpn --train_image_size=512 --heatmap_size=128
python eval_all_cpn_onepass.py --run_on_cloud=False --backbone=large_detnext_cpn --train_image_size=512 --heatmap_size=128

# for training
python train_senet_cpn_onebyone.py --run_on_cloud=False
python train_detxt_cpn_onebyone.py --run_on_cloud=False
python train_large_xt_cpn_onebyone.py --run_on_cloud=False --backbone=detxt
python train_large_xt_cpn_onebyone.py --run_on_cloud=False --backbone=sext

11 changes: 7 additions & 4 deletions net/detxt_cpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def dilated_se_next_bottleneck_block(inputs, input_filters, name_prefix, is_trai
return tf.nn.relu(pre_act, name=name_prefix + '/relu')

# the input image should in BGR order, note that this is not the common case in Tensorflow
def sext_cpn_backbone(input_image, istraining, data_format, group=32):
def sext_cpn_backbone(input_image, istraining, data_format, net_depth=50, group=32):
bn_axis = -1 if data_format == 'channels_last' else 1

if data_format == 'channels_last':
Expand All @@ -304,8 +304,11 @@ def sext_cpn_backbone(input_image, istraining, data_format, group=32):
swaped_input_image = tf.stack([image_channels[2], image_channels[1], image_channels[0]], axis=1)
#swaped_input_image = input_image

if net_depth not in [50, 101]:
raise TypeError('Only ResNeXt50 or ResNeXt101 is supprted now.')

input_depth = [256, 512, 1024] # the input depth of the the first block is dummy input
num_units = [3, 4, 6]
num_units = [3, 4, 6] if net_depth==50 else [3, 4, 23]
block_name_prefix = ['conv2_{}', 'conv3_{}', 'conv4_{}']

if data_format == 'channels_first':
Expand Down Expand Up @@ -475,9 +478,9 @@ def global_net_sext_bottleneck_block(inputs, input_filters, is_training, data_fo
pre_act = tf.add(residuals, rescaled_feat, name=name_prefix + '_add')
return tf.nn.relu(pre_act, name=name_prefix + '/relu')

def cascaded_pyramid_net(inputs, output_channals, heatmap_size, istraining, data_format):
def cascaded_pyramid_net(inputs, output_channals, heatmap_size, istraining, data_format, net_depth=50):
#with tf.variable_scope('resnet50', 'resnet50', values=[inputs]):
end_points = sext_cpn_backbone(inputs, istraining, data_format)
end_points = sext_cpn_backbone(inputs, istraining, data_format, net_depth=net_depth)
pyramid_len = len(end_points)
up_sampling = None
pyramid_heatmaps = []
Expand Down
Loading

0 comments on commit e90c5b0

Please sign in to comment.