Skip to content

Commit

Permalink
Save predictions as JSON list
Browse files Browse the repository at this point in the history
Previously was being stored as Python list
(eg. with single quotes strings)
  • Loading branch information
Sohang Chopra committed Jun 4, 2023
1 parent e37d96a commit fc3be9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion classify/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import argparse
import csv
import json
import io
import os
import platform
Expand Down Expand Up @@ -152,7 +153,7 @@ def run(
top_pred_index = top5i[0]
csv_output.writerow({
'path': path,
'top_5_predicted': [(names[j], prob[j].item()) for j in top5i],
'top_5_predicted': json.dumps([(names[j], prob[j].item()) for j in top5i]),
'label': names[top_pred_index],
'confidence': f'{prob[top_pred_index]:.2f}'
})
Expand Down

0 comments on commit fc3be9e

Please sign in to comment.