Skip to content

Moved pre-processing step to Core ML class - #25

Merged
ellbosch merged 1 commit into
masterfrom
u/elbosc/63/model-preprocessing
Mar 30, 2021
Merged

ellbosch merged 1 commit into
masterfrom
u/elbosc/63/model-preprocessing

Conversation

@ellbosch

Copy link
Copy Markdown
Contributor

This PR offloads image preprocessing to the Vision class in Core ML. This should make us better prepared for possible changes to expected image input size in the future.

Because:

  • The Vision class automatically adjusts preprocessing based on the expected image size from the loaded Core ML model. Our prior implementation was naive about the expected format.

This commit:

  • Assigns .centerCrop to the VNCoreMLRequest object.
  • Removes now unused code for squaring the image.
  • Re-orders the LobeML file in the project menu, for kicks.

Tagging #22 because there's a chance that bug gets fixed with this change.

@ellbosch
ellbosch requested a review from mbeissinger March 25, 2021 02:47
onComplete(request)
})

/// Set center cropping for the expected image size.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mbeissinger comment code here for your review.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yep looks good

.compactMap { $0 } // remove non-nill values
.receive(on: DispatchQueue.global(qos: .userInitiated))
.sink(receiveValue: { [weak self] image in
guard let squaredImage = image.squared() else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That little bugger 😛

onComplete(request)
})

/// Set center cropping for the expected image size.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yep looks good

@ellbosch
ellbosch merged commit 807f4fa into master Mar 30, 2021
@ellbosch
ellbosch deleted the u/elbosc/63/model-preprocessing branch March 30, 2021 23:23
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.

3 participants