learning_model 1.0.39 → 1.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -138,7 +138,8 @@ class LearningMobilenet {
138
138
  return __awaiter(this, void 0, void 0, function* () {
139
139
  try {
140
140
  if (this.mobilenetModule !== null) {
141
- const cap = (0, tf_1.isTensor)(data) ? data : (0, tf_1.capture)(data, false);
141
+ const croppedImage = (0, canvas_1.cropTo)(data, 224, false);
142
+ const cap = (0, tf_1.isTensor)(data) ? data : (0, tf_1.capture)(croppedImage, false);
142
143
  const predict = this.mobilenetModule.predict(cap);
143
144
  const activation = predict.dataSync();
144
145
  const classIndex = this.registerClassNumber(label);
@@ -190,13 +191,13 @@ class LearningMobilenet {
190
191
  this.isRunning = false;
191
192
  },
192
193
  onBatchBegin: (batch, logs) => {
193
- console.log(`Batch ${batch} is starting.`);
194
+ //console.log(`Batch ${batch} is starting.`);
194
195
  },
195
196
  onBatchEnd: (batch, logs) => {
196
- console.log(`Batch ${batch} has ended.`);
197
+ //console.log(`Batch ${batch} has ended.`);
197
198
  },
198
199
  onEpochBegin: (epoch, logs) => {
199
- console.log(`Epoch ${epoch + 1} is starting.`, logs);
200
+ //console.log(`Epoch ${epoch+1} is starting.`, logs);
200
201
  },
201
202
  onEpochEnd: (epoch, logs) => {
202
203
  this.onEpochEnd(epoch, logs);
@@ -264,6 +265,7 @@ class LearningMobilenet {
264
265
  classProbabilities.set(className, probability);
265
266
  }
266
267
  }
268
+ console.log('classProbabilities', classProbabilities);
267
269
  (0, tfjs_1.dispose)(logits);
268
270
  return classProbabilities;
269
271
  }
@@ -300,7 +302,7 @@ class LearningMobilenet {
300
302
  layers: [
301
303
  tf.layers.dense({
302
304
  inputShape: this.mobilenetModule.outputs[0].shape.slice(1),
303
- units: 64,
305
+ units: 128,
304
306
  activation: 'relu',
305
307
  kernelInitializer: varianceScaling,
306
308
  useBias: true
@@ -150,7 +150,8 @@ class LearningMobilenet implements LearningInterface {
150
150
  public async addData(label: string, data: any): Promise<void> {
151
151
  try {
152
152
  if (this.mobilenetModule !== null) {
153
- const cap = isTensor(data) ? data : capture(data, false);
153
+ const croppedImage = cropTo(data, 224, false);
154
+ const cap = isTensor(data) ? data : capture(croppedImage, false);
154
155
  const predict = this.mobilenetModule.predict(cap) as tf.Tensor;
155
156
  const activation = predict.dataSync() as Float32Array;
156
157
  const classIndex = this.registerClassNumber(label);
@@ -199,13 +200,13 @@ class LearningMobilenet implements LearningInterface {
199
200
  this.isRunning = false;
200
201
  },
201
202
  onBatchBegin: (batch: any, logs: any) => {
202
- console.log(`Batch ${batch} is starting.`);
203
+ //console.log(`Batch ${batch} is starting.`);
203
204
  },
204
205
  onBatchEnd: (batch: any, logs: any) => {
205
- console.log(`Batch ${batch} has ended.`);
206
+ //console.log(`Batch ${batch} has ended.`);
206
207
  },
207
208
  onEpochBegin: (epoch: number, logs: any) => {
208
- console.log(`Epoch ${epoch+1} is starting.`, logs);
209
+ //console.log(`Epoch ${epoch+1} is starting.`, logs);
209
210
  },
210
211
  onEpochEnd: (epoch: number, logs: any) => {
211
212
  this.onEpochEnd(epoch, logs);
@@ -273,6 +274,7 @@ class LearningMobilenet implements LearningInterface {
273
274
  classProbabilities.set(className, probability);
274
275
  }
275
276
  }
277
+ console.log('classProbabilities', classProbabilities);
276
278
  dispose(logits);
277
279
  return classProbabilities;
278
280
  } catch (error) {
@@ -310,7 +312,7 @@ class LearningMobilenet implements LearningInterface {
310
312
  layers: [
311
313
  tf.layers.dense({
312
314
  inputShape: this.mobilenetModule!.outputs[0].shape.slice(1),
313
- units: 64,
315
+ units: 128,
314
316
  activation: 'relu',
315
317
  kernelInitializer: varianceScaling, // 'varianceScaling'
316
318
  useBias: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learning_model",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "learning model develop",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",