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

Replace TensorFlow image loading with stb_image #429

Merged
merged 14 commits into from
Apr 8, 2020

Conversation

BradLarson
Copy link
Contributor

@BradLarson BradLarson commented Mar 30, 2020

As part of our efforts to reduce our dependencies on TensorFlow libraries, this replaces the image saving and loading routines with ones provided by the stb_image C single headers. This is inspired by t-ae's cross-platform image loading library Swim. We're evaluating various image processing options, so this isn't guaranteed to be a permanent implementation, but it works well for our use cases right now.

The interface to the Image type has intentionally been left the same as it was before, in order to restrict all code changes to just Image.swift. I'll follow on with some modifications to the API in a later PR.

This is the last change needed to close out issue #225.

@brettkoonce
Copy link
Contributor

i think this is a good pragmatic way to get away from raw ops

@BradLarson BradLarson changed the title Replace TensorFlow image loading with Swim Replace TensorFlow image loading with stb_image Apr 6, 2020
Support/CMakeLists.txt Outdated Show resolved Hide resolved
Support/CMakeLists.txt Outdated Show resolved Hide resolved
Support/CMakeLists.txt Outdated Show resolved Hide resolved
Support/CMakeLists.txt Outdated Show resolved Hide resolved
Support/CMakeLists.txt Outdated Show resolved Hide resolved
Support/CMakeLists.txt Outdated Show resolved Hide resolved
Support/Image.swift Outdated Show resolved Hide resolved
Support/StbImage/CMakeLists.txt Outdated Show resolved Hide resolved
Support/StbImage/module.modulemap Outdated Show resolved Hide resolved
Support/StbImage/module.modulemap Outdated Show resolved Hide resolved
@ematejska
Copy link
Contributor

Looks good.

@ematejska ematejska merged commit cdf7f12 into tensorflow:master Apr 8, 2020
@BradLarson BradLarson deleted the ImageTFRemoval branch April 8, 2020 17:31
import TensorFlow

final class ImageTests: XCTestCase {
let resourceBaseLocation = URL(fileURLWithPath: #file).deletingLastPathComponent()
Copy link
Contributor

Choose a reason for hiding this comment

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

will #file break in the forthcoming changes to not be full paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, it probably will. It looks like we have access to #filePath in our toolchain (I wasn't sure if we did), so I'll switch this and our other uses of #file to #filePath in anticipation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR #449 is my quick fix to address this.

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.

6 participants