2020. június 21., vasárnap

// Get the 'deepai' package here (Compatible with browser & nodejs): // https://www.npmjs.com/package/deepai // All examples use JS async-await syntax, be sure to call the API inside an async function. // Learn more about async-await here: https://javascript.info/async-await // Example posting a image URL: const deepai = require('deepai'); // OR include deepai.min.js as a script tag in your HTML deepai.setApiKey('d72c58fa-c17d-4d89-bde6-d77d1173030d'); (async function() { var resp = await deepai.callStandardApi("colorizer", { image: "YOUR_IMAGE_URL", }); console.log(resp); })() // Example posting file picker input image (Browser only): const deepai = require('deepai'); // OR include deepai.min.js as a script tag in your HTML deepai.setApiKey('d72c58fa-c17d-4d89-bde6-d77d1173030d'); (async function() { var resp = await deepai.callStandardApi("colorizer", { image: document.getElementById('yourFileInputId'), }); console.log(resp); })() // Example posting a local image file (Node.js only): const fs = require('fs'); const deepai = require('deepai'); // OR include deepai.min.js as a script tag in your HTML deepai.setApiKey('d72c58fa-c17d-4d89-bde6-d77d1173030d'); (async function() { var resp = await deepai.callStandardApi("colorizer", { image: fs.createReadStream("/path/to/your/file.jpg"), }); console.log(resp); })()