Can you tell me how to return the results of a test as a JSON file? #1484
-
I've completed CNN code in the past. However, I understand that pkl files are currently the only file type that can be returned via test.py. I would like to have the results in the form of a json file. How can I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Here is an example: I get the result from the shell:
Note that: result in pkl file is a list of dict: make sure to change to |
Beta Was this translation helpful? Give feedback.
Here is an example:
I get the result from the shell:
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.