How to make inference for single image?

I have trained a segmentation model and saved it in an export.pkl file. Now, I want to run inference on this model for a single new image. Here’s the code I tried-

def acc_camvid(input, target):
    target = target.squeeze(1)
    mask = target != void_code
    return (input.argmax(dim=1)[mask]==target[mask]).float().mean()

metrics = acc_camvid
learn = load_learner("./")
img = open_image("test/2.jpg")
pred = learn.predict(img)[0]
pred.save("pred.jpg")

But on opening pred.jpg, I find a completely black image. How can I predict and produce a mask on 2.jpg?