peal.global_utils.get_predictions¶
- peal.global_utils.get_predictions(args)[source]¶
Predict a whole dataset and write the labels to a csv file.
Runs
args.classifieroverargs.datasetwith gradients disabled, accepting the several sample layouts used in PEAL and in the vendored code ((img, lab, file)triples, dicts withx/y/urland(img, y)pairs whoseybundles label, hint, index and filename). Multi-logit outputs are argmaxed, single-logit outputs thresholded at 0. The accuracy against the dataset labels is printed.- Parameters:
args (
object) – Needsdataset,classifier,batch_sizeandlabel_path; optionallymax_samplesto stop early andis_image_to_class, which prefixes each filename with its class directory so the csv matches an ImageFolder layout.- Returns:
A csv with the columns
idxandpredictionis written toargs.label_path;idxfalls back to the running sample number when the dataset yields no filenames. Note that a directory namedutilsis created in the working directory as a side effect.- Return type: