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 recreating cache when using image files (#1078) #1114

Merged
merged 2 commits into from
Mar 10, 2021
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
25 changes: 12 additions & 13 deletions ludwig/features/image_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,15 @@ def add_feature_data(
preprocessing_parameters,
backend
):
set_default_value(
feature[PREPROCESSING],
'in_memory',
preprocessing_parameters['in_memory']
)
set_default_value(
feature[PREPROCESSING],
'num_processes',
preprocessing_parameters['num_processes']
)
in_memory = preprocessing_parameters['in_memory']
if PREPROCESSING in feature and 'in_memory' in feature[PREPROCESSING]:
in_memory = feature[PREPROCESSING]['in_memory']

num_processes = preprocessing_parameters['num_processes']
if PREPROCESSING in feature and 'num_processes' in feature[
PREPROCESSING]:
num_processes = feature[PREPROCESSING]['num_processes']

src_path = None
if hasattr(input_df, 'src'):
src_path = os.path.dirname(os.path.abspath(input_df.src))
Expand Down Expand Up @@ -284,17 +283,17 @@ def add_feature_data(
user_specified_num_channels=user_specified_num_channels
)

if feature[PREPROCESSING]['in_memory']:
if in_memory:
# Number of processes to run in parallel for preprocessing
num_processes = feature[PREPROCESSING]['num_processes']
metadata[feature[NAME]][PREPROCESSING][
'num_processes'] = num_processes
metadata[feature[NAME]]['reshape'] = (height, width, num_channels)

# Split the dataset into pools only if we have an explicit request to use
# multiple processes. In case we have multiple input images use the
# standard code anyway.
if backend.supports_multiprocessing and (num_processes > 1 or num_images > 1):
if backend.supports_multiprocessing and (
num_processes > 1 or num_images > 1):
all_file_paths = [get_abs_path(src_path, file_path)
for file_path in input_df[feature[NAME]]]

Expand Down