text_plain_output_1.png
import json

import torch

test_dir = '../input/birdclef-2022/test_soundscapes'
test_base_path = '../input/birdclef-2022/test.csv'
class_dict_base_path = '../input/birdclef-2022-saved-weights-and-misc/class_dict.json'
best_acc_mode_base_path = '../input/birdclef-2022-saved-weights-and-misc/birdclef2022-best_accuracy_model.pt'
best_loss_model_base_path = '../input/birdclef-2022-saved-weights-and-misc/birdclef2022-best_loss_model.pt'

class_labels = json.load(open(class_dict_base_path, 'r'))
num_classes = len(class_labels.keys())

device = 'cuda:0' if torch.cuda.is_available() else 'cpu'
device

best_model = CLEFNetwork(num_classes)
checkpoint = torch.load(best_loss_model_base_path, map_location=torch.device(device))
best_model.load_state_dict(checkpoint['model'])
print(best_model)