Skip to content

Instantly share code, notes, and snippets.

@EsteveSegura
Last active October 21, 2019 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EsteveSegura/7e28f3fe4ed74372b8d69ef66eb3415a to your computer and use it in GitHub Desktop.
Save EsteveSegura/7e28f3fe4ed74372b8d69ef66eb3415a to your computer and use it in GitHub Desktop.
instagram vot
const download = require('image-downloader')
const detectFood = require('./detectFood');
//download instagram post
async function downloadPost(ig,media_id){
try {
let postToDownload = await getMediaIdInfo(ig,media_id);
let downloadedData = await downloadImageFromUrl(postToDownload.items[0].image_versions2.candidates[0].url,media_id);
return downloadedData;
} catch (error) {
return 'cant_read';
}
}
//use package image-downloader for downloading images from the internet
async function downloadImageFromUrl (url,id){
const path = `./imgs/${id}.jpg`;
await download.image({url: url,dest: path});
return id;
}
//this way can call python vggModel.py
async function getPrediction(path){
let pred = await detectFood.getPrediction(path);
return pred;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment