-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
The error
Traceback (most recent call last):
File "create_tf_record_from_joint_dataset.py", line 109, in main
allow_sample_reuse)
File "create_tf_record_from_joint_dataset.py", line 141, in attempt_to_find_sample_that_is_not_yet_in_dataset
return random.choice(all_items_in_category)
File "/opt/python/3.7.15/lib/python3.7/random.py", line 261, in choice
raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence
When list of documents in given engraving is empty, the random.choice crashes. The code assumes that there will be some documents, even though in documentation it is said, that engraving specifications can be left out.
How to replicate
- create dataset with no information about engravings
- run
create_tf_record_from_joint_dataset.pywith the dataset created above
Possible fix
# create_tf_record_from_joint_dataset.py, line 97
with tqdm(desc="Serializing annotations", total=target_size) as progress_bar:
while samples_written < target_size:
current_engraving, number_of_staves = sampling_categories[index % len(sampling_categories)]
all_items_in_category = dataset[current_engraving][number_of_staves]
# fix, check if there are any documents
if len(all_items_in_category) == 0:
index += 1
continue
# end fix
encoding_succeeded = False
tf_example = NoneMetadata
Metadata
Assignees
Labels
No labels