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

[WIP] adding in Security Semantic Segmentation interp script #762

Closed
wants to merge 1 commit into from

Conversation

benhoff
Copy link
Contributor

@benhoff benhoff commented Oct 10, 2019

It should be explicitly noted that this script changes the preprocessing step of images.

This change set scales the images to preserve the aspect ratio (and then padding the other area with blank values). The previous preprocessing did not preserve the aspect ratio, and scaled the image to match the input parameters.

So the code in this change set is:

_, _, h, w = self._input_layout
scale = min(h / image.shape[0], w / image.shape[1])
in_frame = image if image.shape[:-1] == (h, w) else cv2.resize(image, None, fx=scale, fy=scale)

in_frame_size = in_frame.shape[:2]
in_frame = np.pad(in_frame, ((0, h - in_frame_size[0]), (0, w - in_frame_size[1]), (0, 0)), mode='constant', constant_values=0)

The previous code:

_, _, h, w = self._input_layout
in_frame = image if image.shape[:-1] == (h, w) else cv2.resize(image, (w, h))

I'm not sure if that would have an impact on previous models or not.

@benhoff
Copy link
Contributor Author

benhoff commented Oct 10, 2019

I wouldn't recommend merging this, but it can be used to test #759

@benhoff benhoff changed the title adding in Security Semantic Segmentation interp script [WIP] adding in Security Semantic Segmentation interp script Oct 13, 2019
raw_cls_mask = cv2.resize(raw_cls_mask, (w, h)) > 0.5
mask = raw_cls_mask.astype(np.uint8)
# Put an object mask in an image mask.
im_mask = np.zeros((im_h, im_w), dtype=np.uint8)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to self, this looks wrong. im_w and im_h appear flipped. need to investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant