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

how to change the input picture's dimension #20

Closed
msha096 opened this issue May 2, 2019 · 4 comments
Closed

how to change the input picture's dimension #20

msha096 opened this issue May 2, 2019 · 4 comments

Comments

@msha096
Copy link

msha096 commented May 2, 2019

Hi, I am trying to use my own dataset and the image is 1024*2048. I changed the 'input size' of 'db', in config/CenterNet104.json. But I got the following errors:

Traceback (most recent call last):
File "train.py", line 207, in
train(training_dbs, validation_db, args.start_iter)
File "train.py", line 139, in train
training_loss, focal_loss, pull_loss, push_loss, regr_loss = nnet.train(**training)
File "/home/mingzhi/Downloads/CenterNet-master/nnet/py_factory.py", line 82, in train
loss_kp = self.network(xs, ys)
File "/home/mingzhi/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/mingzhi/Downloads/CenterNet-master/models/py_utils/data_parallel.py", line 68, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/mingzhi/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/mingzhi/Downloads/CenterNet-master/nnet/py_factory.py", line 21, in forward
loss_kp = self.loss(preds, ys, **kwargs)
File "/home/mingzhi/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/mingzhi/Downloads/CenterNet-master/models/py_utils/kp.py", line 339, in forward
pull, push = self.ae_loss(tl_tag, br_tag, gt_mask)
File "/home/mingzhi/Downloads/CenterNet-master/models/py_utils/kp_utils.py", line 224, in _ae_loss
dist = tag_mean.unsqueeze(1) - tag_mean.unsqueeze(2)
RuntimeError: Dimension out of range (expected to be in range of [-2, 1], but got 2)

@Duankaiwen
Copy link
Owner

@msha096 Can I see your full log?

@msha096
Copy link
Author

msha096 commented May 6, 2019

@msha096 Can I see your full log?

Yes here it is. If I change to [1024,2048], it will be out of my cuda's capability.So I changed to 512,1024.

(CenterNet) ➜ CenterNet-master python train.py CenterNet-104
loading all datasets...
using 4 threads
loading from cache file: cache/coco_train.pkl
loading annotations into memory...
annotations_file ./data/coco/annotations/instances_train.json
Done (t=0.05s)
creating index...
index created!
loading from cache file: cache/coco_train.pkl
loading annotations into memory...
annotations_file ./data/coco/annotations/instances_train.json
Done (t=0.06s)
creating index...
index created!
loading from cache file: cache/coco_train.pkl
loading annotations into memory...
annotations_file ./data/coco/annotations/instances_train.json
Done (t=0.06s)
creating index...
index created!
loading from cache file: cache/coco_train.pkl
loading annotations into memory...
annotations_file ./data/coco/annotations/instances_train.json
Done (t=0.04s)
creating index...
index created!
loading from cache file: cache/coco_val.pkl
loading annotations into memory...
annotations_file ./data/coco/annotations/instances_val.json
Done (t=0.01s)
creating index...
index created!
system config...
{'batch_size': 1,
'cache_dir': 'cache',
'chunk_sizes': [1],
'config_dir': 'config',
'data_dir': './data',
'data_rng': <mtrand.RandomState object at 0x7feb675e3510>,
'dataset': 'MSCOCO',
'decay_rate': 10,
'display': 5,
'learning_rate': 0.00025,
'max_iter': 480000,
'nnet_rng': <mtrand.RandomState object at 0x7feb675e3558>,
'opt_algo': 'adam',
'prefetch_size': 6,
'pretrain': None,
'result_dir': 'results',
'sampling_function': 'kp_detection',
'snapshot': 5000,
'snapshot_name': 'CenterNet-104',
'stepsize': 450000,
'test_split': 'testdev',
'train_split': 'trainval',
'val_iter': 500,
'val_split': 'minival',
'weight_decay': False,
'weight_decay_rate': 1e-05,
'weight_decay_type': 'l2'}
db config...
{'ae_threshold': 0.5,
'border': 128,
'categories': 80,
'data_aug': True,
'gaussian_bump': True,
'gaussian_iou': 0.7,
'gaussian_radius': -1,
'input_size': [512, 1024],
'kp_categories': 1,
'lighting': True,
'max_per_image': 100,
'merge_bbox': False,
'nms_algorithm': 'exp_soft_nms',
'nms_kernel': 3,
'nms_threshold': 0.5,
'output_sizes': [[128, 256]],
'rand_color': True,
'rand_crop': True,
'rand_pushes': False,
'rand_samples': False,
'rand_scale_max': 1.4,
'rand_scale_min': 0.6,
'rand_scale_step': 0.1,
'rand_scales': array([0.6, 0.7, 0.8, 0.9, 1. , 1.1, 1.2, 1.3]),
'special_crop': False,
'test_scales': [1],
'top_k': 70,
'weight_exp': 8}
len of db: 1126
start prefetching data...
shuffling indices...
start prefetching data...
shuffling indices...
start prefetching data...
shuffling indices...
start prefetching data...
shuffling indices...
building model...
module_file: models.CenterNet-104
start prefetching data...
shuffling indices...
total parameters: 210062960
setting learning rate to: 0.00025
training start...
0%| | 0/480000 [00:00<?, ?it/s]/home/mingzhi/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/upsampling.py:122: UserWarning: nn.Upsampling is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.Upsampling is deprecated. Use nn.functional.interpolate instead.")

Traceback (most recent call last):
File "train.py", line 208, in
train(training_dbs, validation_db, args.start_iter)
File "train.py", line 139, in train
training_loss, focal_loss, pull_loss, push_loss, regr_loss = nnet.train(**training)
File "/home/mingzhi/Downloads/CenterNet-master/nnet/py_factory.py", line 82, in train
loss_kp = self.network(xs, ys)
File "/home/mingzhi/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/mingzhi/Downloads/CenterNet-master/models/py_utils/data_parallel.py", line 68, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/mingzhi/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/mingzhi/Downloads/CenterNet-master/nnet/py_factory.py", line 21, in forward
loss_kp = self.loss(preds, ys, **kwargs)
File "/home/mingzhi/anaconda3/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/mingzhi/Downloads/CenterNet-master/models/py_utils/kp.py", line 339, in forward
pull, push = self.ae_loss(tl_tag, br_tag, gt_mask)
File "/home/mingzhi/Downloads/CenterNet-master/models/py_utils/kp_utils.py", line 224, in _ae_loss
dist = tag_mean.unsqueeze(1) - tag_mean.unsqueeze(2)
RuntimeError: Dimension out of range (expected to be in range of [-2, 1], but got 2)

@Duankaiwen
Copy link
Owner

@msha096 Add these codes above the
dist = tag_mean.unsqueeze(1) - tag_mean.unsqueeze(2)
in models/py_utils/kp_utils.py:

if len(tag_mean.size()) < 2:

      tag_mean = tag_mean.unsqueeze(0)`  

@z-huabao
Copy link

z-huabao commented Jun 5, 2019

@Duankaiwen why not update the code on repos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants