File tree Expand file tree Collapse file tree 1 file changed +10
-21
lines changed Expand file tree Collapse file tree 1 file changed +10
-21
lines changed Original file line number Diff line number Diff line change 1
1
# tfjs-image-node
2
+
2
3
A simple image classifier using tfjs, that can run in Node.js
3
4
4
5
### Install
6
+
5
7
``` bash
6
8
npm i tfjs-image-node
7
9
# or
8
10
yarn add tfjs-image-node
9
11
# or
10
12
bun add tfjs-image-node
11
13
```
14
+
12
15
### Import
16
+
13
17
``` typescript
14
18
const classifyImage = require (" tfjs-image-node" );
15
19
// or
16
20
import { classifyImage } from " tfjs-image-node" ;
17
21
```
18
22
19
-
20
23
## Example
24
+
21
25
``` typescript
22
26
const classifyImage = require (" tfjs-image-node" );
23
27
24
- const metadata = require (" ./metadata.json" );
25
28
const model = " https://teachablemachine.withgoogle.com/models/jAIOHvmge" ;
26
- const image = " https://www.stgeorges.nhs.uk/wp-content/uploads/2014/03/hand-2.jpeg" ;
29
+ const image =
30
+ " https://www.stgeorges.nhs.uk/wp-content/uploads/2014/03/hand-2.jpeg" ;
27
31
28
32
(async () => {
29
- const prediction = await classifyImage (model , image , metadata );
33
+ const prediction = await classifyImage (model , image );
30
34
console .log (prediction [0 ]);
31
- })()
35
+ })();
32
36
33
37
// expected output:
34
38
// { label: 'Hand', probability: 0.9999574422836304 }
35
39
```
36
40
37
41
## Parameters
42
+
38
43
<table >
39
44
<thead >
40
45
<tr>
@@ -66,21 +71,5 @@ const image = "https://www.stgeorges.nhs.uk/wp-content/uploads/2014/03/hand-2.jp
66
71
The file path or URL to the image you want classified.
67
72
</td>
68
73
</tr>
69
- <tr>
70
- <td>
71
- METADATA
72
- </td>
73
- <td>
74
- JSON including labels: string[]
75
- </td>
76
- <td>
77
- The metadata for your AI model, including the labels for the model's predictions.
78
- </td>
79
- </tr>
80
74
</tdata >
81
75
</table >
82
-
83
-
84
-
85
-
86
-
You can’t perform that action at this time.
0 commit comments