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

Fix vqa dataset loading #1195

Merged
merged 8 commits into from
Jun 21, 2024
Merged
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
12 changes: 3 additions & 9 deletions swift/llm/utils/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,16 +1346,14 @@ def preprocess_row(row):
def preprocess_okvqa(dataset):

def preprocess(row):
image = row['image']
query = row['question']
response = np.random.choice(row['answers'])
return {
'response': response,
'images': image,
'query': query,
}

return dataset.map(preprocess, load_from_cache_file=False)
return dataset.map(preprocess, load_from_cache_file=False).rename_column('image', 'images')


register_dataset(
Expand All @@ -1371,16 +1369,14 @@ def preprocess(row):
def preprocess_a_okvqa(dataset):

def preprocess(row):
image = row['image']
query = row['question']
response = np.random.choice(row['rationales'])
return {
'response': response,
'images': image,
'query': query,
}

return dataset.map(preprocess, load_from_cache_file=False)
return dataset.map(preprocess, load_from_cache_file=False).rename_column('image', 'images')


register_dataset(
Expand All @@ -1396,17 +1392,15 @@ def preprocess(row):
def preprocess_ocr_vqa(dataset):

def preprocess(row):
image = row['image']
idx = np.random.choice(range(len(row['questions'])))
query = row['questions'][idx]
response = row['answers'][idx]
return {
'response': response,
'images': image,
'query': query,
}

return dataset.map(preprocess, load_from_cache_file=False)
return dataset.map(preprocess, load_from_cache_file=False).rename_column('image', 'images')


register_dataset(
Expand Down
Loading