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

bug fix: Remove the NUL character at the end to avoid JSONDecodeError #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

keepcreative
Copy link

@keepcreative keepcreative commented May 13, 2024

Remove the NUL character at the end to avoid JSONDecodeError

the code before may cause the error below:

Traceback (most recent call last):
File "/path/to/evaluate.py", line 65, in
eval_res = evaluate_metrics_from_lists(gen_captions, true_captions)
File "/path/to/caption_evaluation_tools/eval_metrics.py", line 156, in evaluate_metrics_from_lists
metrics, per_file_metrics = evaluate_metrics_from_files(
File "/path/to/caption_evaluation_tools/eval_metrics.py", line 102, in evaluate_metrics_from_files
cocoEval.evaluate()
File "/path/to/caption_evaluation_tools/coco_caption/pycocoevalcap/eval.py", line 72, in evaluate
score, scores = scorer.compute_score(gts, res)
File "/path/to/caption_evaluation_tools/coco_caption/pycocoevalcap/spice/spice.py", line 79, in compute_score
results = json.load(data_file)
File "/path/to/miniconda3/envs/myenv/lib/python3.9/json/init.py", line 293, in load
return loads(fp.read(),
File "/path/to/miniconda3/envs/myenv/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/path/to/miniconda3/envs/myenv/lib/python3.9/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 71062 column 2 (char 1260980)

where the 'Extra data: line 71062 column 2' is actually a NUL symbol.

Remove the NUL character at the end to avoid JSONDecodeError
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

Successfully merging this pull request may close these issues.

1 participant