1tf.setBackend("webgl"),tf.enableProdMode();var videoWidth=400,videoHeight=300;const IMAGE_WIDTH=224,IMAGE_HEIGHT=224;var mode="user";const mobile=isMobile();let model_classifier;const status_classifier=document.getElementById("status_classifier");document.getElementById("files0").addEventListener("change",(function(e){file_infer(e.target.files[0],document.getElementById("inpimg0"),status_classifier,classifier_Demo)})),document.getElementById("classifier_files_btn").addEventListener("click",(function(e){file=document.getElementById("files0").files[0],null==file?status_classifier.textContent="Status: File not found":file_infer(file,document.getElementById("inpimg0"),status_classifier,classifier_Demo)})),document.getElementById("btn0").addEventListener("click",(function(e){url_infer(document.getElementById("imagename0"),document.getElementById("inpimg0"),status_classifier,classifier_Demo)}));const ClassiferWarmup=async()=>{status_classifier.textContent="Status: Loading...",model_classifier=await tf.loadGraphModel("/assets/tfjs_model/model.json");const e=document.getElementById("inpimg0");e.complete&&0!==e.naturalHeight?(classifier_Demo(e),e.style.display=""):e.onload=()=>{classifier_Demo(e),e.style.display=""},document.getElementById("file-container").style.display=""},classifier_Demo=async e=>{status_classifier.textContent="Status: Loading image into model...";const t=tf.tidy((()=>{const t=tf.browser.fromPixels(e).toFloat().resizeBilinear([224,224]),n=tf.scalar(255),i=tf.tensor3d([.485,.456,.406],[1,1,3]),c=tf.tensor3d([.229,.224,.225],[1,1,3]),d=t.div(n).sub(i).div(c);status_classifier.textContent="Status: Model loaded! running inference";const o=d.transpose([0,1,2]).expandDims();return model_classifier.predict(o).arraySync()}));var n=[];n.push(["bus",t[0][0]]),n.push(["car",t[0][1]]),n.push(["pickup",t[0][2]]),n.push(["truck",t[0][3]]),n.push(["van",t[0][4]]),n.sort((function(e,t){return t[1]-e[1]})),document.getElementById("classifier_out1").innerHTML=n[0][0]+": "+(100*n[0][1]).toFixed(2)+"%",document.getElementById("classifier_out2").innerHTML=n[1][0]+": "+(100*n[1][1]).toFixed(2)+"%",document.getElementById("classifier_out3").innerHTML=n[2][0]+": "+(100*n[2][1]).toFixed(2)+"%",status_classifier.textContent="Status: Done!"};let request,video;function detectInRealTime(e){const t=document.getElementById("output"),n=t.getContext("2d"),i="rear"!=mode;t.width=videoWidth,t.height=videoHeight,async function t(){n.clearRect(0,0,videoWidth,videoHeight),e.onloadeddata=()=>{camloaded=!0},camloaded&&(await classifier_Demo(e),n.save(),i&&(n.scale(-1,1),n.translate(-videoWidth,0)),n.drawImage(e,0,0,videoWidth,videoHeight),n.restore()),request=requestAnimationFrame(t)}()}async function bindPage(){camloaded=!1;try{video=await loadVideo(mode)}catch(e){let t=document.getElementById("info");throw t.textContent="this browser does not support video capture,or this device does not have a camera",t.style.display="block",e}detectInRealTime(video)}var filecheckBox=document.getElementById("fileinput"),urlcheckBox=document.getElementById("urlinput"),filecontainer=document.getElementById("file-container"),urlcontainer=document.getElementById("url-container");filecheckBox.addEventListener("click",(function(){1==filecheckBox.checked?(urlcheckBox.checked=!1,filecontainer.style.display="block",urlcontainer.style.display="none"):(urlcheckBox.checked=!0,filecontainer.style.display="none",urlcontainer.style.display="block")})),urlcheckBox.addEventListener("click",(function(){1==urlcheckBox.checked?(filecheckBox.checked=!1,filecontainer.style.display="none",urlcontainer.style.display="block"):(filecheckBox.checked=!0,filecontainer.style.display="block",urlcontainer.style.display="none")})),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;var camloaded=!1;function showfps(){var e=document.getElementById("show_fps"),t=document.getElementById("fps");1==e.checked?t.style.display="block":t.style.display="none"}function setmode(){mode=1==document.getElementById("camMode").checked?"rear":"user",1==document.getElementById("webcamc").checked&&(video.srcObject.getTracks().forEac
1h((function(e){e.stop()})),cancelAnimationFrame(request),bindPage())}function webc(){var e=document.getElementById("imagec"),t=document.getElementById("webcamc"),n=document.getElementById("mainImage"),i=document.getElementById("mainVideo");if(1==t.checked)mobile&&(document.getElementById("camswitch").style.display="block"),e.checked=!1,t_Width=document.getElementById("mainopt").clientWidth,t_Height=300,n.style.display="none",document.getElementById("main").style.display="block",i.style.display="block",apectWidth=4/3*t_Height,videoWidth=apectWidth>t_Width?t_Width:apectWidth,videoHeight=t_Height,camloaded=!1,bindPage();else{document.getElementById("camswitch").style.display="none",cancelAnimationFrame(request),video.srcObject.getTracks().forEach((function(e){e.stop()}));document.getElementById("output").getContext("2d").clearRect(0,0,videoWidth,videoHeight),i.style.display="none",document.getElementById("main").style.display="none"}}function imagec(){var e=document.getElementById("imagec"),t=document.getElementById("webcamc"),n=document.getElementById("mainImage"),i=document.getElementById("inpimg0"),c=document.getElementById("mainVideo");1==e.checked?(1==t.checked&&(document.getElementById("camswitch").style.display="none",t.checked=!1,cancelAnimationFrame(request),video&&video.srcObject.getTracks().forEach((function(e){e.stop()}))),document.getElementById("main").style.display="block",n.style.display="block",c.style.display="none",i.src="/assets/demo_images/box_6109.jpg",ClassiferWarmup()):(n.style.display="none",document.getElementById("main").style.display="none")}ClassiferWarmup();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.