JunweiLiang / Object_Detection_Tracking

Out-of-the-box code and models for CMU's object detection and tracking system for multi-camera surveillance videos. Speed optimized Faster-RCNN model. Tensorflow based. Also supports EfficientDet. WACVW'20
MIT License
486 stars 134 forks source link

TypeError: Object of type 'int64' is not JSON serializable #15

Closed Neo-YH closed 4 years ago

Neo-YH commented 4 years ago

image 出现了这个报错,我试试能不能解决它。要是解决了我把方法发布上来,总是麻烦学长解答真不好意思。

Neo-YH commented 4 years ago

image

pred列表里放的字典里的数据应该是float型的为什么报的int64呢

Neo-YH commented 4 years ago

image 按照网上的方法,自定义了一下serialize的方法,好像不行 应该是要把numpy.int64转成python里有的数据类型吧

Neo-YH commented 4 years ago

image 多亏了朋友的帮助,发现cat_id还要int强制转化一下

JunweiLiang commented 4 years ago

这行代码?我之前都直接输出tracking,所以没有遇到这个问题

Neo-YH commented 4 years ago

是的,加了int之后这里没问题了,原理我还不太明白

Neo-YH commented 4 years ago

res里面各项注释了一遍,发现是cat_id这里的问题,然后加了个int转换试试

JunweiLiang commented 4 years ago

感谢,我待会更新代码。这个错误很常见,python自带的json不会自动转换numpy的数据类型

Neo-YH commented 4 years ago

多谢学长,是我该说感谢。还有个问题想问一下

Neo-YH commented 4 years ago

image 我看进度条用的是利用tqdm输出的,这两个进度条都是0%,是不是读取视频还是存在问题呀

JunweiLiang commented 4 years ago

请把完整的报错信息以及你运行的命令粘贴下来

Neo-YH commented 4 years ago

运行命令: python obj_detect_tracking.py --model_path obj_v3_model --version 3 --video_dir v1-val_testvideos --video_lst_file v1-val_testvideos.lst --out_dir test_json_out --frame_gap 1 --get_tracking --tracking_dir testtrack

Neo-YH commented 4 years ago

/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/sklearn/utils/linearassignment.py:22: FutureWarning: The linearassignment module is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead. FutureWarning) 0%| | 0/1 [00:00<?, ?it/s]<VideoCapture 0x7fd7b86b7410> 0%| | 0/1 [00:04<?, ?it/s] Traceback (most recent call last): File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1334, in _do_call return fn(*args) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1319, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[1] = [0] is repeated [[{{node fastrcnn_predictions/map/while/SparseToDense}} = SparseToDense[T=DT_BOOL, Tindices=DT_INT32, _class=["loc:@fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3"], validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](fastrcnn_predictions/map/while/Neg_1/_1301, fastrcnn_predictions/map/while/Shape/_1303, fastrcnn_predictions/map/while/SparseToDense/sparse_values/_1305, fastrcnn_predictions/map/while/SparseToDense/default_value/_1307)]] [[{{node fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3/_1315}} = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_4724_fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "obj_detect_tracking.py", line 614, in sess_input, feed_dict=feed_dict) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1152, in _run feed_dict_tensor, options, run_metadata) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1328, in _do_run run_metadata) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1348, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: indices[1] = [0] is repeated [[node fastrcnn_predictions/map/while/SparseToDense (defined at /home/c1080/zyh/ObjectDetectionTracking/Object_Detection_Tracking-master/models.py:1222) = SparseToDense[T=DT_BOOL, Tindices=DT_INT32, _class=["loc:@fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3"], validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](fastrcnn_predictions/map/while/Neg_1/_1301, fastrcnn_predictions/map/while/Shape/_1303, fastrcnn_predictions/map/while/SparseToDense/sparse_values/_1305, fastrcnn_predictions/map/while/SparseToDense/default_value/_1307)]] [[{{node fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3/_1315}} = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_4724_fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

Caused by op 'fastrcnn_predictions/map/while/SparseToDense', defined at: File "obj_detect_tracking.py", line 480, in model = get_model(args, args.gpuid_start, controller=args.controller) File "/home/c1080/zyh/ObjectDetectionTracking/Object_Detection_Tracking-master/models.py", line 102, in get_model model = Mask_RCNN_FPN(config, gpuid=gpuid) File "/home/c1080/zyh/ObjectDetectionTracking/Object_Detection_Tracking-master/models.py", line 278, in init self.build_forward() File "/home/c1080/zyh/ObjectDetectionTracking/Object_Detection_Tracking-master/models.py", line 925, in build_forward decoded_boxes, label_probs) File "/home/c1080/zyh/ObjectDetectionTracking/Object_Detection_Tracking-master/models.py", line 1289, in fastrcnn_predictions parallel_iterations=10) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 494, in map_fn maximum_iterations=n) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3291, in while_loop return_same_structure) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3004, in BuildLoop pred, body, original_loop_vars, loop_vars, shape_invariants) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2939, in _BuildLoop body_result = body(packed_vars_for_body) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3260, in body = lambda i, lv: (i + 1, orig_body(lv)) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py", line 483, in compute packed_fn_values = fn(packed_values) File "/home/c1080/zyh/ObjectDetectionTracking/Object_Detection_Tracking-master/models.py", line 1222, in nms_return_masks default_value=False) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 306, in new_func return func(*args, *kwargs) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/sparse_ops.py", line 887, in sparse_to_dense name=name) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/gen_sparse_ops.py", line 2899, in sparse_to_dense name=name) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func return func(args, **kwargs) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op op_def=op_def) File "/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1770, in init self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): indices[1] = [0] is repeated [[node fastrcnn_predictions/map/while/SparseToDense (defined at /home/c1080/zyh/ObjectDetectionTracking/Object_Detection_Tracking-master/models.py:1222) = SparseToDense[T=DT_BOOL, Tindices=DT_INT32, _class=["loc:@fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3"], validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](fastrcnn_predictions/map/while/Neg_1/_1301, fastrcnn_predictions/map/while/Shape/_1303, fastrcnn_predictions/map/while/SparseToDense/sparse_values/_1305, fastrcnn_predictions/map/while/SparseToDense/default_value/_1307)]] [[{{node fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3/_1315}} = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_4724_fastrcnn_predictions/map/while/TensorArrayWrite/TensorArrayWriteV3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

Neo-YH commented 4 years ago

image 再跑没出现这个报错了,就abort了

JunweiLiang commented 4 years ago

/home/c1080/anaconda3/envs/tf/lib/python3.6/site-packages/sklearn/utils/linearassignment.py:22: FutureWarning: The linearassignment module is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead.

这个warning不应该出现,请更新代码(deep_sort/) 你的video里是否有avi格式,有的话参照这个example--use_lijun或者--use_moviepy

Neo-YH commented 4 years ago

好的,我现在试试,video是测试用的MP4 wget https://aladdin-eax.inf.cs.cmu.edu/shares/diva_obj_detect_models/models/v1-val_testvideos.tgz

JunweiLiang commented 4 years ago

我更新了代码和README并测试过了,可以git pull一下然后再试试。

Neo-YH commented 4 years ago

我赶紧试试,感谢学长

Neo-YH commented 4 years ago

学长,我想问一下你用的tensorflow-gpu的版本号,能看一下你配置的环境吗

JunweiLiang commented 4 years ago

tf 1.15.2, CUDA 10.0, cuDNN 7.6