mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Dynamically load TensorFlow JS
This commit is contained in:
parent
155dc45906
commit
c950b4d28e
@ -298,22 +298,6 @@ var ComunicWeb = {
|
|||||||
setStatus: function(success){},
|
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
|
* The date library
|
||||||
*/
|
*/
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
* @param {String} fileURL The file URL
|
* @param {String} fileURL The file URL
|
||||||
* @return {Boolean} False if it fails
|
* @return {Boolean} False if it fails
|
||||||
*/
|
*/
|
||||||
ComunicWeb.common.jsFiles.includeFile = function(fileURL){
|
async function includeJS(fileURL) {
|
||||||
var fileElem = document.createElement("script");
|
var fileElem = document.createElement("script");
|
||||||
fileElem.type = "text/javascript";
|
fileElem.type = "text/javascript";
|
||||||
fileElem.src = fileURL;
|
fileElem.innerHTML = await (await fetch(fileURL)).text();
|
||||||
|
|
||||||
//Append the new element
|
//Append the new element
|
||||||
document.body.appendChild(fileElem);
|
document.head.appendChild(fileElem);
|
||||||
|
|
||||||
//Debug message
|
//Debug message
|
||||||
ComunicWeb.debug.logMessage("Added JS file " + fileURL);
|
ComunicWeb.debug.logMessage("Added JS file " + fileURL);
|
||||||
@ -30,7 +30,7 @@ ComunicWeb.common.jsFiles.includeFile = function(fileURL){
|
|||||||
*
|
*
|
||||||
* @param {String} source The source code to execute
|
* @param {String} source The source code to execute
|
||||||
*/
|
*/
|
||||||
ComunicWeb.common.jsFiles.executeJSsource = function(source){
|
function executeJSsource(source){
|
||||||
var jsSourceContainer = document.createElement("script");
|
var jsSourceContainer = document.createElement("script");
|
||||||
jsSourceContainer.innerHTML = source;
|
jsSourceContainer.innerHTML = source;
|
||||||
document.body.appendChild(jsSourceContainer);
|
document.body.appendChild(jsSourceContainer);
|
||||||
|
@ -993,6 +993,9 @@ class CallWindow extends CustomEvents {
|
|||||||
// Load network if required
|
// Load network if required
|
||||||
if (!this.backgroundDetectionNetwork)
|
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({
|
this.backgroundDetectionNetwork = await bodyPix.load({
|
||||||
multiplier: 0.75,
|
multiplier: 0.75,
|
||||||
stride: 32,
|
stride: 32,
|
||||||
|
@ -168,10 +168,6 @@ class Dev {
|
|||||||
|
|
||||||
// Record MediaStream
|
// Record MediaStream
|
||||||
"3rdparty/MediaStreamRecorder.min.js",
|
"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