Skip to content

Instantly share code, notes, and snippets.

@sxjscience
Last active May 5, 2021 22:08
Show Gist options
  • Save sxjscience/52e5fc68f0ac1e47d257b4ad24d4b3b8 to your computer and use it in GitHub Desktop.
Save sxjscience/52e5fc68f0ac1e47d257b4ad24d4b3b8 to your computer and use it in GitHub Desktop.
import os
from PIL import Image
base_dir = 'image manually'
with open('label_file.txt', 'w') as of:
for filename in os.listdir(base_dir):
print('Labeling filename', filename)
img = Image.open(os.path.join(base_dir, filename))
img.show()
label = input('Flood = 0, Non-flood=1: ')
of.write('{}\t{}\n'.format(filename, label))
img.close()
of.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment