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

Testing this on my own dataset #21

Open
chariot1498 opened this issue May 3, 2019 · 20 comments
Open

Testing this on my own dataset #21

chariot1498 opened this issue May 3, 2019 · 20 comments

Comments

@chariot1498
Copy link

Hey how can I integrate this in a project like how can I run it on a bunch of images and get bounding boxes and confidence score in return .

@Duankaiwen
Copy link
Owner

@chariot1498 Hi, you can modify the "kp_dectection" function in test/coco.py.

@li10141110
Copy link

li10141110 commented May 16, 2019

@Duankaiwen I have trained one category object detection centernet based on your project but I found that in test.py my model can only get low scores(about 0.4-0.6). It confused me cause I can obtain 0.46AP and 0.828 AP@0.5. Followed is my test result and screenshot of code

image
test @ 6000
/home/imdl/anaconda3/envs/centernet/bin/python /home/imdl/workspace/CenterNet-master_train_custom_dataset/test.py CenterNet-52 --testiter 6000 --split validation
cfg_file: config/CenterNet-52.json
loading all datasets...
split: minival
loading from cache file: cache/coco_minival2014.pkl
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
system config...
{'batch_size': 16,
'cache_dir': 'cache',
'chunk_sizes': [16],
'config_dir': 'config',
'data_dir': '../data',
'data_rng': <mtrand.RandomState object at 0x7f7560b8c708>,
'dataset': 'MSCOCO',
'decay_rate': 10,
'display': 5,
'learning_rate': 0.0005,
'max_iter': 40000,
'nnet_rng': <mtrand.RandomState object at 0x7f7560b8c750>,
'opt_algo': 'adam',
'prefetch_size': 6,
'pretrain': None,
'result_dir': 'results',
'sampling_function': 'kp_detection',
'snapshot': 1000,
'snapshot_name': 'CenterNet-52',
'stepsize': 10000,
'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': 1,
'data_aug': True,
'gaussian_bump': True,
'gaussian_iou': 0.7,
'gaussian_radius': -1,
'input_size': [511, 511],
'kp_categories': 1,
'lighting': True,
'max_per_image': 50,
'merge_bbox': False,
'nms_algorithm': 'exp_soft_nms',
'nms_kernel': 3,
'nms_threshold': 0.5,
'output_sizes': [[128, 128]],
'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}
loading parameters at iteration: 6000
building neural network...
module_file: models.CenterNet-52
total parameters: 104783243
loading parameters...
loading model from cache/nnet/CenterNet-52/CenterNet-52_6000.pkl
locating kps: 0%| | 0/348 [00:00<?, ?it/s]THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/THCGeneral.cpp line=663 error=11 : invalid argument
/home/imdl/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.")
locating kps: 100%|█| 348/348 [01:06<00:00, 5.36it/s]
Loading and preparing results...
DONE (t=0.04s)
creating index...
index created!
Running per image evaluation...
Evaluate annotation type bbox
DONE (t=1.05s).
Accumulating evaluation results...
DONE (t=0.09s).
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.461
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.828
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.487
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.060
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.484
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.456
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.591
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.629
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.500
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.629
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Running per image evaluation...
Evaluate annotation type bbox
DONE (t=0.99s).
Accumulating evaluation results...
DONE (t=0.09s).
False discovery (FD) @[ IoU=0.05:0.50 | area= all | maxDets=100 ] = 0.161
False discovery (FD) @[ IoU=0.05 | area= all | maxDets=100 ] = 0.153
False discovery (FD) @[ IoU=0.25 | area= all | maxDets=100 ] = 0.159
False discovery (FD) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.172
False discovery (FD) @[ IoU=0.05:0.50 | area= small | maxDets=100 ] = 0.790
False discovery (FD) @[ IoU=0.05:0.50 | area=medium | maxDets=100 ] = 0.120
False discovery (FD) @[ IoU=0.05:0.50 | area= large | maxDets=100 ] = -1.000

Process finished with exit code 0

@hejinsome
Copy link

@li10141110 你好,我训练ok,test出问题:
(CenterNet) [root@add CenterNet-master]# python test.py CenterNet-104 --testiter 12000 --split validation
cfg_file: config/CenterNet-104.json
loading all datasets...
split: minival
minival
{1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 13, 13: 14, 14: 15, 15: 16, 16: 17, 17: 18, 18: 19, 19: 20, 20: 21, 21: 22, 22: 23, 23: 24, 24: 25, 25: 27, 26: 28, 27: 31, 28: 32, 29: 33, 30: 34, 31: 35, 32: 36, 33: 37, 34: 38, 35: 39, 36: 40, 37: 41, 38: 42, 39: 43, 40: 44, 41: 46, 42: 47, 43: 48, 44: 49, 45: 50, 46: 51, 47: 52, 48: 53, 49: 54, 50: 55, 51: 56, 52: 57, 53: 58, 54: 59, 55: 60, 56: 61, 57: 62, 58: 63, 59: 64, 60: 65, 61: 67, 62: 70, 63: 72, 64: 73, 65: 74, 66: 75, 67: 76, 68: 77, 69: 78, 70: 79, 71: 80, 72: 81, 73: 82, 74: 84, 75: 85, 76: 86, 77: 87, 78: 88, 79: 89, 80: 90}
loading from cache file: cache/coco_val.pkl
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
<db.coco.MSCOCO object at 0x7f04291065c0>
system config...
{'batch_size': 2,
'cache_dir': 'cache',
'chunk_sizes': [2],
'config_dir': 'config',
'data_dir': '/data2/hejin/CenterNet-master/data',
'data_rng': <mtrand.RandomState object at 0x7f0460ec1ab0>,
'dataset': 'MSCOCO',
'decay_rate': 10,
'display': 5,
'learning_rate': 0.00025,
'max_iter': 12000,
'nnet_rng': <mtrand.RandomState object at 0x7f0460ec1af8>,
'opt_algo': 'adam',
'prefetch_size': 6,
'pretrain': None,
'result_dir': 'results',
'sampling_function': 'kp_detection',
'snapshot': 500,
'snapshot_name': 'CenterNet-104',
'stepsize': 5000,
'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': 3,
'data_aug': True,
'gaussian_bump': True,
'gaussian_iou': 0.7,
'gaussian_radius': -1,
'input_size': [511, 511],
'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, 128]],
'rand_color': True,
'rand_crop': False,
'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}
loading parameters at iteration: 12000
building neural network...
module_file: models.CenterNet-104
total parameters: 209944226
loading parameters...
loading model from cache/nnet/CenterNet-104/CenterNet-104_12000.pkl
test.coco
<function testing at 0x7f0428af2158>
locating kps: 0%| | 0/10 [00:00<?, ?it/s]Traceback (most recent call last):
File "test.py", line 102, in
test(testing_db, args.split, args.testiter, args.debug, args.suffix)
File "test.py", line 62, in test
testing(db, nnet, result_dir, debug=debug)
File "/data2/hejin/CenterNet-master/test/coco.py", line 321, in testing
return globals()[system_configs.sampling_function](db, nnet, result_dir, debug=debug)
File "/data2/hejin/CenterNet-master/test/coco.py", line 129, in kp_detection
dets, center = decode_func(nnet, images, K, ae_threshold=ae_threshold, kernel=nms_kernel)
File "/data2/hejin/CenterNet-master/test/coco.py", line 54, in kp_decode
detections, center = nnet.test([images], ae_threshold=ae_threshold, K=K, kernel=kernel)
File "/data2/hejin/CenterNet-master/nnet/py_factory.py", line 114, in test
return self.model(*xs, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/CenterNet-master/nnet/py_factory.py", line 32, in forward
return self.module(*xs, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/CenterNet-master/models/py_utils/kp.py", line 290, in forward
return self._test(*xs, **kwargs)
File "/data2/hejin/CenterNet-master/models/py_utils/kp.py", line 243, in _test
inter = self.pre(image)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/CenterNet-master/models/py_utils/utils.py", line 15, in forward
bn = self.bn(conv)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 66, in forward
exponential_average_factor, self.eps)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/functional.py", line 1254, in batch_norm
training, momentum, eps, torch.backends.cudnn.enabled
RuntimeError: CUDA error: out of memory

@li10141110
Copy link

your GPU memory is limited.

@li10141110
Copy link

set batch size to 1 and chunk_size [1]

@wudi00
Copy link

wudi00 commented May 25, 2019

I want to train my own dataset and I format the data to the coco format, change the class_id in the ./db/coco.py, where else should I modify? Thanks

@NightNightNight
Copy link

@li10141110 what's the chunk_sizes means? how can i set gpu id in this project?

@Duankaiwen
Copy link
Owner

@li10141110 Hi, the scores only affect the order of boxes.

@Duankaiwen
Copy link
Owner

@NightNightNight chunk_sizes denotes the batch size for each GPU

@NightNightNight
Copy link

@Duankaiwen thanks for you reply, i know the means of chunk_sizes now.

@lzw0515
Copy link

lzw0515 commented Nov 15, 2019

@li10141110 你好,我训练ok,test出问题:
(CenterNet) [root@add CenterNet-master]# python test.py CenterNet-104 --testiter 12000 --split validation
cfg_file: config/CenterNet-104.json
loading all datasets...
split: minival
minival
{1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 13, 13: 14, 14: 15, 15: 16, 16: 17, 17: 18, 18: 19, 19: 20, 20: 21, 21: 22, 22: 23, 23: 24, 24: 25, 25: 27, 26: 28, 27: 31, 28: 32, 29: 33, 30: 34, 31: 35, 32: 36, 33: 37, 34: 38, 35: 39, 36: 40, 37: 41, 38: 42, 39: 43, 40: 44, 41: 46, 42: 47, 43: 48, 44: 49, 45: 50, 46: 51, 47: 52, 48: 53, 49: 54, 50: 55, 51: 56, 52: 57, 53: 58, 54: 59, 55: 60, 56: 61, 57: 62, 58: 63, 59: 64, 60: 65, 61: 67, 62: 70, 63: 72, 64: 73, 65: 74, 66: 75, 67: 76, 68: 77, 69: 78, 70: 79, 71: 80, 72: 81, 73: 82, 74: 84, 75: 85, 76: 86, 77: 87, 78: 88, 79: 89, 80: 90}
loading from cache file: cache/coco_val.pkl
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
<db.coco.MSCOCO object at 0x7f04291065c0>
system config...
{'batch_size': 2,
'cache_dir': 'cache',
'chunk_sizes': [2],
'config_dir': 'config',
'data_dir': '/data2/hejin/CenterNet-master/data',
'data_rng': <mtrand.RandomState object at 0x7f0460ec1ab0>,
'dataset': 'MSCOCO',
'decay_rate': 10,
'display': 5,
'learning_rate': 0.00025,
'max_iter': 12000,
'nnet_rng': <mtrand.RandomState object at 0x7f0460ec1af8>,
'opt_algo': 'adam',
'prefetch_size': 6,
'pretrain': None,
'result_dir': 'results',
'sampling_function': 'kp_detection',
'snapshot': 500,
'snapshot_name': 'CenterNet-104',
'stepsize': 5000,
'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': 3,
'data_aug': True,
'gaussian_bump': True,
'gaussian_iou': 0.7,
'gaussian_radius': -1,
'input_size': [511, 511],
'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, 128]],
'rand_color': True,
'rand_crop': False,
'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}
loading parameters at iteration: 12000
building neural network...
module_file: models.CenterNet-104
total parameters: 209944226
loading parameters...
loading model from cache/nnet/CenterNet-104/CenterNet-104_12000.pkl
test.coco
<function testing at 0x7f0428af2158>
locating kps: 0%| | 0/10 [00:00<?, ?it/s]Traceback (most recent call last):
File "test.py", line 102, in
test(testing_db, args.split, args.testiter, args.debug, args.suffix)
File "test.py", line 62, in test
testing(db, nnet, result_dir, debug=debug)
File "/data2/hejin/CenterNet-master/test/coco.py", line 321, in testing
return globals()[system_configs.sampling_function](db, nnet, result_dir, debug=debug)
File "/data2/hejin/CenterNet-master/test/coco.py", line 129, in kp_detection
dets, center = decode_func(nnet, images, K, ae_threshold=ae_threshold, kernel=nms_kernel)
File "/data2/hejin/CenterNet-master/test/coco.py", line 54, in kp_decode
detections, center = nnet.test([images], ae_threshold=ae_threshold, K=K, kernel=kernel)
File "/data2/hejin/CenterNet-master/nnet/py_factory.py", line 114, in test
return self.model(*xs, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/CenterNet-master/nnet/py_factory.py", line 32, in forward
return self.module(*xs, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/CenterNet-master/models/py_utils/kp.py", line 290, in forward
return self._test(*xs, **kwargs)
File "/data2/hejin/CenterNet-master/models/py_utils/kp.py", line 243, in _test
inter = self.pre(image)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/CenterNet-master/models/py_utils/utils.py", line 15, in forward
bn = self.bn(conv)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 66, in forward
exponential_average_factor, self.eps)
File "/data2/hejin/anaconda2/envs/CenterNet/lib/python3.6/site-packages/torch/nn/functional.py", line 1254, in batch_norm
training, momentum, eps, torch.backends.cudnn.enabled
RuntimeError: CUDA error: out of memory

你好,我也遇到了这个问题,训练自己的数据集的时候,训练可以,但是测试就显存不足,请问怎么解决?

@Duankaiwen
Copy link
Owner

Duankaiwen commented Nov 18, 2019 via email

@yang-chenyu104
Copy link

你好,请问一下,当我缩小图片的时候,运行test.py时会出现ValueError: need at least one array to concatenate,这个原因是np.concatenate(center_points, axis=1)中center_points是空集,可能原因是缩小图片会出现没有GT的情况,那我应该怎么解决这个问题?谢谢答疑

@Duankaiwen
Copy link
Owner

@yang-chenyu104
你修改scales的值了么?

@yang-chenyu104
Copy link

yang-chenyu104 commented May 28, 2021 via email

@Duankaiwen
Copy link
Owner

谢谢解答,我把scaless修改了,有个问题不懂,为啥要加一个scales==1的判断,把那行注释了#if scale == 1:目前正在生成results.json,谢谢大佬的代码,对我帮助很大!!!,想用中心点检测去做表格方面的研究,希望在自己研究方面加深!!!

------------------ 原始邮件 ------------------ 发件人: "Duankaiwen/CenterNet" @.>; 发送时间: 2021年5月28日(星期五) 下午3:42 @.>; 抄送: "な法--言说 @.@.>; 主题: Re: [Duankaiwen/CenterNet] Testing this on my own dataset (#21) @yang-chenyu104 你修改scales的值了么? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

@yang-chenyu104
实验时发现只需要scale=1时检测到的center就够了,因此只取了scale=1时的center。希望对你有帮助。

@yang-chenyu104
Copy link

yang-chenyu104 commented May 28, 2021 via email

@yang-chenyu104
Copy link

yang-chenyu104 commented May 28, 2021 via email

@Duankaiwen
Copy link
Owner

在代码里面我怎么去找寻效果最好的一次的损失和正确率

------------------ 原始邮件 ------------------ 发件人: "Duankaiwen/CenterNet" @.>; 发送时间: 2021年5月28日(星期五) 下午4:00 @.>; 抄送: "な法--言说 @.@.>; 主题: Re: [Duankaiwen/CenterNet] Testing this on my own dataset (#21) 谢谢解答,我把scaless修改了,有个问题不懂,为啥要加一个scales==1的判断,把那行注释了#if scale == 1:目前正在生成results.json,谢谢大佬的代码,对我帮助很大!!!,想用中心点检测去做表格方面的研究,希望在自己研究方面加深!!! … ------------------ 原始邮件 ------------------ 发件人: "Duankaiwen/CenterNet" @.>; 发送时间: 2021年5月28日(星期五) 下午3:42 @.>; 抄送: "な法--言说 @.@.>; 主题: Re: [Duankaiwen/CenterNet] Testing this on my own dataset (#21) @yang-chenyu104 你修改scales的值了么? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. @yang-chenyu104 实验时发现只需要scale=1时检测到的center就够了,因此只取了scale=1时的center。希望对你有帮助。 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

@yang-chenyu104

每次iter只有loss,等训练结束之后才统一测检测精度,所以没有办法去找效果最好的一次的正确率,你倒是可以找到1w,2w,..., 48w iter,这48个中最好的一次精度,因为每隔10000个iter会保存一次模型,比如你训练了480000 iters,那么你就有48个模型,加载每个模型测一下,找出最好的精度.

在trian.py line 138和line 154有每个iter之后的loss,你可以统计一下,找到最好的一次loss

@yang-chenyu104
Copy link

yang-chenyu104 commented May 28, 2021 via email

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

8 participants