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

DELF: Fix CSV read error #11249

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
4 changes: 2 additions & 2 deletions research/delf/delf/python/training/build_image_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _get_all_image_files_and_labels(name, csv_path, image_dir):
image_paths = tf.io.gfile.glob(os.path.join(image_dir, '*.jpg'))
file_ids = [os.path.basename(os.path.normpath(f))[:-4] for f in image_paths]
if name == _TRAIN_SPLIT:
with tf.io.gfile.GFile(csv_path, 'rb') as csv_file:
with tf.io.gfile.GFile(csv_path, 'r') as csv_file:
df = pd.read_csv(csv_file)
df = df.set_index('id')
labels = [int(df.loc[fid]['landmark_id']) for fid in file_ids]
Expand All @@ -140,7 +140,7 @@ def _get_clean_train_image_files_and_labels(csv_path, image_dir):
a continuous set of labels.
"""
# Load the content of the CSV file (landmark_id/label -> images).
with tf.io.gfile.GFile(csv_path, 'rb') as csv_file:
with tf.io.gfile.GFile(csv_path, 'r') as csv_file:
df = pd.read_csv(csv_file)

# Create the dictionary (key = image_id, value = {label, file_id}).
Expand Down