(args)
| 7 | |
| 8 | |
| 9 | def process_files(args): |
| 10 | all_predictions = collections.OrderedDict() |
| 11 | all_labels = collections.OrderedDict() |
| 12 | all_uid = collections.OrderedDict() |
| 13 | for path in args.paths: |
| 14 | path = os.path.join(path, args.prediction_name) |
| 15 | try: |
| 16 | data = torch.load(path) |
| 17 | for dataset in data: |
| 18 | name, d = dataset |
| 19 | predictions, labels, uid = d |
| 20 | if name not in all_predictions: |
| 21 | all_predictions[name] = np.array(predictions) |
| 22 | if args.labels is None: |
| 23 | args.labels = [i for i in range(all_predictions[name].shape[1])] |
| 24 | if args.eval: |
| 25 | all_labels[name] = np.array(labels) |
| 26 | all_uid[name] = np.array(uid) |
| 27 | else: |
| 28 | all_predictions[name] += np.array(predictions) |
| 29 | assert np.allclose(all_uid[name], np.array(uid)) |
| 30 | except Exception as e: |
| 31 | print(e) |
| 32 | continue |
| 33 | return all_predictions, all_labels, all_uid |
| 34 | |
| 35 | |
| 36 | def get_threshold(all_predictions, all_labels, one_threshold=False): |
no test coverage detected