From 779fd46bf73f53cb0c0a006abe8daad13d682a04 Mon Sep 17 00:00:00 2001 From: Yannick Assogba Date: Fri, 9 Aug 2019 16:02:27 -0400 Subject: [PATCH 1/5] Add integration test app. --- tfjs-react-native/.npmignore | 1 + .../integration_rn59/.buckconfig | 6 + .../integration_rn59/.gitattributes | 1 + tfjs-react-native/integration_rn59/.gitignore | 63 + .../integration_rn59/.watchmanconfig | 1 + tfjs-react-native/integration_rn59/App.tsx | 172 + .../integration_rn59/__tests__/App-test.tsx | 14 + .../integration_rn59/android/app/BUCK | 55 + .../integration_rn59/android/app/build.gradle | 154 + .../android/app/build_defs.bzl | 19 + .../android/app/proguard-rules.pro | 17 + .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 36 + .../com/integration_rn59/MainActivity.java | 15 + .../com/integration_rn59/MainApplication.java | 50 + .../generated/BasePackageList.java | 16 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/styles.xml | 8 + .../integration_rn59/android/build.gradle | 33 + .../android/gradle.properties | 18 + .../android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 55616 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + .../integration_rn59/android/gradlew | 188 + .../integration_rn59/android/gradlew.bat | 100 + .../integration_rn59/android/keystores/BUCK | 8 + .../keystores/debug.keystore.properties | 4 + .../integration_rn59/android/settings.gradle | 8 + tfjs-react-native/integration_rn59/app.json | 4 + .../assets/images/catsmall.jpg | Bin 0 -> 4704 bytes .../integration_rn59/assets/model/model.json | 388 + .../integration_rn59/assets/model/weights.bin | Bin 0 -> 2379688 bytes .../integration_rn59/babel.config.js | 3 + .../components/Diagnostic.tsx | 106 + .../components/MobilenetDemo.tsx | 225 + .../integration_rn59/components/Run.tsx | 144 + .../integration_rn59/components/ml.ts | 120 + tfjs-react-native/integration_rn59/index.js | 22 + .../integration_rn59/ios/Podfile | 33 + .../integration_rn59/ios/Podfile.lock | 225 + .../project.pbxproj | 1318 ++++ .../xcschemes/integration_rn59-tvOS.xcscheme | 129 + .../xcschemes/integration_rn59.xcscheme | 129 + .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../ios/integration_rn59/AppDelegate.h | 17 + .../ios/integration_rn59/AppDelegate.m | 56 + .../Base.lproj/LaunchScreen.xib | 42 + .../AppIcon.appiconset/Contents.json | 53 + .../Images.xcassets/Contents.json | 6 + .../ios/integration_rn59/Info.plist | 82 + .../ios/integration_rn59/main.m | 16 + .../ios/integration_rn59Tests/Info.plist | 24 + .../integration_rn59Tests.m | 68 + .../integration_rn59/jest.config.js | 21 + .../integration_rn59/metro.config.js | 40 + .../integration_rn59/package.json | 40 + .../integration_rn59/tsconfig.json | 23 + .../integration_rn59/tslint.json | 65 + tfjs-react-native/integration_rn59/yarn.lock | 6668 +++++++++++++++++ 70 files changed, 11096 insertions(+) create mode 100644 tfjs-react-native/integration_rn59/.buckconfig create mode 100644 tfjs-react-native/integration_rn59/.gitattributes create mode 100644 tfjs-react-native/integration_rn59/.gitignore create mode 100644 tfjs-react-native/integration_rn59/.watchmanconfig create mode 100644 tfjs-react-native/integration_rn59/App.tsx create mode 100644 tfjs-react-native/integration_rn59/__tests__/App-test.tsx create mode 100644 tfjs-react-native/integration_rn59/android/app/BUCK create mode 100644 tfjs-react-native/integration_rn59/android/app/build.gradle create mode 100644 tfjs-react-native/integration_rn59/android/app/build_defs.bzl create mode 100644 tfjs-react-native/integration_rn59/android/app/proguard-rules.pro create mode 100644 tfjs-react-native/integration_rn59/android/app/src/debug/AndroidManifest.xml create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/AndroidManifest.xml create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/java/com/integration_rn59/MainActivity.java create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/java/com/integration_rn59/MainApplication.java create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/java/com/integration_rn59/generated/BasePackageList.java create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/values/strings.xml create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/values/styles.xml create mode 100644 tfjs-react-native/integration_rn59/android/build.gradle create mode 100644 tfjs-react-native/integration_rn59/android/gradle.properties create mode 100644 tfjs-react-native/integration_rn59/android/gradle/wrapper/gradle-wrapper.jar create mode 100644 tfjs-react-native/integration_rn59/android/gradle/wrapper/gradle-wrapper.properties create mode 100755 tfjs-react-native/integration_rn59/android/gradlew create mode 100644 tfjs-react-native/integration_rn59/android/gradlew.bat create mode 100644 tfjs-react-native/integration_rn59/android/keystores/BUCK create mode 100644 tfjs-react-native/integration_rn59/android/keystores/debug.keystore.properties create mode 100644 tfjs-react-native/integration_rn59/android/settings.gradle create mode 100644 tfjs-react-native/integration_rn59/app.json create mode 100644 tfjs-react-native/integration_rn59/assets/images/catsmall.jpg create mode 100644 tfjs-react-native/integration_rn59/assets/model/model.json create mode 100644 tfjs-react-native/integration_rn59/assets/model/weights.bin create mode 100644 tfjs-react-native/integration_rn59/babel.config.js create mode 100644 tfjs-react-native/integration_rn59/components/Diagnostic.tsx create mode 100644 tfjs-react-native/integration_rn59/components/MobilenetDemo.tsx create mode 100644 tfjs-react-native/integration_rn59/components/Run.tsx create mode 100644 tfjs-react-native/integration_rn59/components/ml.ts create mode 100644 tfjs-react-native/integration_rn59/index.js create mode 100644 tfjs-react-native/integration_rn59/ios/Podfile create mode 100644 tfjs-react-native/integration_rn59/ios/Podfile.lock create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcodeproj/project.pbxproj create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcodeproj/xcshareddata/xcschemes/integration_rn59-tvOS.xcscheme create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcodeproj/xcshareddata/xcschemes/integration_rn59.xcscheme create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcworkspace/contents.xcworkspacedata create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/AppDelegate.h create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/AppDelegate.m create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Base.lproj/LaunchScreen.xib create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Images.xcassets/Contents.json create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Info.plist create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/main.m create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59Tests/Info.plist create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59Tests/integration_rn59Tests.m create mode 100644 tfjs-react-native/integration_rn59/jest.config.js create mode 100644 tfjs-react-native/integration_rn59/metro.config.js create mode 100644 tfjs-react-native/integration_rn59/package.json create mode 100644 tfjs-react-native/integration_rn59/tsconfig.json create mode 100644 tfjs-react-native/integration_rn59/tslint.json create mode 100644 tfjs-react-native/integration_rn59/yarn.lock diff --git a/tfjs-react-native/.npmignore b/tfjs-react-native/.npmignore index 6292b5fdb8..3e79386865 100644 --- a/tfjs-react-native/.npmignore +++ b/tfjs-react-native/.npmignore @@ -25,3 +25,4 @@ tsconfig.json tslint.json yarn-error.log yarn.lock +integration_rn59 diff --git a/tfjs-react-native/integration_rn59/.buckconfig b/tfjs-react-native/integration_rn59/.buckconfig new file mode 100644 index 0000000000..934256cb29 --- /dev/null +++ b/tfjs-react-native/integration_rn59/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/tfjs-react-native/integration_rn59/.gitattributes b/tfjs-react-native/integration_rn59/.gitattributes new file mode 100644 index 0000000000..d42ff18354 --- /dev/null +++ b/tfjs-react-native/integration_rn59/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/tfjs-react-native/integration_rn59/.gitignore b/tfjs-react-native/integration_rn59/.gitignore new file mode 100644 index 0000000000..448aabe7da --- /dev/null +++ b/tfjs-react-native/integration_rn59/.gitignore @@ -0,0 +1,63 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# Visual Studio Code +# +.vscode/ + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots + +# Bundle artifact +*.jsbundle + +# CocoaPods +/ios/Pods/ \ No newline at end of file diff --git a/tfjs-react-native/integration_rn59/.watchmanconfig b/tfjs-react-native/integration_rn59/.watchmanconfig new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/tfjs-react-native/integration_rn59/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tfjs-react-native/integration_rn59/App.tsx b/tfjs-react-native/integration_rn59/App.tsx new file mode 100644 index 0000000000..c83c39ef6d --- /dev/null +++ b/tfjs-react-native/integration_rn59/App.tsx @@ -0,0 +1,172 @@ +/** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + +import React, { Fragment } from 'react'; +import { + Button, + SafeAreaView, + StyleSheet, + ScrollView, + View, + Text, + StatusBar, +} from 'react-native'; + +import * as tf from '@tensorflow/tfjs'; +import '@tensorflow/tfjs-react-native'; + +import Diagnostic from './components/Diagnostic'; +import MobilenetDemo from './components/MobilenetDemo'; + +export type Screen = 'main' | 'diag' | 'demo'; + +interface AppState { + isTfReady: boolean; + currentScreen: Screen; +} + +export default class App extends React.Component { + constructor(props: any) { + super(props); + this.state = { + isTfReady: false, + currentScreen: 'main' + } + + this.showDiagnosticScreen = this.showDiagnosticScreen.bind(this); + this.showDemoScreen = this.showDemoScreen.bind(this); + this.showMainScreen = this.showMainScreen.bind(this); + } + + async componentDidMount() { + await tf.setBackend('rn-webgl'); + await tf.ready(); + this.setState({ + isTfReady: true, + }); + } + + showDiagnosticScreen() { + this.setState({ currentScreen: 'diag' }); + } + + showDemoScreen() { + this.setState({ currentScreen: 'demo' }); + } + + showMainScreen() { + this.setState({ currentScreen: 'main' }); + } + + renderMainScreen() { + return + + Diagnostic +