EasyMocap icon indicating copy to clipboard operation
EasyMocap copied to clipboard

json.decoder error (Mediapipe)

Open Vinayky86 opened this issue 2 years ago • 9 comments

Hello.. thanks for this amazing development.. I was trying to use mediapipe for MV1P and i followed these steps 1 - python apps/preprocess/extract_image.py 0_input\project 2 - python apps/preprocess/extract_keypoints.py 0_input\project --mode mp-pose and 3 - python apps/demo/mv1p.py 0_input/project --out 1_output/project --vis_det --vis_repro --sub_vis 1 2 3 4 --vis_smpl

but when i run 3rd steps (mv1p.py), getting this error

Traceback (most recent call last): File "apps/demo/mv1p.py", line 117, in mv1pmf_skel(dataset, check_repro=True, args=args) File "apps/demo/mv1p.py", line 35, in mv1pmf_skel images, annots = dataset[nf] File "c:\mocap\easymocap\easymocap\dataset\mv1pmf.py", line 72, in getitem images, annots_all = super().getitem(index) File "c:\mocap\easymocap\easymocap\dataset\base.py", line 482, in getitem annot = read_annot(annname, self.kpts_type) File "c:\mocap\easymocap\easymocap\mytools\file_utils.py", line 46, in read_annot data = read_json(annotname) File "c:\mocap\easymocap\easymocap\mytools\file_utils.py", line 19, in read_json data = json.load(f) File "C:\Users\Vinayky86\anaconda3\envs\easymocap\lib\json_init_.py", line 296, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "C:\Users\Vinayky86\anaconda3\envs\easymocap\lib\json_init_.py", line 348, in loads return _default_decoder.decode(s) File "C:\Users\Vinayky86\anaconda3\envs\easymocap\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\Vinayky86\anaconda3\envs\easymocap\lib\json\decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Invalid \escape: line 2 column 19 (char 20)

Please correct me if I am doing any wrong steps thank you ...!!!

Vinayky86 avatar Jul 28 '22 06:07 Vinayky86

Hello, you can print the filename when the error occurs.

chingswy avatar Jul 29 '22 07:07 chingswy

thanks for your response..!! am i following the right steps..? 1 - python apps/preprocess/extract_image.py 2 - python apps/preprocess/extract_keypoints.py 3 - python apps/demo/mv1p.py

"Actully i don't know lot of things about coading,
can you please direct me what is the main reason of this error" thanks a lot..!!

Vinayky86 avatar Jul 29 '22 09:07 Vinayky86

Seems the file is corrupted. You can remove the annots folder and generate again.

chingswy avatar Jul 29 '22 09:07 chingswy

thanks... i did this step around 4 times delete and regenerate the annots. but nothing happened. but i found little difference in mediapipe's annots in openpose annots - "filename": "images\1\000000.jpg", in mediapipe annots - "filename": "1\000000.jpg", can it cause the Json.decoder error..?

Vinayky86 avatar Jul 29 '22 09:07 Vinayky86

No. This won't cause the decode error.

chingswy avatar Jul 30 '22 07:07 chingswy

Ok thanks for your reply..!!! I will try

Vinayky86 avatar Jul 30 '22 09:07 Vinayky86

The Problem is in the JSON files there should be two \ in the filename but there is only one

run this command for each camera

import os

os.chdir(r'path\to\json\folder')

for fp in os.listdir('.'):
    if fp.endswith('.json'):
        f = open(fp, 'r+')
        content = f.read()
        f.seek(0)
        f.truncate()

        f.write(content[:26] + r"\\" + content[27:])
        f.close()

NishilVani avatar Aug 03 '22 06:08 NishilVani

Thanks @NishilVani . Maybe it's a bug in windows? I didn't test the code on Windows now.

chingswy avatar Aug 03 '22 08:08 chingswy

Thank you very much @NishilVani your code successfully convert .json file for each cameras, but easymocap giving same jsondecoder error. BTW thanks again for your help you are very kind, really appreciate 🙏🙏

Vinayky86 avatar Aug 03 '22 10:08 Vinayky86

Probably related to #198

ferhatsb avatar Sep 13 '22 15:09 ferhatsb

Thank you very much @ferhatsb exactly..👌you have solved the problem..👏👏❤️

Vinayky86 avatar Sep 13 '22 16:09 Vinayky86