Skip to content

Instantly share code, notes, and snippets.

@seaslee
Created March 30, 2013 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seaslee/5276281 to your computer and use it in GitHub Desktop.
Save seaslee/5276281 to your computer and use it in GitHub Desktop.
walk the two level files like following: ====dir ||subdir ||files ||subdir ||files ...
def imgs(imgsdir):
for dirname, subdirnames, subfiles in os.walk(imgsdir):
#subdir for each query of images
for subdir in subdirnames:
for dirname1, subdirnames1, subfiles1 in os.walk(os.path.join(dirname, subdir)):
#each image in the directory of one query
for img in subfiles1:
imgpath = os.path.join(dirname1, img)
yield imgpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment