Skip to content

Commit 4df6399

Browse files
docs: clean up readme
1 parent 449103a commit 4df6399

File tree

1 file changed

+3
-87
lines changed
  • modules/react-native-mlkit-barcode-scanning

1 file changed

+3
-87
lines changed
Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,5 @@
1-
# @infinitered/react-native-mlkit-image-labeling
1+
# @infinitered/react-native-mlkit-barcode-scanning
22

3-
### [Check the friendly docs here! 📖](https://docs.infinite.red/react-native-mlkit/image-labeling)
3+
### [Check the friendly docs here! 📖](https://docs.infinite.red/react-native-mlkit/barcode-scanning)
44

5-
# Getting Started with react-native-mlkit-image-labeling
6-
7-
## Overview
8-
9-
`react-native-mlkit-image-labeling` provides utilities for image classification using ML Kit in React Native apps. It
10-
allows for the classification of images using either ML Kit's built-in models or custom TensorFlow Lite models.
11-
12-
## Installation
13-
14-
```shell
15-
npm install @infinitered/react-native-mlkit-image-labeling expo-asset
16-
```
17-
18-
## Usage
19-
20-
### 1. Import necessary hooks and types:
21-
22-
```tsx
23-
import {
24-
useImageLabeling,
25-
useImageLabelingProvider,
26-
useImageLabelingModels,
27-
ImageLabelingConfig,
28-
ClassificationResult
29-
} from "@infinitered/react-native-mlkit-image-labeling";
30-
```
31-
32-
### 2. Define your models configuration:
33-
34-
Create an `ImageLabelingConfig` object that identifies your model files and options:
35-
36-
```tsx
37-
const MODELS: ImageLabelingConfig = {
38-
nsfw: {
39-
model: require("./path/to/model.tflite"),
40-
options: {
41-
maxResultCount: 5,
42-
confidenceThreshold: 0.5,
43-
},
44-
},
45-
};
46-
```
47-
48-
### 3. Set up the Provider:
49-
50-
The image labeling functionality requires a provider at the root of your app or where you plan to use the models:
51-
52-
```tsx
53-
function App() {
54-
const models = useImageLabelingModels(MODELS);
55-
const { ImageLabelingModelProvider } = useImageLabelingProvider(models);
56-
57-
return (
58-
<ImageLabelingModelProvider>
59-
<YourApp />
60-
</ImageLabelingModelProvider>
61-
);
62-
}
63-
64-
```
65-
66-
### 4. Using the image labeler in your components:
67-
68-
```tsx
69-
function ImageClassifier() {
70-
// Get the classifier instance for your model
71-
const classifier = useImageLabeling("nsfw");
72-
73-
const classifyImage = async (imageUri: string) => {
74-
try {
75-
const result = await classifier.classifyImage(imageUri);
76-
console.log(result);
77-
} catch (error) {
78-
console.error("Classification failed:", error);
79-
}
80-
};
81-
82-
return (
83-
<View>
84-
// ....your component
85-
</View>
86-
);
87-
}
88-
89-
```
5+
# Getting Started with react-native-mlkit-barcode-scanning

0 commit comments

Comments
 (0)