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

Image preprocessing block (flip, rotate, resize) #683

Merged
merged 10 commits into from
Sep 26, 2024

Conversation

EmilyGavrilenko
Copy link
Contributor

Description

Add a block that supports resizing, flipping, and rotating

Type of change

  • New feature (non-breaking change which adds functionality)

How has this change been tested, please provide a testcase or example of how you tested the change?

UI editor & with tests

Any specific deployment considerations

n/a

Docs

n/a

}
},
)
flip_type: Union[str, WorkflowParameterSelector(kind=[STRING_KIND]), Literal["vertical", "horizontal", "both"]] = Field( # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove str here

np_image: np.ndarray, width: Optional[int], height: Optional[int]
) -> np.ndarray:
if width is None and height is None:
return np_image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return np_image
return np_image.copy()

We should return copy of the image to be consistent with remainder of this method where copy is returned

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


def apply_rotate_image(np_image: np.ndarray, rotation_degrees: Optional[int]):
if rotation_degrees is None or rotation_degrees == 0:
return np_image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return np_image
return np_image.copy()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

def apply_rotate_image(np_image: np.ndarray, rotation_degrees: Optional[int]):
if rotation_degrees is None or rotation_degrees == 0:
return np_image
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already returned, else is not required (can save one indent level)

@PawelPeczek-Roboflow PawelPeczek-Roboflow merged commit 6d9ad3f into main Sep 26, 2024
57 checks passed
@PawelPeczek-Roboflow PawelPeczek-Roboflow deleted the image_preprocessing_block branch September 26, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants