Skip to content

Commit adc1394

Browse files
authored
Merge pull request #190 from YoDevil/YoDevil-patch-1
ImageClassifier: predict: handle unsupported input
2 parents e5425eb + 652e1cf commit adc1394

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/ImageClassifier/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class ImageClassifier {
7070
imgToPredict = inputNumOrCallback;
7171
} else if (typeof inputNumOrCallback === 'object' && inputNumOrCallback.elt instanceof HTMLImageElement) {
7272
imgToPredict = inputNumOrCallback.elt; // Handle p5.js image
73+
} else if (!(this.video instanceof HTMLVideoElement)) {
74+
// Handle unsupported input
75+
throw new Error('No input image provided. If you want to classify a video, pass the video element in the constructor. ');
7376
}
7477

7578
if (typeof numOrCallback === 'number') {

0 commit comments

Comments
 (0)