先の記事の補足です。
「あ、い、う、え、お、X」の6種類の口形が、awbとcwaという2つの特徴量によって、かなり明確に分離できるという実験結果を先に示しました。今回は、これをより明確にリアルタイムに確認するために、アプリを若干改訂しました。詳しくは、下図の中の説明文をご覧下さい。
I am a professor emeritus of CS at Kanagawa Institute of Technology, Japan. Originally my specialty was parallel and distributed systems. My current interests include machine learning, natural language processing, creating mobile apps with MIT App Inventor, and quantum computing. In the web version of this blog, clicking the icon on the right (a plastic sphere) will take you to the "List of Quantum Computing Articles". - Fujio Yamamoto (for e-mail, add "@ieee.org" after "yamamotof")
先の記事の補足です。
「あ、い、う、え、お、X」の6種類の口形が、awbとcwaという2つの特徴量によって、かなり明確に分離できるという実験結果を先に示しました。今回は、これをより明確にリアルタイムに確認するために、アプリを若干改訂しました。詳しくは、下図の中の説明文をご覧下さい。
This article is a sequel to "Using the MIT App Inventor Facemesh Extension". In Facemesh, the key points of the face are numbered from 1 to 450, and the map that associates the number with the position in the face is provided by Google on GitHub. However, at present, this map does not show the correct position in the face (probably due to version upgrade). Therefore, I made a tool to get the correspondence between the number and the actual position.
Most desirable is to get that number by touching a Facemesh key point. However, there are 450 points in total, including dense parts, so even if it is enlarged, it is difficult to operate it on the screen of the smartphone. Therefore, as a second method, I decided to search for the necessary key points while increasing or decreasing the number. In this case, a partial map that is already known (like the handwritten map in Fig. 1) is useful.
In the Fig.1, start from the specified value (255 in the figure), and increase or decrease the number with the "+" and "-" buttons. This makes it easy to search around 255, for example. In this example, the red dot for number 256 is clearly visible among the green keypoints. This app also uses the Facemesh extension from MIT App Inventor. Fig.2 shows the main parts of the program. I won't explain it in detail, but it's fairly easy to make because it uses Ball, which is an animation function of App Inventor.
In fact, in the "mask wearing" shown in the previous task [Exercise-1], the key points that form the periphery of the mask were acquired by the above method.
【abstract】The MIT App Inventor FaceExtension has been released [1][2]. This makes it very easy to create a smartphone app that uses Google's facial recognition (450 major points) learning model Facemesh. Let's make three simple apps right away.
■[Exercise-1] On/Off by opening and closing the mouth considering face orientation
You can see what I want to make by watching the animated gif below. Let's make this little app using the FaceExtension of MIT App Inventor.
My answer is shown in Figure 1. Here's a complete App Inventor source program that works. I think this program is simple and very easy to understand. Notice that the opening and closing of the mouth is detected by the difference in the y-coordinate between upper and lower lips, and the orientation of the face is detected by the difference in the x-coordinates between the two points on the nose. They are grouped into a block (named whenFaceExtension.FaceUpdated) and it is activated in real time when the face or mouth moves.
■[Exercise-3] - Visualize the transition of the mouth-shaped area during utterance
One of the great features of MIT App Inventor is the ease of integration with the GUI. Fig.4 is an app that makes the best use of it. Facemesh can detect the main 450 points on the face, but here we will use only 4 points around the mouth. The simpler the better. Graph the transition of the area of this diamond-shaped mouth (blue line) and the rate of change of the area (red line). This is an exercise that you can enjoy watching the movement of the mouth and its waveform. Play may give some hints.
In order to properly distinguish, for example, "apple" from "orange" using such mouth movements, acceleration waveforms of mouth area change may also be needed. Hundreds of such waveforms (or their frequency analysis results) should be prepared for each utterance type. And thorough training (learning) using them will be necessary.
References
[1] Facemesh Filter Camera
http://appinventor.mit.edu/explore/resources/ai/facemesh
[2] Artificial Intelligence with MIT App Inventor,
http://appinventor.mit.edu/explore/ai-with-mit-app-inventor
【what is this】Googleの顔認識(主要486点)や指の認識(主要関節21点)の学習モデルが、PythonやJavaScriptなどで使えるようになっています[1]。本記事は、これに基づいた顔認識モデルFacemeshに関する小生独自の簡単な説明です。
■顔のキーポイント(全486点)のリアルタイム認識
Facemeshによる顔のキーポイントの検出例を図1に示します。人間の実写の他、写真や肖像画でもOKのようです。福沢諭吉と平賀源内の肖像画(何故かこのお二人)、および大学HPの広報(女子学生)写真で試しました。顔認識や感情分析に重要な、口や鼻や目の付近のメッシュは当然ながら細かくなっています。
■唇と瞼の開き具合の認識
主要点番号とその位置の対応は、mesh mapにありますので、その番号を指定して、必要な点の検出ができます。一例として、唇と瞼の開き具合を見るため、図2のように、8点(唇4点と瞼4点)を赤色に着色してみました。
これら8点のマップは図3のとおりです。鼻や頬や顎についてのキーポイントも同様に得られます。(キーポイント番号は、その後改訂にともない、図3とは異なるかも知れません。)これらを利用すれば、例えば口の開き具合で、何かの動作を制御する等、自分なりの顔認識関係アプリを(簡単なものであれば)作れそうな気になります!
図4は、日本語母音の発話時の口形の検出例です。なかなか面白そうですが、これですぐに読唇ができるわけではありません。実際の機械読唇技術に関しては、宮崎剛教授らの論文[2]等を参考にして深く検討する必要があるでしょう。
■口の開閉でオンオフを制御してみる
→この項はその後修正し、こちらにまとめました。
■感想
(1)プログラミングの容易化
図3を改めて眺めてみました。このようにランドマーク(キーポイント)がリアルタイムに検出されるのであれば、この後は顔の表情を認識することは格段に容易になります。(情報系が苦手な学生を含む)より幅広い人々が、AI技術発展の恩恵を受けられると思います。
(2)スマホなどGPU無しでも推論ができる
以前は、上記例題のようなリアルタイム顔認識には、GPU付きの高性能PCが必要でしたが、今はこのような認識(推論)は普通のスマホで十分できてしまう。アイディアと工夫次第で、思いもつかぬアプリケーションも生まれそうに思われます。
参考文献・資料
[1] Face and hand tracking in the browser with MediaPipe and TensorFlow.js, https://blog.tensorflow.org/2020/03/face-and-hand-tracking-in-browser-with-mediapipe-and-tensorflowjs.html
[2] 宮崎 剛、中島豊四郎:[推薦論文]日本語の発話映像における初口形の検出方法提案、情報処理学会論文誌、Vol.53、No.3、pp.1472-1479、2012.