lmoroney / dlaicourse

Notebooks for learning deep learning
5.66k stars 5.37k forks source link

Fix bug occuring in Firefox #89

Open PaulPidou opened 4 years ago

PaulPidou commented 4 years ago

In Firefox the function tf.browser.fromPixels(this.webcamElement) doesn't return a Tensor that matches the video width and height. The croppedImage obtained is thus of size [240, 240] which raises the follwing error: Error: Error when checking : expected input_1 to have shape [null,224,224,3] but got array with shape [1,240,240,3].

In order to match the input size of the model the croppedImage needs to be resized. This is ensured by the two lines added.

The fix has been tested on Firefox Browser 74.0.1 (64 bits) and Google Chrome 80.0.3987.163 (64 bits)