Releases: infinitered/react-native-mlkit
@infinitered/react-native-mlkit-document-scanner@3.0.0
@infinitered/react-native-mlkit-core@3.0.0
Major Changes
-
83b7e6e: Standardize API patterns and coordinate structures across ML Kit modules
- Separates model operations into three hooks with simpler APIs
- loading the models, (
useObjectDetectionModels,useImageLabelingModels) - initializing the provider (
useObjectDetectionProvider,useImageLabelingProvider) - accessing models for inference, (
useObjectDetector,useImageLabeling)
- loading the models, (
- Implements consistent naming patterns to make the APIs more legible
- Removes "RNMLKit" prefix from non-native types
- Use specific names for hooks (
useImageLabelingModelsinstead ofuseModels) - Model configs are now
Configs, instead ofAssetRecords
- Moves base types into the
corepackage to ensure consistency - Fixes an issue with bounding box placement on portrait / rotated images on iOS
- Improves error handling and state management
- Updates documentation to match the new API
Breaking Changes
Image Labeling
- Renamed
useModelstouseImageLabelingModelsfor clarity - Renamed
useImageLabelertouseImageLabeling - Introduced new
useImageLabelingProviderhook for cleaner context management - Added type-safe configurations with
ImageLabelingConfig - Renamed model context provider from
ObjectDetectionModelContextProvidertoImageLabelingModelProvider
Here's how to update your app:
Fetching the provider
- const MODELS: AssetRecord = { + const MODELS: ImageLabelingConfig = { nsfwDetector: { model: require("./assets/models/nsfw-detector.tflite"), options: { maxResultCount: 5, confidenceThreshold: 0.5, } }, }; function App() { - const { ObjectDetectionModelContextProvider } = useModels(MODELS) + const models = useImageLabelingModels(MODELS) + const { ImageLabelingModelProvider } = useImageLabelingProvider(models) return ( - <ObjectDetectionModelContextProvider> + <ImageLabelingModelProvider> {/* Rest of your app */} - </ObjectDetectionModelContextProvider> + </ImageLabelingModelProvider> ) }
Using the model
- const model = useImageLabeler("nsfwDetector") + const detector = useImageLabeling("nsfwDetector") const labels = await detector.classifyImage(imagePath)
Object Detection
useObjectDetectionModelsnow requires anassetsparameteruseObjectDetectoris nowuseObjectDetection- Introduced new
useObjectDetectionProviderhook for context management - Renamed and standardized type definitions:
RNMLKitObjectDetectionObject→ObjectDetectionObjectRNMLKitObjectDetectorOptions→ObjectDetectorOptionsRNMLKitCustomObjectDetectorOptions→CustomObjectDetectorOptions
- Added new types:
ObjectDetectionModelInfo,ObjectDetectionConfig,ObjectDetectionModels - Moved model configuration to typed asset records
- Default model now included in models type union
Here's how to update your app:
Fetching the provider
- const MODELS: AssetRecord = { + const MODELS: ObjectDetectionConfig = { birdDetector: { model: require("./assets/models/bird-detector.tflite"), options: { shouldEnableClassification: false, shouldEnableMultipleObjects: false, } }, }; function App() { - const { ObjectDetectionModelContextProvider } = useObjectDetectionModels({ - assets: MODELS, - loadDefaultModel: true, - defaultModelOptions: DEFAULT_MODEL_OPTIONS, - }) + const models = useObjectDetectionModels({ + assets: MODELS, + loadDefaultModel: true, + defaultModelOptions: DEFAULT_MODEL_OPTIONS, + }) + + const { ObjectDetectionProvider } = useObjectDetectionProvider(models) return ( - <ObjectDetectionModelContextProvider> + <ObjectDetectionProvider> {/* Rest of your app */} - </ObjectDetectionModelContextProvider> + </ObjectDetectionProvider> ) }
Using the model
- const {models: {birdDetector} = useObjectDetectionModels({ - assets: MODELS, - loadDefaultModel: true, - defaultModelOptions: DEFAULT_MODEL_OPTIONS, - }) - + const birdDetector = useObjectDetection("birdDetector") const objects = birdDetector.detectObjects(imagePath)
Face Detection
- Changed option naming conventions to match ML Kit SDK patterns:
detectLandmarks→landmarkModerunClassifications→classificationMode- Changed default
performanceModefromaccuratetofast - Renamed hook from
useFaceDetectortouseFaceDetection - Renamed context provider from
RNMLKitFaceDetectionContextProvidertoFaceDetectionProvider - Added comprehensive error handling
- Added new state management with
FaceDetectionStatetype
Here's how to update your app:
Using the detector
const options = { - detectLandmarks: true, + landmarkMode: true, - runClassifications: true, + classificationMode: true, }Using the provider
- import { RNMLKitFaceDetectionContextProvider } from "@infinitered/react-native-mlkit-face-detection" + import { FaceDetectionProvider } from "@infinitered/react-native-mlkit-face-detection" function App() { return ( - <RNMLKitFaceDetectionContextProvider> + <FaceDetectionProvider> {/* Rest of your app */} - </RNMLKitFaceDetectionContextProvider> + </FaceDetectionProvider> ) }
Using the hooks
- const detector = useFaceDetector() + const detector = useFaceDetection() // useFacesInPhoto remains unchanged const { faces, status, error } = useFacesInPhoto(imageUri)
Core Module
- Introduced shared TypeScript interfaces:
ModelInfo<T>AssetRecord<T>
- Standardized frame coordinate structure
- Implemented consistent type patterns
- Separates model operations into three hooks with simpler APIs
-
b668ab0: Upgrade to expo 52
Minor Changes
@infinitered/react-native-mlkit-object-detection@2.0.1
Patch Changes
- Updated dependencies [70cd8da]
- @infinitered/react-native-mlkit-core@2.1.0
@infinitered/react-native-mlkit-image-labeling@2.0.1
Patch Changes
- Updated dependencies [70cd8da]
- @infinitered/react-native-mlkit-core@2.1.0
@infinitered/react-native-mlkit-face-detection@2.0.1
Patch Changes
- Updated dependencies [70cd8da]
- @infinitered/react-native-mlkit-core@2.1.0
@infinitered/react-native-mlkit-document-scanner@2.0.1
Patch Changes
- Updated dependencies [70cd8da]
- @infinitered/react-native-mlkit-core@2.1.0
@infinitered/react-native-mlkit-core@2.1.0
Minor Changes
- 70cd8da: RNMLKitImage will now scale image to fill container by default. scaleFactor no longer accepts numbers.
@infinitered/react-native-mlkit-object-detection@2.0.0
Major Changes
-
1e282e0: Update modules and example app to be compatible with Expo v51. Increases minimum deployment target to 13.4.
To ensure that your app will be compatible, make sure your minimum deployment version is set higher than 13.4 by
using theexpo-build-propertiesplugin in yourapp.json.{ "plugins": [ [ "expo-build-properties", { "ios": { "deploymentTarget": "13.4" } } ] ] }
Patch Changes
- Updated dependencies [1e282e0]
- @infinitered/react-native-mlkit-core@2.0.0
@infinitered/react-native-mlkit-image-labeling@2.0.0
Major Changes
-
1e282e0: Update modules and example app to be compatible with Expo v51. Increases minimum deployment target to 13.4.
To ensure that your app will be compatible, make sure your minimum deployment version is set higher than 13.4 by
using theexpo-build-propertiesplugin in yourapp.json.{ "plugins": [ [ "expo-build-properties", { "ios": { "deploymentTarget": "13.4" } } ] ] }
Patch Changes
- Updated dependencies [1e282e0]
- @infinitered/react-native-mlkit-core@2.0.0
@infinitered/react-native-mlkit-face-detection@2.0.0
Major Changes
-
1e282e0: Update modules and example app to be compatible with Expo v51. Increases minimum deployment target to 13.4.
To ensure that your app will be compatible, make sure your minimum deployment version is set higher than 13.4 by
using theexpo-build-propertiesplugin in yourapp.json.{ "plugins": [ [ "expo-build-properties", { "ios": { "deploymentTarget": "13.4" } } ] ] }
Patch Changes
- Updated dependencies [1e282e0]
- @infinitered/react-native-mlkit-core@2.0.0