Step 8: Parallel Computing
Running computations and processing data in parallel.
How to Accelerate Deep Lake Workflows with Parallel Computing
Defining the parallel computing function
import deeplake
from PIL import Image
import numpy as np
import os
@deeplake.compute
def file_to_deeplake(file_name, sample_out, class_names):
## First two arguments are always default arguments containing:
# 1st argument is an element of the input iterable (list, dataset, array,...)
# 2nd argument is a dataset sample
# Other arguments are optional
# Find the label number corresponding to the file
label_text = os.path.basename(os.path.dirname(file_name))
label_num = class_names.index(label_text)
# Append the label and image to the output sample
sample_out.append({"labels": np.uint32(label_num),
"images": deeplake.read(file_name)})
return sample_outExecuting the parallel computation
Was this helpful?