This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classifier.train(e => { | |
console.log(e) // "e" will be null once the training has finished | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const featureExtractor = ml5.featureExtractor('MobileNet', () => { | |
classifier = featureExtractor.classification( | |
document.querySelector('video'), | |
() => { | |
console.log("Video ready!") | |
} | |
) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loop = classifier => { | |
classifier.classify().then(results => { | |
setResult({ | |
label: results[0].label, | |
probability: results[0].confidence.toFixed(4) | |
}) | |
loop(classifier) // Call again to create a loop | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.mediaDevices | |
.getUserMedia({ | |
video: true | |
}) | |
.then(function(mediaStream) { | |
const video = document.querySelector('video') | |
video.srcObject = mediaStream | |
}) | |
.catch(function(err) { | |
console.warn('Error accessing camera') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>Ml5.js test</title> | |
<script src="https://unpkg.com/ml5@0.4.3/dist/ml5.min.js"></script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react' | |
import './image-classifier.scss' | |
const ImageClassifier = () => { | |
const [result, setResult] = useState({}) | |
const ml5 = window.ml5 | |
useEffect(() => { | |
// Initialize video element with camera input | |
navigator.getUserMedia( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'/users/{email}': | |
get: | |
tags: | |
- USERS | |
description: Returns the requested user | |
parameters: | |
- name: email | |
in: path | |
description: email of the requested user | |
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... non relevant require statements are omitted | |
const swaggerJsdoc = require('swagger-jsdoc') | |
const swaggerUi = require('swagger-ui-express') | |
const packageJson = require('../package.json') | |
const appVersion = packageJson.version | |
const appName = packageJson.name | |
const API_DOCS_PATH = path.resolve(__dirname, '../api.yaml') | |
const app = express() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(browser.alive){ | |
if(stack.empty && !queue.empty){ | |
stack.push(queue.next) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//No ejecutéis esto, por favor :) | |
let infinito = true | |
setTimeout(function() { | |
infinito = false | |
}, 10000) | |
while(infinito) { | |
console.log("todavía estoy aquí!", Date.now()) | |
} |
NewerOlder