June 2022
Intermediate to advanced
368 pages
5h 36m
Japanese
MobileNetモデルはあらゆる種類の異なるトラックを検出できます。識別可能なトラックの一覧をすべて確認してこの問題の解答としてもいいですし、単純に得られたクラス名のリストのそれぞれに「truck」という単語が含まれるかどうかを確認してもかまいません。ここではより簡単な後者の解答を紹介します。
HTMLとJavaScriptの全体を含む解答は以下のようになります。
<!DOCTYPE html><html><head><scriptsrc="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.7.0/dist/tf.min.js"></script><scriptsrc="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet@1.0.0"></script>❶<script>mobilenet.load().then(model=>{constimg=document.getElementById('myImage');❷// 画像を分類model.classify(img).then(predictions=>{console.log('Predictions: ',predictions);// トラックだったかどうか?letfoundATruckpredictions.forEach(p=>{foundATruck=foundATruck||p.className.includes("truck")❸})// ダイアログに「TRUCK ...
Read now
Unlock full access