PHP Classes

File: js/main/ModelLoader.js

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Face ID PHP   js/main/ModelLoader.js   Download  
File: js/main/ModelLoader.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Face ID PHP
Recognize faces by analyzing image descriptors
Author: By
Last change:
Date: 1 month ago
Size: 1,179 bytes
 

 

Contents

Class file image Download
export default class ModelLoader { constructor(faceapi) { this.modelsLoaded = false; this.loadingIndicator = document.getElementById('loadingIndicator'); } async loadModels() { if (this.modelsLoaded) { return; } this.showLoadingIndicator(); try { await faceapi.nets.tinyFaceDetector.loadFromUri('/models'), await faceapi.nets.ssdMobilenetv1.loadFromUri("/models") await faceapi.nets.faceLandmark68Net.loadFromUri("/models") await faceapi.nets.faceRecognitionNet.loadFromUri("/models") this.modelsLoaded = true; console.log('Modelos de reconhecimento facial carregados.'); } catch (error) { console.error("Falha ao carregar modelos face-api:", error); this.modelsLoaded = false; } finally { this.hideLoadingIndicator(); } } showLoadingIndicator() { this.loadingIndicator.style.display = 'block'; } hideLoadingIndicator() { this.loadingIndicator.style.display = 'none'; } areModelsLoaded() { return this.modelsLoaded; } }