https://editor.p5js.org/Claire_Z/sketches/oKT7rMdZ-

I tried the facial emotions image detection model in transformer.js (link to the model). It can detect the facial expression in the image and output 5 guesses with the rank of possibility from night to low.

I tried several different kinds of images. It’s better at recognizing those typical facial expressions, like the smiling face in the first image.

image.png

image.png

image.png

image.png

Compare with ml5, the most intuitive feeling is that the loading speed of the transformer.js models is slower than ml5. It takes a much longer time to load, as I always wonder if the model is still loading or there are errors in the code. But I think there are more pre-trained models than are more specific in achieving certain functions in transformer.js than ml5. For example, the model I tried can directly guesses the facial emotion of the image, yet with the ml5 models we learned so far, there are more steps between input an image and output a guess of the emotion.

image.png

When I run the sketch, it gives some errors, while still show the results. What are those errors?