Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"async-parallel": "^1.2.3",
"fast-glob": "^3.2.11",
"flickr-sdk": "^6.0.0",
"google-img-scrap": "^1.0.6",
"vue": "^2.7.14"
},
"engines": {
Expand Down
20 changes: 3 additions & 17 deletions tests/faces-tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Flickr = require('flickr-sdk')
const { GOOGLE_IMG_SCRAP , GOOGLE_QUERY } = require('google-img-scrap');
const download = require('download')
const flatten = require('lodash/flatten')
const execa = require('execa')
Expand All @@ -10,14 +9,15 @@ const LABELS = require('./res/famous_people.json')
const PHOTOS_PER_LABEL = 10
const PHOTOS_OLDER_THAN = 1627464319 // 2021-07-28; for determinism
const FACE_DISTANCE_THRESHOLD = 0.42
const flickr = new Flickr(process.env.FLICKR_API_KEY)

;(async function() {
const labels = LABELS.slice(0,20)
const negativeLabel = 'portrait'

await Parallel.each(labels, async label => {
try {
let urls = await findPhotosGoogle('"' + label + '"', PHOTOS_PER_LABEL)
let urls = await findPhotos(label, PHOTOS_PER_LABEL)
await Promise.all(
flatten(urls).map(url => download(url, 'temp_images/' + label))
)
Expand All @@ -28,7 +28,7 @@ const FACE_DISTANCE_THRESHOLD = 0.42
}, 1)

try {
let urls = await findPhotosGoogle(negativeLabel, PHOTOS_PER_LABEL * 3)
let urls = await findPhotos(negativeLabel, PHOTOS_PER_LABEL * 3)
await Promise.all(
flatten(urls).map(url => download(url, 'temp_images/' + negativeLabel))
)
Expand Down Expand Up @@ -136,20 +136,6 @@ function findPhotos(label, amount = PHOTOS_PER_LABEL) {
})
}

async function findPhotosGoogle(label, amount= PHOTOS_PER_LABEL) {
console.log('GOOGLE search: '+label)
const results = await GOOGLE_IMG_SCRAP({
search: label,
query: {
EXTENSION: GOOGLE_QUERY.EXTENSION.JPG,
SIZE: GOOGLE_QUERY.SIZE.LARGE,
},
limit: amount,
});

return results.result.map(i => i.url)
}

function addVectors(a, b) {
return a.map((el, i) => el + b[i])
}
Expand Down
14 changes: 0 additions & 14 deletions tests/landmarks-tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Flickr = require('flickr-sdk')
const { GOOGLE_IMG_SCRAP , GOOGLE_QUERY } = require('google-img-scrap');
const download = require('download')
const uniq = require('lodash/uniq')
const flatten = require('lodash/flatten')
Expand Down Expand Up @@ -100,16 +99,3 @@ function findPhotos(label, amount = PHOTOS_PER_LABEL) {
throw err
})
}

async function findPhotosGoogle(label, amount= PHOTOS_PER_LABEL) {
console.log('GOOGLE search: '+label)
const results = await GOOGLE_IMG_SCRAP({
search: label,
query: {
EXTENSION: GOOGLE_QUERY.EXTENSION.JPG
},
limit: amount,
});

return results.result.map(i => i.url)
}
Loading