Skip to content

Can you tell me how to return the results of a test as a JSON file? #1484

Answered by Ezra-Yu
sinyoung-park asked this question in Q&A
Discussion options

You must be logged in to vote

Here is an example:

I get the result from the shell:

python tools/test.py $CFG $CKPT_PATH --out result.pkl --out-item pred

Note that:

result in pkl file is a list of dict:
each dict contains :('img_path', <class 'str'>), ('scale_factor', <class 'tuple'>), ('ori_shape', <class 'tuple'>), ('img_shape', <class 'tuple'>), ('sample_idx', <class 'int'>), ('num_classes', <class 'int'>), ('pred_score', <class 'torch.Tensor'>), ('pred_label', <class 'torch.Tensor'>), ('gt_score', <class 'torch.Tensor'>), ('gt_label', <class 'torch.Tensor'>)

make sure to change to torch.Tensor into python float, int, and list before dump into JSON file.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sinyoung-park
Comment options

Answer selected by sinyoung-park
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants