File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import * as tf from '@tensorflow/tfjs';
22import cropAndResizeImage from './cropAndResizeImage' ;
33import getClasses from './getClasses' ;
44import train from './train' ;
5+ import translateImages from './translateImages' ;
56import loadPretrainedModel , {
67 PRETRAINED_MODELS_KEYS ,
78} from './loadPretrainedModel' ;
@@ -58,7 +59,7 @@ class MLClassifier {
5859 }
5960
6061 private getData = async ( dataType : string ) : Promise < ICollectedData > => {
61- if ( dataType !== 'train' || dataType !== 'eval' ) {
62+ if ( dataType !== 'train' && dataType !== 'eval' ) {
6263 throw new Error ( `Datatype ${ dataType } unsupported` ) ;
6364 }
6465
Original file line number Diff line number Diff line change 1+ import * as tf from '@tensorflow/tfjs' ;
2+
13const loadImage = async ( src : string ) => new Promise < HTMLImageElement > ( ( resolve , reject ) => {
24 const image = new Image ( ) ;
35 image . src = src ;
@@ -14,7 +16,7 @@ const translateImages = async (origImages: Array<tf.Tensor3D | HTMLImageElement
1416 if ( typeof image === 'string' ) {
1517 const loadedImage = await loadImage ( image ) ;
1618 image = tf . fromPixels ( loadedImage ) ;
17- } else if ( image . src ) {
19+ } else if ( image instanceof HTMLImageElement ) {
1820 const loadedImage = await loadImage ( image . src ) ;
1921 image = tf . fromPixels ( loadedImage ) ;
2022 }
@@ -26,4 +28,4 @@ const translateImages = async (origImages: Array<tf.Tensor3D | HTMLImageElement
2628 return images ;
2729}
2830
29- export translateImages ;
31+ export default translateImages ;
You can’t perform that action at this time.
0 commit comments