xingyizhou / CenterNet2

Two-stage CenterNet
Apache License 2.0
1.21k stars 188 forks source link

run demo.py for video output error #74

Open Dannyxu1031 opened 2 years ago

Dannyxu1031 commented 2 years ago

python demo.py --video-input /workspace/xdy/CenterNet2-master/output/video/2021111616185900.mp4 [12/09 01:25:50 detectron2]: Arguments: Namespace(config_file='/workspace/xdy/CenterNet2-master/projects/CenterNet2/configs/CenterNet2_DLA-BiFPN-P5_640_16x_ST.yaml', webcam=False, video_input='/workspace/xdy/CenterNet2-master/output/video/2021111616185900.mp4', input=None, output='/workspace/xdy/CenterNet2-master/output/val/', confidence_threshold=0.3, opts=[]) WARNING [12/09 01:25:50 d2.config.compat]: Config '/workspace/xdy/CenterNet2-master/projects/CenterNet2/configs/CenterNet2_DLA-BiFPN-P5_640_16x_ST.yaml' has no VERSION. Assuming it to be compatible with latest v2. Loading pretrained DLA! 0%| | 0/7501 [00:01<?, ?it/s] Traceback (most recent call last): File "/workspace/xdy/CenterNet2-master/projects/CenterNet2/demo.py", line 185, in for vis_frame in tqdm.tqdm(demo.run_on_video(video), total=num_frames): File "/root/miniconda3/envs/detectron2/lib/python3.9/site-packages/tqdm/std.py", line 1180, in iter for obj in iterable: File "/workspace/xdy/CenterNet2-master/projects/CenterNet2/predictor.py", line 152, in run_on_video yield process_predictions(frame, self.predictor(frame)) File "/workspace/xdy/CenterNet2-master/projects/CenterNet2/predictor.py", line 115, in process_predictions vis_frame = video_visualizer.draw_instance_predictions(frame, predictions) File "/workspace/xdy/detectron2/detectron2/utils/video_visualizer.py", line 109, in draw_instance_predictions else [y[0] for y in filter(lambda x: x[1], zip(labels, visibilities))] TypeError: 'NoneType' object is not iterable

I run demo.py for video output,but something wrong here.But when I run demo.py with Base-CenterNet2.yaml,it work.how can i fix it?

Dannyxu1031 commented 2 years ago

There always wrong when I used the argument "--opts MODEL.WEIGHTS"

Boatsure commented 2 years ago

Hi @Dannyxu1031 have you figured the issue out?

I find that the NoneType problem comes from the visibilities--labels--duration and finally turns out to be the predictions dict not including the _IDduration key: durations = predictions.ID_duration if predictions.has("ID_duration") else None

the prediction of model CenterNet2_R50_1x is: <class 'detectron2.structures.instances.Instances'> Instances(num_instances=39, image_height=542, image_width=807, fields= [pred_boxes: Boxes(tensor([[241.1353, 139.6680, 375.6159, 197.3571], [604.5829, 141.3495, 656.8168, 165.8259], [276.3841, 225.3874, 573.3428, 483.9016], [372.2970, 148.4080, 477.9282, 191.1354], [501.4162, 141.7366, 545.5916, 169.5368], [763.7508, 139.8452, 797.9053, 175.4382], [542.8406, 134.1765, 607.2749, 168.4592], [ 2.0638, 142.5656, 79.9496, 184.2120], [337.7661, 134.5329, 411.2755, 162.6599], [111.1094, 115.5351, 126.5559, 124.9969], [125.5042, 115.0389, 151.5087, 129.8213], [739.4490, 141.0512, 779.1739, 161.4336], [ 79.7839, 117.6921, 110.8978, 136.0438], [716.1653, 140.6606, 744.0775, 161.7662], [212.7217, 139.5664, 271.5062, 177.7411], [696.8834, 140.5839, 742.4159, 162.4066], [174.0790, 120.8204, 210.0613, 135.5340], [214.9684, 124.3780, 231.7171, 134.9491], [542.7147, 137.1107, 575.5455, 167.6913], [469.0678, 170.3258, 543.6485, 238.9222], [180.7123, 123.1844, 211.9622, 135.1333], [105.5332, 115.1088, 125.4691, 125.6428], [472.3793, 141.9874, 545.4722, 170.2103], [473.3885, 147.4614, 513.0460, 170.4382], [ 2.4199, 142.6647, 36.9965, 184.3582], [336.5692, 136.4574, 377.8730, 160.0500], [280.0128, 124.7579, 317.7306, 138.9644], [171.5089, 116.8886, 201.7563, 134.1216], [696.7322, 141.3676, 729.3130, 162.5914], [469.0678, 170.3258, 543.6485, 238.9222], [771.5851, 130.7168, 795.5539, 144.2596], [ 81.7277, 115.2408, 108.9647, 131.9405], [695.9254, 129.7966, 704.5533, 141.3309], [113.4691, 114.2615, 143.1823, 127.2237], [472.9387, 153.7226, 480.4456, 168.7634], [469.2350, 196.9153, 544.2471, 237.9603], [118.9201, 115.1781, 143.0161, 128.7013], [188.2796, 124.4722, 214.7957, 135.0403], [ 60.7254, 150.7339, 81.0295, 181.7287]])), scores: tensor([0.9408, 0.9379, 0.9376, 0.9237, 0.8962, 0.8423, 0.8215, 0.8173, 0.7885, 0.7645, 0.7584, 0.7530, 0.7295, 0.7114, 0.7082, 0.6648, 0.6562, 0.6121, 0.5982, 0.5779, 0.5294, 0.5046, 0.4942, 0.4880, 0.4769, 0.4741, 0.4723, 0.4706, 0.4571, 0.4199, 0.4031, 0.4021, 0.3771, 0.3743, 0.3703, 0.3409, 0.3377, 0.3323, 0.3114]), pred_classes: tensor([ 2, 2, 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 56, 2, 2, 2, 2, 2, 13, 2, 2, 2])])

hzt97 commented 2 years ago

use --video-input instead of --input

hlr7999 commented 2 years ago

Hi, @surefyyq , you can change line 76 in detectron2/utils/video_visualizer.py from durations = predictions.ID_duration if predictions.has("ID_duration") else None to durations = predictions.ID_duration if predictions.has("ID_duration") else [1]*num_instances. That works for me.

Dannyxu1031 commented 2 years ago

Thanks for your reply! I will try it.

------------------ 原始邮件 ------------------ 发件人: "Liren @.>; 发送时间: 2022年4月24日(星期天) 下午5:44 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [xingyizhou/CenterNet2] run demo.py for video output error (Issue #74)

Hi, @surefyyq , you can change line 76 in detectron2/utils/video_visualizer.py from durations = predictions.ID_duration if predictions.has("ID_duration") else None to durations = predictions.ID_duration if predictions.has("ID_duration") else [1]*num_instances. And then reinstall detectron2 by python -m pip install -e CenterNet2. That works for me.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

xin9726 commented 2 years ago

Please how can I modify it so that it only detects people, I have not found the code to modify the label