Skip to content

Instantly share code, notes, and snippets.

@danielcwq
Created December 22, 2021 07:01
Show Gist options
  • Save danielcwq/aa1423774c4033c22d40c596ea7ae1c4 to your computer and use it in GitHub Desktop.
Save danielcwq/aa1423774c4033c22d40c596ea7ae1c4 to your computer and use it in GitHub Desktop.
x = dls.vocab
image = (path/'images/00000181_035.png') #some random image from the database
def match(raw, vocab):
return [[vocab[0],(raw[0].item()*100)],[vocab[1],(raw[1].item()*100)],[vocab[2],(raw[2].item()*100)],[vocab[3],(raw[3].item()*100)],[vocab[4],(raw[4].item()*100)],[vocab[5],(raw[5].item()*100)],[vocab[6],(raw[6].item()*100)],[vocab[7],(raw[7].item()*100)],[vocab[8],(raw[8].item()*100)],[vocab[9],(raw[9].item()*100)],[vocab[10],(raw[10].item()*100)],[vocab[11],(raw[11].item()*100)],[vocab[12],(raw[12].item()*100)],[vocab[13],(raw[13].item()*100)],[vocab[14],(raw[14].item()*100)]]
def list_preds(img_path):
prediction, indice, losses = learn.predict(img_path)
arr = match(losses, x)
return(arr)
list_preds(image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment