learning_model 1.0.40 → 1.0.42

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,8 +138,7 @@ class LearningMobilenet {
138
138
  return __awaiter(this, void 0, void 0, function* () {
139
139
  try {
140
140
  if (this.mobilenetModule !== null) {
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);
141
+ const cap = (0, tf_1.isTensor)(data) ? data : (0, tf_1.capture)(data, false);
143
142
  const predict = this.mobilenetModule.predict(cap);
144
143
  const activation = predict.dataSync();
145
144
  const classIndex = this.registerClassNumber(label);
@@ -278,10 +277,16 @@ class LearningMobilenet {
278
277
  saveModel(handlerOrURL, config) {
279
278
  var _a;
280
279
  return __awaiter(this, void 0, void 0, function* () {
281
- if (!this.isTrainedDone) {
282
- return Promise.reject(new Error('Train is not done status'));
280
+ try {
281
+ console.log('saveModel try', this.isTrainedDone);
282
+ if (!this.isTrainedDone) {
283
+ return Promise.reject(new Error('Train is not done status'));
284
+ }
285
+ yield ((_a = this.model) === null || _a === void 0 ? void 0 : _a.save(handlerOrURL, config));
286
+ }
287
+ catch (e) {
288
+ console.log('saveModel Error', e);
283
289
  }
284
- yield ((_a = this.model) === null || _a === void 0 ? void 0 : _a.save(handlerOrURL, config));
285
290
  });
286
291
  }
287
292
  // 진행중 여부
@@ -150,8 +150,7 @@ 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 croppedImage = cropTo(data, 224, false);
154
- const cap = isTensor(data) ? data : capture(croppedImage, false);
153
+ const cap = isTensor(data) ? data : capture(data, false);
155
154
  const predict = this.mobilenetModule.predict(cap) as tf.Tensor;
156
155
  const activation = predict.dataSync() as Float32Array;
157
156
  const classIndex = this.registerClassNumber(label);
@@ -285,10 +284,15 @@ class LearningMobilenet implements LearningInterface {
285
284
 
286
285
  // 모델 저장
287
286
  public async saveModel(handlerOrURL: io.IOHandler | string, config?: io.SaveConfig): Promise<void> {
288
- if (!this.isTrainedDone) {
289
- return Promise.reject(new Error('Train is not done status'));
287
+ try {
288
+ console.log('saveModel try', this.isTrainedDone);
289
+ if (!this.isTrainedDone) {
290
+ return Promise.reject(new Error('Train is not done status'));
291
+ }
292
+ await this.model?.save(handlerOrURL, config);
293
+ } catch(e) {
294
+ console.log('saveModel Error', e);
290
295
  }
291
- await this.model?.save(handlerOrURL, config);
292
296
  }
293
297
 
294
298
  // 진행중 여부
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learning_model",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "learning model develop",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",