Created
June 5, 2018 12:37
-
-
Save kalaspuffar/2eabd4d38cd3a7de0dde4b35c8be7aa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
addrs = [ | |
'PetImages/A/test1.jpg', | |
'PetImages/B/test3.jpg', | |
'PetImages/B/test3.jpg', | |
'PetImages/C/test4.jpg', | |
'PetImages/D/test2.jpg', | |
'PetImages/C/test4.jpg', | |
'PetImages/A/test1.jpg', | |
'PetImages/D/test2.jpg' | |
] | |
letterString = 'ABCDEFGHJKLMNOPQRSTUVWXYZ' | |
labels = [] | |
for addr in addrs: | |
m = re.match('PetImages/([A-Z])/.*', addr) | |
labels.append(letterString.find(m.group(1))) | |
print labels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @kalaspuffar. I am trying out this code for around 40 classes, however my label names are not single letters such A,B,C. They have such names as character_1_ka. As i understand, the letterString looks at each character of the string as a label, yes? Would this be fixed by creating an array of strings as letterString?