<jupyter_start><jupyter_text>Test of Image Processing Workflows by Tobias<jupyter_code>from fairworkflows import is_fairworkflow, is_fairstep, FairStep, FairWorkflow
@is_fairstep(label='Rotating an image represented as a string by 90 degrees')
def rotate_image(img):
    return img.transpose(Image.ROTATE_90)
@is_fairstep(label='Inverting the colors of an image')
def invert_colors(img):
    from PIL import Image, ImageOps
    return ImageOps.invert(img)
@is_fairstep(label='Add blur to image')
def blur(img):
    from PIL import ImageFilter
    return img.filter(ImageFilter.BLUR)
@is_fairstep(label='Overlay two images')
def overlay(bg_img, fg_img):
    img = bg_img.copy()
    fg_img = fg_img.convert("RGBA")
    img.paste(fg_img, (0, 0), fg_img)
    return img
@is_fairstep(label='Convert white to transparency')
def white_to_transparency(img):
    from PIL import Image
    img = img.convert("RGBA")
    data = img.getdata()
    new_data = []
    for item in data:
        if item[0] == 255 and item[1] == 255 and item[2] == 255:
            new_data.append((255, 255, 255, 0))
        else:
            new_data.append(item)
    img.putdata(new_data)
    return img
@is_fairworkflow(label='My Workflow')
def my_workflow(img1, img2):
    return overlay(blur(img1), white_to_transparency(img2))
from PIL import Image
input1 = Image.open("img/city.png")
input1
input2 = Image.open("img/rose.png")
input2
fw = FairWorkflow.from_function(my_workflow)
result, prov = fw.execute(input1, input2)
result
fw.display()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11463730569948187, 'fraction_numerical': 0.02461139896373057, 'mean_word_length': 4.5978260869565215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '588014', 'license': 'Apache-2.0', 'n_tokens_mistral': 578, 'n_tokens_neox': 544, 'n_words': 133, 'path': 'examples/test_image_processing_wf_tobias.ipynb', 'repo_name': 'fair-workflows/fairworkflows', 'size': '1544'}