human-pose-estimation.pytorch
human-pose-estimation.pytorch copied to clipboard
Training on custom dataset
I am planning to tune the pretrained coco model on a tagged custom dataset. In the .yaml file, I can see we can give resent50 as pretrained model. Is there any way I can use the coco pretrained model to do fine tuning on my local dataset?
Update :- I went through the codebase and I see an option to specify the checkpoint file in config.py. But the training code only loads pretrained ResNet model and I couldn't find the checkpoint variable used anywhere. In the paper, you have mentioned that you did finetuning on PoseTrack dataset using COCO pretrained model. Could you please let me know how to do the same for my dataset?
I have not added this function for this repo. But you can set which params you want to init from the COCO pre-trained model in https://github.com/Microsoft/human-pose-estimation.pytorch/blob/master/lib/models/pose_resnet.py#L250.
Hi. I have applied transfter learning by first loading the pretrained COCO weights and then initialize the last layer of the net.
@Odaimoko Could you tell me what did you change? I was able to load COCO pretrained model without changing anything in the existing codebase.
Regarding initialization of layers, the current code initializes deconvolution and final layer before loading the pretrained model. Did you have to change anything here? https://github.com/Microsoft/human-pose-estimation.pytorch/blob/master/lib/models/pose_resnet.py#L250.
@meetdave06 I only changed code in pose_estimation/train.py.
That init_weight method only serves to init from pretrained model from resnet but not from the author's provided ones. If you step into that method you will find the parameter pretrained to be something like 'models/pytorch/resnet50-19c8e357.pth'. So the original code cannot resume training sessions.
The place where author load his mature model is in pose_estimation/valid.py. In this line. I changed it so it applies to posetrack 17 's 15 joint result.
This is placed just after calling get_pose_net in train.py.
if config.TEST.MODEL_FILE: # train from pretrained model
logger.info('=> loading model from {}'.format(config.TEST.MODEL_FILE))
meta_info = torch.load(config.TEST.MODEL_FILE)
if 'pt17-epoch' in args.model_file:
# resume previous training
state_dict = OrderedDict({k.replace('module.', ''): v
for k, v in meta_info['state_dict'].items()})
config.TRAIN.BEGIN_EPOCH = meta_info['epoch']
else:
# if load from coco pretrained model,
logger.info('=> initialize from coco, so adjusting the last layer')
model.final_layer = nn.Conv2d(256, 17, (1, 1), (1, 1))
state_dict = meta_info
model.load_state_dict(state_dict)
if not 'pt17-epoch' in args.model_file: # if load from coco pretrained model
model.final_layer = nn.Conv2d(256, config.MODEL.NUM_JOINTS, (1, 1), (1, 1))
logger.info('=> adjust done.')
It is just a part of the code so if there's anything confusing pls let me know.
Also just replacing the last layer with random one cannot get competitive result. My final PCKh on posetrack validation set is 88.01. But I use my trained model to run posetrack task 1 and only get 71 mAP. If you have better result pls tell me.
Hi ,I trained model using my own dataset that has only 14 points. I just changed the "NUM_JOINTS: 17" to "NUM_JOINTS: 14" in “384x288_d256x3_adam_lr1e-3.yaml”file. and I also changed "self.num_joints = 17" to "self.num_joints = 14" in “ coco.py” 。 while Training ,The predicted picture saved at "output"file is predicted well. But when finished the training .I run valid.py to test my model on val2017 dataset .The all test result is wrong,the predict points are located in everywhere. and Accuracy =0.0000. Could you tell me how to train the model using my own dataset that has 14 points for each person? Which files should I modify? Thank you very much @meetdave06
Accumulating evaluation results... DONE (t=0.04s). Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50 | area= all | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.75 | area= all | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets= 20 ] = 0.000
Accumulating evaluation results... DONE (t=0.04s). Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets= 20 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50 | area= all | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.75 | area= all | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets= 20 ] = 0.000 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets= 20 ] = 0.000
Hello Mike. Did you use the CrowdPose dataset, and if not can you tell me what dataset you used and how did you changed the code inside valid.py in order to test on the new dataset? I dont think modifying the config file is enough.
@SanduIrina Hello can you please explain how did you use the model for your own dataset?