Skip to content

Commit 19638ae

Browse files
author
Kevin Scott
committed
Also transform images into predict
1 parent e381841 commit 19638ae

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

package-lock.json

Lines changed: 22 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ml-classifier",
3-
"version": "0.3.7",
3+
"version": "0.3.8",
44
"description": "A machine learning engine for quickly training image classification models in your browser",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ class MLClassifier {
125125
return history;
126126
}
127127

128-
public predict = async (data: tf.Tensor3D) => {
128+
public predict = async (orig: tf.Tensor3D | HTMLImageElement | string) => {
129129
await this.loaded();
130130
if (!this.model) {
131131
throw new Error('You must call train prior to calling predict');
132132
}
133+
const data = await translateImages([orig])[0];
133134
const img = await this.cropAndActivateImage(data);
134135
// TODO: Do these images need to be activated?
135136
const predictedClass = tf.tidy(() => {

0 commit comments

Comments
 (0)