将kinetics-skleton数据集转换为训练使用的npy与pkl文件时

将kinetics-skleton数据集转换为训练使用的npy与pkl文件时,出现下列问题:

Traceback (most recent call last):--------------------------- ]
  File "tools/kinetics_gendata.py", line 88, in <module>
    gendata(data_path, label_path, data_out_path, label_out_path)
  File "tools/kinetics_gendata.py", line 46, in gendata
    window_size=max_frame)
  File "D:\jiafeng\project\st-gcn-master\feeder\feeder_kinetics.py", line 56, in __init__
    self.load_data()
  File "D:\jiafeng\project\st-gcn-master\feeder\feeder_kinetics.py", line 69, in load_data
    label_info = json.load(f)
  File "D:\software\anaconda3\envs\pytorch\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "D:\software\anaconda3\envs\pytorch\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "D:\software\anaconda3\envs\pytorch\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\software\anaconda3\envs\pytorch\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

我导入的json文件部分格式如下:

{"data": [{"frame_index": 150, "skeleton": [{"pose": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "score": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}]}], "label": "falling", "label_index": 3}

这是报错的代码部分:

img

根据错误信息提示,可能是json文件格式不正确导致的。建议检查一下json文件的格式是否符合标准的json格式,比如是否有缺失的括号、逗号等。

可以使用在线的json格式验证工具来检查json文件格式是否正确,比如:https://jsonformatter.curiousconcept.com/%E3%80%82

另外,也可以尝试在代码中使用try-catch语句来捕捉异常并打印出错信息,以便更好地定位问题所在。例如:

try:
    label_info = json.load(f)
except json.decoder.JSONDecodeError as e:
    print(f"Error parsing JSON: {e}")