Updates Swift and ObjC READMEs and quickstart.
PiperOrigin-RevId: 247513844
This commit is contained in:
parent
3eb4a44f05
commit
6f980870f3
@ -5,7 +5,7 @@ solution for Objective-C developers. It enables low-latency inference of
|
||||
on-device machine learning models with a small binary size and fast performance
|
||||
supporting hardware acceleration.
|
||||
|
||||
## Getting Started
|
||||
## Build TensorFlow with iOS support
|
||||
|
||||
To build the Objective-C TensorFlow Lite library on Apple platforms,
|
||||
[install from source](https://www.tensorflow.org/install/source#setup_for_linux_and_macos)
|
||||
@ -19,9 +19,34 @@ python configure.py
|
||||
|
||||
Follow the prompts and when asked to build TensorFlow with iOS support, enter `y`.
|
||||
|
||||
### Bazel
|
||||
### CocoaPods developers
|
||||
|
||||
In your `BUILD` file, add the `TensorFlowLite` dependency:
|
||||
Add the TensorFlow Lite pod to your `Podfile`:
|
||||
|
||||
```ruby
|
||||
pod 'TensorFlowLiteObjC'
|
||||
```
|
||||
|
||||
Then, run `pod install`.
|
||||
|
||||
In your Objective-C files, import the umbrella header:
|
||||
|
||||
```objectivec
|
||||
#import "TFLTensorFlowLite.h"
|
||||
```
|
||||
|
||||
Or, the module if you set `CLANG_ENABLE_MODULES = YES` in your Xcode project:
|
||||
|
||||
```objectivec
|
||||
@import TFLTensorFlowLite;
|
||||
```
|
||||
|
||||
Note: To import the TensorFlow Lite module in your Objective-C files, you must
|
||||
also include `use_frameworks!` in your `Podfile`.
|
||||
|
||||
### Bazel developers
|
||||
|
||||
In your `BUILD` file, add the `TensorFlowLite` dependency to your target:
|
||||
|
||||
```python
|
||||
objc_library(
|
||||
@ -37,6 +62,12 @@ In your Objective-C files, import the umbrella header:
|
||||
#import "TFLTensorFlowLite.h"
|
||||
```
|
||||
|
||||
Or, the module if you set `CLANG_ENABLE_MODULES = YES` in your Xcode project:
|
||||
|
||||
```objectivec
|
||||
@import TFLTensorFlowLite;
|
||||
```
|
||||
|
||||
Build the `TensorFlowLite` Objective-C library target:
|
||||
|
||||
```shell
|
||||
@ -49,36 +80,14 @@ Build the `TensorFlowLiteTests` target:
|
||||
bazel test tensorflow/lite/experimental/objc:TensorFlowLiteTests
|
||||
```
|
||||
|
||||
### Tulsi
|
||||
#### Generate the Xcode project using Tulsi
|
||||
|
||||
Open the `TensorFlowLite.tulsiproj` using the
|
||||
[TulsiApp](https://github.com/bazelbuild/tulsi) or by running the
|
||||
Open the `//tensorflow/lite/experimental/objc/TensorFlowLite.tulsiproj` using
|
||||
the [TulsiApp](https://github.com/bazelbuild/tulsi)
|
||||
or by running the
|
||||
[`generate_xcodeproj.sh`](https://github.com/bazelbuild/tulsi/blob/master/src/tools/generate_xcodeproj.sh)
|
||||
script from the root `tensorflow` directory:
|
||||
|
||||
```shell
|
||||
generate_xcodeproj.sh --genconfig tensorflow/lite/experimental/objc/TensorFlowLite.tulsiproj:TensorFlowLite --outputfolder ~/path/to/generated/TensorFlowLite.xcodeproj
|
||||
```
|
||||
|
||||
### CocoaPods
|
||||
|
||||
Add the following to your `Podfile`:
|
||||
|
||||
```ruby
|
||||
pod 'TensorFlowLiteObjC'
|
||||
```
|
||||
|
||||
Then, run `pod install`.
|
||||
|
||||
In your Objective-C files, import the umbrella header:
|
||||
|
||||
```objectivec
|
||||
#import "TFLTensorFlowLite.h"
|
||||
```
|
||||
|
||||
Or, the module if `CLANG_ENABLE_MODULES = YES` and `use_frameworks!` is
|
||||
specified in your `Podfile`:
|
||||
|
||||
```objectivec
|
||||
@import TFLTensorFlowLite;
|
||||
```
|
||||
|
@ -1,5 +1,3 @@
|
||||
# Run `pod lib lint TensorFlowLiteObjC.podspec` to ensure this is a valid spec.
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'TensorFlowLiteObjC'
|
||||
s.version = '0.2.0'
|
||||
|
@ -5,7 +5,7 @@ solution for Swift developers. It enables low-latency inference of on-device
|
||||
machine learning models with a small binary size and fast performance supporting
|
||||
hardware acceleration.
|
||||
|
||||
## Getting Started
|
||||
## Build TensorFlow with iOS support
|
||||
|
||||
To build the Swift TensorFlow Lite library on Apple platforms,
|
||||
[install from source](https://www.tensorflow.org/install/source#setup_for_linux_and_macos)
|
||||
@ -19,9 +19,25 @@ python configure.py
|
||||
|
||||
Follow the prompts and when asked to build TensorFlow with iOS support, enter `y`.
|
||||
|
||||
### Bazel
|
||||
### CocoaPods developers
|
||||
|
||||
In your `BUILD` file, add the `TensorFlowLite` dependency:
|
||||
Add the TensorFlow Lite pod to your `Podfile`:
|
||||
|
||||
```ruby
|
||||
pod 'TensorFlowLiteSwift'
|
||||
```
|
||||
|
||||
Then, run `pod install`.
|
||||
|
||||
In your Swift files, import the module:
|
||||
|
||||
```swift
|
||||
import TensorFlowLite
|
||||
```
|
||||
|
||||
### Bazel developers
|
||||
|
||||
In your `BUILD` file, add the `TensorFlowLite` dependency to your target:
|
||||
|
||||
```python
|
||||
swift_library(
|
||||
@ -49,12 +65,12 @@ Build the `TensorFlowLiteTests` target:
|
||||
bazel test tensorflow/lite/experimental/swift:TensorFlowLiteTests --swiftcopt=-enable-testing
|
||||
```
|
||||
|
||||
Note that `--swiftcopt=-enable-testing` is required for optimized builds (`-c opt`).
|
||||
Note: `--swiftcopt=-enable-testing` is required for optimized builds (`-c opt`).
|
||||
|
||||
### Tulsi
|
||||
#### Generate the Xcode project using Tulsi
|
||||
|
||||
Open the `TensorFlowLite.tulsiproj` using the
|
||||
[TulsiApp](https://github.com/bazelbuild/tulsi)
|
||||
Open the `//tensorflow/lite/experimental/swift/TensorFlowLite.tulsiproj` using
|
||||
the [TulsiApp](https://github.com/bazelbuild/tulsi)
|
||||
or by running the
|
||||
[`generate_xcodeproj.sh`](https://github.com/bazelbuild/tulsi/blob/master/src/tools/generate_xcodeproj.sh)
|
||||
script from the root `tensorflow` directory:
|
||||
@ -62,19 +78,3 @@ script from the root `tensorflow` directory:
|
||||
```shell
|
||||
generate_xcodeproj.sh --genconfig tensorflow/lite/experimental/swift/TensorFlowLite.tulsiproj:TensorFlowLite --outputfolder ~/path/to/generated/TensorFlowLite.xcodeproj
|
||||
```
|
||||
|
||||
### CocoaPods
|
||||
|
||||
Add the following to your `Podfile`:
|
||||
|
||||
```ruby
|
||||
pod 'TensorFlowLiteSwift'
|
||||
```
|
||||
|
||||
Then, run `pod install`.
|
||||
|
||||
In your Swift files, import the module:
|
||||
|
||||
```swift
|
||||
import TensorFlowLite
|
||||
```
|
||||
|
@ -1,5 +1,3 @@
|
||||
# Run `pod lib lint TensorFlowLiteSwift.podspec` to ensure this is a valid spec.
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'TensorFlowLiteSwift'
|
||||
s.version = '0.2.0'
|
||||
|
@ -30,12 +30,12 @@ To get started quickly writing your own iOS code, we recommend using our
|
||||
[Swift image classification example](https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/ios)
|
||||
as a starting point.
|
||||
|
||||
The sections below walk you through the steps for adding TensorFlow Lite Swift
|
||||
or Objective-C to your project:
|
||||
The sections below demonstrate how to add TensorFlow Lite Swift or Objective-C
|
||||
to your project:
|
||||
|
||||
### CocoaPods developers
|
||||
|
||||
In your `Podfile`, add the TensorFlow Lite pod. Then, run `pod install`:
|
||||
In your `Podfile`, add the TensorFlow Lite pod. Then, run `pod install`.
|
||||
|
||||
#### Swift
|
||||
|
||||
@ -52,7 +52,7 @@ pod 'TensorFlowLiteObjC'
|
||||
|
||||
### Bazel developers
|
||||
|
||||
In your `BUILD` file, add the `TensorFlowLite` dependency.
|
||||
In your `BUILD` file, add the `TensorFlowLite` dependency to your target.
|
||||
|
||||
#### Swift
|
||||
|
||||
@ -74,7 +74,7 @@ objc_library(
|
||||
)
|
||||
```
|
||||
|
||||
### Importing the library
|
||||
### Import the library
|
||||
|
||||
For Swift files, import the TensorFlow Lite module:
|
||||
|
||||
@ -88,12 +88,11 @@ For Objective-C files, import the umbrella header:
|
||||
#import "TFLTensorFlowLite.h"
|
||||
```
|
||||
|
||||
Or, the TensorFlow Lite module:
|
||||
Or, the module if you set `CLANG_ENABLE_MODULES = YES` in your Xcode project:
|
||||
|
||||
```objectivec
|
||||
@import TFLTensorFlowLite;
|
||||
```
|
||||
|
||||
Note: If importing the Objective-C TensorFlow Lite module, `CLANG_ENABLE_MODULES`
|
||||
must be set to `YES`. Additionally, for CocoaPods developers, `use_frameworks!`
|
||||
must be specified in your `Podfile`.
|
||||
Note: For CocoaPods developers who want to import the Objective-C TensorFlow
|
||||
Lite module, you must also include `use_frameworks!` in your `Podfile`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user