You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
This PR introduces hookless API and restructures the `./src` directory.
### Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Documentation update (improves or adds clarity to existing
documentation)
### Tested on
- [x] iOS
- [x] Android
### Checklist
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly
- [x] My changes generate no new warnings
A string that specifies the path to the model file. You can download the model from our [HuggingFace repository](https://huggingface.co/software-mansion/react-native-executorch-ssdlite320-mobilenet-v3-large/tree/main).
57
+
A string that specifies the path to the model file. You can download the model from our [HuggingFace repository](https://huggingface.co/software-mansion/react-native-executorch-ssdlite320-mobilenet-v3-large/tree/main).
63
58
For more information on that topic, you can check out the [Loading models](https://docs.swmansion.com/react-native-executorch/fundamentals/loading-models) page.
64
59
65
60
### Returns
66
61
67
62
The hook returns an object with the following properties:
|`forward`|`(input: string) => Promise<Detection[]>`| A function that accepts an image (url, b64) and returns an array of `Detection` objects. |
67
+
|`error`| <code>string | null</code> | Contains the error message if the model loading failed. |
68
+
|`isGenerating`|`boolean`| Indicates whether the model is currently processing an inference. |
69
+
|`isReady`|`boolean`| Indicates whether the model has successfully loaded and is ready for inference. |
77
70
78
71
## Running the model
79
72
80
73
To run the model, you can use the `forward` method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The function returns an array of `Detection` objects. Each object contains coordinates of the bounding box, the label of the detected object, and the confidence score. For more information, please refer to the reference or type definitions.
81
74
82
75
## Detection object
76
+
83
77
The detection object is specified as follows:
78
+
84
79
```typescript
85
80
interfaceBbox {
86
81
x1:number;
@@ -95,33 +90,37 @@ interface Detection {
95
90
score:number;
96
91
}
97
92
```
93
+
98
94
The `bbox` property contains information about the bounding box of detected objects. It is represented as two points: one at the bottom-left corner of the bounding box (`x1`, `y1`) and the other at the top-right corner (`x2`, `y2`).
99
95
The `label` property contains the name of the detected object, which corresponds to one of the `CocoLabels`. The `score` represents the confidence score of the detected object.
0 commit comments