mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-24 18:08:50 +00:00
Dynamically load TensorFlow JS
This commit is contained in:
parent
155dc45906
commit
c950b4d28e
@ -298,22 +298,6 @@ var ComunicWeb = {
|
||||
setStatus: function(success){},
|
||||
},
|
||||
|
||||
/**
|
||||
* Operations on JS files
|
||||
*/
|
||||
jsFiles:{
|
||||
|
||||
/**
|
||||
* Include a Javascript file
|
||||
*/
|
||||
includeFile: function(fileURL){},
|
||||
|
||||
/**
|
||||
* Execute some source code contained in a variable
|
||||
*/
|
||||
executeJSsource: function(source){},
|
||||
},
|
||||
|
||||
/**
|
||||
* The date library
|
||||
*/
|
||||
|
@ -10,13 +10,13 @@
|
||||
* @param {String} fileURL The file URL
|
||||
* @return {Boolean} False if it fails
|
||||
*/
|
||||
ComunicWeb.common.jsFiles.includeFile = function(fileURL){
|
||||
async function includeJS(fileURL) {
|
||||
var fileElem = document.createElement("script");
|
||||
fileElem.type = "text/javascript";
|
||||
fileElem.src = fileURL;
|
||||
fileElem.innerHTML = await (await fetch(fileURL)).text();
|
||||
|
||||
//Append the new element
|
||||
document.body.appendChild(fileElem);
|
||||
document.head.appendChild(fileElem);
|
||||
|
||||
//Debug message
|
||||
ComunicWeb.debug.logMessage("Added JS file " + fileURL);
|
||||
@ -30,8 +30,8 @@ ComunicWeb.common.jsFiles.includeFile = function(fileURL){
|
||||
*
|
||||
* @param {String} source The source code to execute
|
||||
*/
|
||||
ComunicWeb.common.jsFiles.executeJSsource = function(source){
|
||||
function executeJSsource(source){
|
||||
var jsSourceContainer = document.createElement("script");
|
||||
jsSourceContainer.innerHTML = source;
|
||||
document.body.appendChild(jsSourceContainer);
|
||||
}
|
||||
}
|
@ -993,6 +993,9 @@ class CallWindow extends CustomEvents {
|
||||
// Load network if required
|
||||
if (!this.backgroundDetectionNetwork)
|
||||
{
|
||||
await includeJS(ComunicConfig.assetsURL + "3rdparty/tfjs/tfjs-1.2.min.js");
|
||||
await includeJS(ComunicConfig.assetsURL + "3rdparty/tensorflow-models/body-pix-2.0.js");
|
||||
|
||||
this.backgroundDetectionNetwork = await bodyPix.load({
|
||||
multiplier: 0.75,
|
||||
stride: 32,
|
||||
|
@ -168,10 +168,6 @@ class Dev {
|
||||
|
||||
// Record MediaStream
|
||||
"3rdparty/MediaStreamRecorder.min.js",
|
||||
|
||||
// TensorflowJS
|
||||
"3rdparty/tfjs/tfjs-1.2.min.js",
|
||||
"3rdparty/tensorflow-models/body-pix-2.0.js"
|
||||
);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user