Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the ordering of the filenames #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@ def image_names(cityscapes_root, subset, citynames=False):
- `subset` the subset to be loaded can be one of `train`, `test`, `val`, `train_extra`.
'''
image_folder = os.path.join(cityscapes_root, 'leftImg8bit', subset)
cnames = []
inames = []

# This is a list of tuples of the form (filename, cityname)
image_names = []

#Get all the images in the subfolders
for city in os.listdir(image_folder):
city_folder = os.path.join(image_folder, city)

for fname in os.listdir(city_folder):
if fname.endswith('.png'):
inames.append(os.path.join(city_folder, fname))
cnames.append(city)
image_names.append((os.path.join(city_folder, fname), city))

# Make sure that the ordering of the filenames is invariant under the possible
# directory traversals. This is important if we want to generate the demo video.
image_names = sorted(image_names, key=lambda x: x[0])

# Restore the original return format
inames, cnames = map(list, zip(*image_names))

return (inames, cnames) if citynames else inames

Expand Down