In the workflow, the input images are stored in an Image object, which is specific to the workflows environment.
# Let's create a image_input object, of type Image, from a pil imageimage_input =Image(image="image_name", source="path/../to/../image")# Access the PIL imageimage_input.image# Access the raw bytes of the imageimage_input.to_bytes# Get the width and height of the imageimage_input.widthimage_input.height# Save the image on diskdata =BytesIO()self.image.save(data, format="JPEG", quality=95)# Crop the imageimage_input.get_crop(pred['bbox'])# Crop the image with a certain 10% extension factorimage_input.get_crop(pred['bbox'], extended=0.1)# Resize an imageimage_input.resize(scaling_factor=0.65, threshold=4)# Rotate an imageimage_input.rotate_image(rotation="rotation_180")
Please see with the product team if you need any other image manipulation method. For more custom needs you can also create a new class, that inherits from this one an add any necessary method.