mrousavy/react-native-fast-tflite — công cụ AI — đang có 1.2k sao GitHub trong nhóm AI Tools. 🧬 High-performance TensorFlow Lite library for React Native with GPU acceleration
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
This allows you to drop .tflite files into your app and swap them out at runtime without rebuilding. 🔥
(Optional) To enable GPU delegates, see Using GPU Delegates below.
Run your app (yarn android / npx pod-install && yarn ios)
Usage
Find a TensorFlow Lite (.tflite) model. There are thousands of public models on tfhub.dev.
Drag your model into your app's asset folder (e.g. src/assets/my-model.tflite)
Load the Model:
// Option A: Standalone Function
const model = await loadTensorflowModel(require('assets/my-model.tflite'), [])
// Option B: Hook in a Function Component
const plugin = useTensorflowModel(require('assets/my-model.tflite'), [])
Models can be loaded from the React Native bundle via require(..), or any URI/URL (http://.. or file://..):
// Asset from React Native Bundle
loadTensorflowModel(require('assets/my-model.tflite'), [])
// File on the local filesystem
loadTensorflowModel({ url: 'file:///var/mobile/.../my-model.tflite' }, [])
// Remote URL
loadTensorflowModel(
{ url: 'https://tfhub.dev/google/lite-model/object_detection_v1.tflite' },
[]
)
Loading a Model is asynchronous since buffers need to be allocated. Make sure to handle errors when loading.
Input and Output data
TensorFlow uses tensors as input and output. Since TensorFlow Lite is optimized for fixed-size byte buffers, you are responsible for interpreting the raw data yourself.
Input and output values are passed as ArrayBuffer. To inspect tensor shapes, open your model in Netron.
For example, the object_detection_mobile_object_localizer_v1_1_default_1.tflite model on tfhub.dev has 1 input tensor and 4 output tensors:
In the description on tfhub.dev we can find the description of all tensors:
From that we know we need a 192 x 192 input image with 3 bytes per pixel (RGB).
Usage (VisionCamera)
If you're using this model with a VisionCamera Frame Processor, you need to convert the Frame to the model's expected input size.
Use vision-camera-resizer to do the conversion:
import { Camera, useFrameOutput } from 'react-native-vision-camera'
import { useResizer } from 'react-native-vision-camera-resizer'
import { useTensorflowModel } from 'react-native-fast-tflite'
const objectDetection = useTensorflowModel(require('object_detection.tflite'), [])
// 1. Create a resizer that converts Frames to 192x192x3 (RGB, uint8)
const { resizer } = useResizer({
width: 192,
height: 192,
channelOrder: 'rgb',
dataType: 'uint8',
})
const frameOutput = useFrameOutput({
pixelFormat: 'yuv',
onFrame(frame) {
'worklet'
if (objectDetection.state !== 'loaded' || resizer == null) {
frame.dispose()
return
}
// 2. Resize the Frame to the model's input size
const resized = resizer.resize(frame)
frame.dispose()
const data = new Uint8Array(resized.getPixelBuffer())
resized.dispose()
// 3. Extract the exact slice of the underlying ArrayBuffer
const inputBuffer = data.buffer.slice(
data.byteOffset,
data.byteOffset + data.byteLength
)
// 4. Run model with given input buffer synchronously
const outputs = objectDetection.model.runSync([inputBuffer])
// 5. Interpret outputs accordingly
const detection_boxes = new Float32Array(outputs[0]!)
const detection_classes = new Float32Array(outputs[1]!)
const detection_scores = new Float32Array(outputs[2]!)
const num_detections = new Float32Array(outputs[3]!)
console.log(`Detected ${num_detections[0]} objects!`)
},
})
return <Camera device="back" isActive={true} outputs={[frameOutput]} {...otherProps} />
[!NOTE]
Unlike v4, VisionCamera v5 no longer requires boxing the model with NitroModules.box(). Since v5 is built on Nitro Modules and uses react-native-worklets, worklets can access HybridObjects like the TFLite model directly.
Using GPU Delegates
GPU Delegates offer faster, GPU-accelerated computation. There are multiple delegates available:
CoreML (iOS)
Expo
Use the config plugin in your expo config (app.json, app.config.json or app.config.js):
const model = await loadTensorflowModel(
require('assets/my-model.tflite'),
['android-gpu']
)
// or
const model = await loadTensorflowModel(
require('assets/my-model.tflite'),
['nnapi']
)
[!WARNING]
NNAPI is deprecated on Android 15. GPU delegate is preferred.
[!NOTE]
Android does not officially support OpenCL, but most GPU vendors do.
Community Discord
Join the Margelo Community Discord to chat about react-native-fast-tflite or other Margelo libraries.
Adopting at scale
This library is provided as is, I work on it in my free time.
If you're integrating react-native-fast-tflite in a production app, consider funding this project and contact me to receive premium enterprise support, help with issues, prioritize bugfixes, request features, and more.
Contributing
Clone the repo
Make sure you have installed Xcode CLI tools such as gcc, cmake and python/python3. See the TensorFlow documentation on what you need exactly.
Run yarn bootstrap and select y on all iOS and Android related questions.
Open the example app and start developing
iOS: example/ios/TfliteExample.xcworkspace
Android: example/android
See the contributing guide to learn how to contribute to the repository and the development workflow.
Đọc thêm về mrousavy/react-native-fast-tflite ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/mrousavy/react-native-fast-tflite là nguồn chính thức.
mrousavy/react-native-fast-tflite có bao nhiêu sao?
mrousavy/react-native-fast-tflite có 1.2k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/mrousavy/react-native-fast-tflite. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
mrousavy/react-native-fast-tflite có phải mã nguồn mở không?
Có — mrousavy/react-native-fast-tflite phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/mrousavy/react-native-fast-tflite.
mrousavy/react-native-fast-tflite còn đang phát triển không?
Commit gần nhất trên mrousavy/react-native-fast-tflite là 23 ngày trước (theo timestamp GitHub). Repo có 90 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
mrousavy/react-native-fast-tflite là gì?
mrousavy/react-native-fast-tflite (mrousavy/react-native-fast-tflite) là dự án TypeScript trên GitHub. Theo mô tả gốc: 🧬 High-performance TensorFlow Lite library for React Native with GPU acceleration
mrousavy/react-native-fast-tflite so với các dự án AI Tools khác thế nào?
mrousavy/react-native-fast-tflite được TopGit xếp vào nhóm AI Tools, với 1.2k sao GitHub và viết bằng TypeScript. Xem trang chủ đề AI Tools trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc react-native-fast-tflite có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về react-native-fast-tflite.