{"id":21651109,"url":"https://github.com/tobedefined/libtensorflowforiosswift","last_synced_at":"2025-04-11T20:23:56.196Z","repository":{"id":202147917,"uuid":"97225820","full_name":"ToBeDefined/LibTensorFlowForiOSSwift","owner":"ToBeDefined","description":"Modified from emoji-tf-ios: https://github.com/h4x3rotab/emoji-tf-ios","archived":false,"fork":false,"pushed_at":"2018-08-23T06:05:14.000Z","size":2788,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T16:22:07.889Z","etag":null,"topics":["ios","swift","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Objective-C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ToBeDefined.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-07-14T11:11:29.000Z","updated_at":"2020-04-17T08:51:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d1e122a-c9d0-49b5-9eaf-6344d332b4a6","html_url":"https://github.com/ToBeDefined/LibTensorFlowForiOSSwift","commit_stats":null,"previous_names":["tobedefined/libtensorflowforiosswift"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FLibTensorFlowForiOSSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FLibTensorFlowForiOSSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FLibTensorFlowForiOSSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FLibTensorFlowForiOSSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ToBeDefined","download_url":"https://codeload.github.com/ToBeDefined/LibTensorFlowForiOSSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473793,"owners_count":21109775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","swift","tensorflow"],"created_at":"2024-11-25T07:46:45.671Z","updated_at":"2025-04-11T20:23:56.171Z","avatar_url":"https://github.com/ToBeDefined.png","language":"Objective-C++","readme":"# LibTensorFlowForiOSSwift\n\n[中文文档](./README_CN.md)\n\nThis is a TensorFlow demo that can be run on iOS and use swift develop. It implements a text classifier that can predict emoji from short text (like tweets).\n\n\u003cdiv style=\"text-align: center;\"\u003e\n\u003cimg src=\"./readmeImages/screenshot1.png\" width=\"40%\" height=\"40%\" /\u003e\n\u003cimg src=\"./readmeImages/screenshot2.png\" width=\"40%\" height=\"40%\" /\u003e\n\u003c/div\u003e\n\nModified from [`emoji-tf-ios`](https://github.com/h4x3rotab/emoji-tf-ios); use `emoji_frozen.pb` model from `emoji-tf-ios`.\n\n\n### how to run\n\n- open terminal and go to project root folder\n\n- input `sh run.sh`. \n\nIn the end, will automatically open Xcode \n\nyou can run the project now\n\n### about `run.sh`\n\nit will compile the `TensorFlow for iOS` automatically\n\n### about project setting \n\u003e how to import TensorFlow in ios project\n\n\n- download TensorFlow to the root folder and compile\n\t\u003e befor compile source file, you should change flow TensorFlow Kernel files. (version \u003c= 1.2.1)\n\t\u003e \n\t\u003e in `run.sh`, it will change them automatically\n\t\u003e\n\t\u003e kernel path: `tensorflow/tensorflow/core/kernels`\n\n\t- `cwise_op_add_1.cc`\n\t\t\u003e before:\n\n\t\t```c++\n\t\t...\n\t\t...\n\t\t#include \"tensorflow/core/kernels/cwise_ops_common.h\"\n\n\t\tnamespace tensorflow {\n\t\tREGISTER5(BinaryOp, CPU, \"Add\", functor::add, float, Eigen::half, double, int32,\n\t\t          int64);\n\n\t\t#if TENSORFLOW_USE_SYCL\n\t\t...\n\t\t...\n\t\t```\n\n\t\t\u003e change to:\n\n\t\t```c++\n\t\t...\n\t\t...\n\t\t#include \"tensorflow/core/kernels/cwise_ops_common.h\"\n\n\t\tnamespace tensorflow {\n\t\tREGISTER5(BinaryOp, CPU, \"Add\", functor::add, float, Eigen::half, double, int32,\n\t\t          int64);\n\n\t\t// line 21 insert this code\n\t\t#if defined(__ANDROID_TYPES_SLIM__)\n\t\tREGISTER(BinaryOp, CPU, \"Add\", functor::add, int32);\n\t\t#endif  // __ANDROID_TYPES_SLIM__\n\t\t// insert end\n\n\t\t#if TENSORFLOW_USE_SYCL\n\t\t...\n\t\t...\n\t\t```\n\n\t- `cwise_op_less.cc`\n\t\t\u003e before:\n\n\t\t```c++\n\t\t...\n\t\t...\n\t\t#include \"tensorflow/core/kernels/cwise_ops_common.h\"\n\n\t\tnamespace tensorflow {\n\t\tREGISTER8(BinaryOp, CPU, \"Less\", functor::less, float, Eigen::half, double,\n\t\t          int32, int64, uint8, int8, int16);\n\t\t#if GOOGLE_CUDA\n\t\tREGISTER7(BinaryOp, GPU, \"Less\", functor::less, float, Eigen::half, double,\n\t\t          int64, uint8, int8, int16);\n\t\t...\n\t\t...\n\t\t```\n\n\t\t\u003e change to:\n\n\t\t```c++\n\t\t...\n\t\t...\n\t\t#include \"tensorflow/core/kernels/cwise_ops_common.h\"\n\n\t\tnamespace tensorflow {\n\t\tREGISTER8(BinaryOp, CPU, \"Less\", functor::less, float, Eigen::half, double,\n\t\t          int32, int64, uint8, int8, int16);\n\t\t\n\t\t// line 21 insert this code\n\t\t#if defined(__ANDROID_TYPES_SLIM__)\n\t\tREGISTER(BinaryOp, CPU, \"Less\", functor::less, int32);\n\t\t#endif  // __ANDROID_TYPES_SLIM__\n\t\t// insert end\n\n\t\t#if GOOGLE_CUDA\n\t\tREGISTER7(BinaryOp, GPU, \"Less\", functor::less, float, Eigen::half, double,\n\t\t          int64, uint8, int8, int16);\n\t\t...\n\t\t...\n\t\t```\n\n\n- about `libtensorflow-core.a`\n\t- in `Other Link Flags` add `$(SRCROOT)/tensorflow/tensorflow/contrib/makefile/gen/lib/libtensorflow-core.a`\n\t- in `Library Search Paths` add `$(SRCROOT)/tensorflow/tensorflow/contrib/makefile/gen/lib`\n\n- about `libprotobuf.a \u0026 libprotobuf-lite.a`\n\t- in `Build Phases | Link Binary With Libraries` add `libprotobuf.a \u0026 libprotobuf-lite.a` (path: `tensorflow/tensorflow/contrib/makefile/gen/protobuf_ios/lib/`)\n\t- in `Library Search Paths` add `$(SRCROOT)/tensorflow/tensorflow/contrib/makefile/gen/protobuf_ios/lib` \n\n- in `Header Search Paths` add flows\n\t- `$(SRCROOT)/tensorflow/`\n\t- `$(SRCROOT)/tensorflow/tensorflow/contrib/makefile/downloads/protobuf/src/`\n\t- `$(SRCROOT)/tensorflow/tensorflow/contrib/makefile/downloads`\n\t- `$(SRCROOT)/tensorflow/tensorflow/contrib/makefile/downloads/eigen`\n\t- `$(SRCROOT)/tensorflow/tensorflow/contrib/makefile/gen/proto`\n\n- in `Other Link Flags` add `-force_load`\n\n- in `Build Phases | Link Binary With Libraries` add `Accelerate.framework`\n\n- in `C++ Language Dialect` select `GNU++11` or `GNU++14`\n\n- in `C++ Standard Library` select `libc++`\n\n- `Enable Bitcode` set `No`\n\n- remove any `-all_load` ，use `-ObjC` replace it\n\t\u003e Remove any use of the `-all_load` flag in your project. The protocol buffers libraries (full and lite versions) contain duplicate symbols, and the `-all_load` flag will cause these duplicates to become link errors. If you were using `-all_load` to avoid issues with Objective-C categories in static libraries, you may be able to replace it with the `-ObjC` flag.\n\n- suppress TensorFlow warning：\n\t- in `Other C Flags` \u0026 `Other C++ Flags` add `-isystem $(SRCROOT)/tensorflow`\n\n\n### reference:\n- compile TensorFlow:\n\t\u003e https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/makefile\n\n- change Kernels error:\n\t\u003e https://github.com/h4x3rotab/emoji-tf-ios/blob/master/README.md\n\n- import TensorFlow to iOS:\n\t\u003e https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/ios/README.md\n\n- suppress warning of TensorFlow:\n\t\u003e https://clang.llvm.org/docs/UsersManual.html#id27\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobedefined%2Flibtensorflowforiosswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobedefined%2Flibtensorflowforiosswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobedefined%2Flibtensorflowforiosswift/lists"}