def static_functions_pipeline(input_string): # Creates a pipeline with a list of functions pipe = Pipeline([remove_spaces, remove_special_chars, lowercase]) # Invokes pipeline output = pipe(input_string) print(f"""output ==> {output}""")
def dynamic_functions_pipeline(input_string, pipe_funcs): # Creates a pipeline with a list of functions using using globals() pipe = Pipeline([globals()[func] for func in pipe_funcs]) # Invokes pipeline output = pipe(input_string) print(f"""output ==> {output}""")
def make_cifar_item_tfm(th_img_tfms=None): img_tfms = [cfnp2img_tfm] if th_img_tfms is not None: # assumes th_img_tfms incl ToTensor (cnvt2 PIL.Image -> tensor + div by 255) img_tfms += [th_img_tfms] else: img_tfms += [cfimg_tfm, cfimg2float_tfm] return CifarTupleTransform(x_tfm=Pipeline(img_tfms), y_tfm=i2t_tfm)
def __init__(self, **kwargs): self.tfms = Pipeline(audio_item_tfms(**kwargs))
def after_batch(self:th_data.DataLoader): 'return empty pipeline when fastai learner looks for after_batch' return Pipeline()
def test_pipeline(): pipe = Pipeline([f, g]) assert 2.0 == pipe(3)