Skip to content

Instantly share code, notes, and snippets.

@gauravbansal98
Created May 13, 2020 12:33
Show Gist options
  • Select an option

  • Save gauravbansal98/1bd89557b820b16e68cf75d59673e8ff to your computer and use it in GitHub Desktop.

Select an option

Save gauravbansal98/1bd89557b820b16e68cf75d59673e8ff to your computer and use it in GitHub Desktop.
# load doc into memory
def load_doc(filename):
# open the file as read only
file = open(filename, 'r')
# read all text
text = file.read()
# close the file
file.close()
return text
# load a pre-defined list of photo identifiers
def load_set(filename):
doc = load_doc(filename)
dataset = list()
# process line by line
for line in doc.split('\n'):
# skip empty lines
if len(line) < 1:
continue
# get the image identifier
identifier = line.split('.')[0]
dataset.append(identifier)
return set(dataset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment