def get_label(Dir): for nextdir in os.listdir(Dir): if not nextdir.startswith('.'): if nextdir in ['NORMAL']: label = 0 elif nextdir in ['PNEUMONIA']: label = 1 else: label = 2 return nextdir, label code example
Example: def get_label(Dir): for nextdir in os.listdir(Dir): if not nextdir.startswith('.'): if nextdir in ['NORMAL']: label = 0 elif nextdir in ['PNEUMONIA']: label = 1 else: label = 2 return nextdir, label
def get_label(Dir):
for nextdir in os.listdir(Dir):
if not nextdir.startswith('.'):
if nextdir in ['NORMAL']:
label = 0
elif nextdir in ['PNEUMONIA']:
label = 1
else:
label = 2
return nextdir, label