{"id":13659721,"url":"https://github.com/icerockdev/moko-tensorflow","last_synced_at":"2026-01-04T02:57:32.187Z","repository":{"id":48777828,"uuid":"265134095","full_name":"icerockdev/moko-tensorflow","owner":"icerockdev","description":"Tensorflow Lite bindings for mobile (android \u0026 ios) Kotlin Multiplatform development","archived":false,"fork":false,"pushed_at":"2023-09-05T14:44:42.000Z","size":524,"stargazers_count":28,"open_issues_count":3,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-10T13:36:46.677Z","etag":null,"topics":["android","ios","kotlin","kotlin-multiplatform","kotlin-native","moko","tensorflow"],"latest_commit_sha":null,"homepage":"https://moko.icerock.dev","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icerockdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-19T03:33:54.000Z","updated_at":"2024-11-09T13:05:02.000Z","dependencies_parsed_at":"2024-08-02T05:18:07.924Z","dependency_job_id":null,"html_url":"https://github.com/icerockdev/moko-tensorflow","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icerockdev%2Fmoko-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icerockdev","download_url":"https://codeload.github.com/icerockdev/moko-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250654130,"owners_count":21465816,"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":["android","ios","kotlin","kotlin-multiplatform","kotlin-native","moko","tensorflow"],"created_at":"2024-08-02T05:01:11.595Z","updated_at":"2026-01-04T02:57:32.145Z","avatar_url":"https://github.com/icerockdev.png","language":"Kotlin","readme":"![moko-tensorflow](https://user-images.githubusercontent.com/5010169/128705344-f858c4b9-db37-49f7-bb1f-9919f29cb78b.png)  \n[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://img.shields.io/maven-central/v/dev.icerock.moko/tensorflow) ](https://repo1.maven.org/maven2/dev/icerock/moko/tensorflow) ![kotlin-version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=dev.icerock.moko\u0026name=tensorflow)\n\n# Mobile Kotlin TensorFlow\nThis is a Kotlin MultiPlatform library that provides access to [TensorFlow-Lite](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite) functionality from\ncommon source set.\n\n## Table of Contents\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Samples](#samples)\n- [Set Up Locally](#set-up-locally)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n## Requirements\n- Gradle version 6.8+\n- Android API 19+\n- iOS version 11.0+\n\n## Installation\n\nroot build.gradle  \n```groovy\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\n\nproject build.gradle\n```groovy\ndependencies {\n    commonMainApi(\"dev.icerock.moko:tensorflow:0.2.1\")\n}\n\ncocoaPods {\n    podsProject = file(\"../ios-app/Pods/Pods.xcodeproj\") // here should be path to Pods xcode project\n\n    pod(\"TensorFlowLiteObjC\", module = \"TFLTensorFlowLite\", onlyLink = true)\n}\n\nkotlin {\n    targets\n        .filterIsInstance\u003corg.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget\u003e()\n        .flatMap { it.binaries }\n        .filterIsInstance\u003corg.jetbrains.kotlin.gradle.plugin.mpp.Framework\u003e()\n        .forEach { framework -\u003e\n            framework.linkerOpts(\n                project.file(\"../ios-app/Pods/TensorFlowLiteC/Frameworks\").path.let { \"-F$it\" },\n                \"-framework\",\n                \"TensorFlowLiteC\"\n            )\n        }\n}\n```\n\nPodfile\n```ruby\npod 'TensorFlowLiteObjC', '~\u003e 2.2.0'\n```\n\n## Usage\n\nFirst place the model file in the multi-platform resource folder `commonMain/resources/MR/files`.\n\n`common`:\n```kotlin\nclass Classifier(private val interpreter: Interpreter) {\n\n    fun classify(inputData: Any) {\n        val inputShape = interpreter.getInputTensor(0).shape\n        val inputSize = inputShape[1]\n\n        val result = Array(1) { FloatArray(OUTPUT_CLASSES_COUNT) }\n        interpreter.run(listOf(inputData), mapOf(Pair(0, result)))\n    }\n}\n```\n\nGetting shared model file (in `common`):\n\n```kotlin\nobject ResHolder {\n    fun getModelFile(): FileResource {\n        return MR.files.mymodel\n    }\n}\n```\n\n`android`:\n```kotlin\nclass MainActivity : AppCompatActivity() {\n    private lateinit var interpreter: Interpreter\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        interpreter = Interpreter(ResHolder.getModelFile(), InterpreterOptions(2, useNNAPI = true), this)\n        val classifier = Classifier(interpreter)\n        classifier.classify(data)\n    }\n\n    override fun onDestroy() {\n        super.onDestroy()\n        interpreter.close()\n    }\n}\n```\n\n`iOS`:\n```swift\nclass ViewController: UIViewController {\n    private var interpreter: TensorflowInterpreter?\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        let options: TensorflowInterpreterOptions = TensorflowInterpreterOptions(numThreads: 2)\n        let modelFileRes: ResourcesFileResource = ResHolder().getModelFile()\n        \n        interpreter = TensorflowInterpreter(fileResource: modelFileRes, options: options)\n        let classifier = Classifier(interpreter: interpreter!)\n\n        classifier.classify(data)\n    }\n\n    deinit {\n        interpreter?.close()\n    }\n}\n```\n\n## Samples\nPlease see more examples in the [sample directory](sample).\n\n## Set Up Locally \n- The [tensorflow directory](tensorflow) contains the `tensorflow` library;\n- The [sample directory](sample) contains sample apps for Android and iOS; plus the mpp-library connected to the apps;\n- For local testing a use the `./publishToMavenLocal.sh` script - so that sample apps use the locally published version.\n\n## Contributing\nAll development (both new features and bug fixes) is performed in the `develop` branch. This way `master` always contains the sources of the most recently released version. Please send PRs with bug fixes to the `develop` branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in `master`.\n\nThe `develop` branch is pushed to `master` on release.\n\nFor more details on contributing please see the [contributing guide](CONTRIBUTING.md).\n\n## License\n        \n    Copyright 2020 IceRock MAG Inc.\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n       http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":[],"categories":["Libraries"],"sub_categories":["🧩 Service SDK"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficerockdev%2Fmoko-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficerockdev%2Fmoko-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficerockdev%2Fmoko-tensorflow/lists"}