MCPcopy Create free account
hub / github.com/JustinBeckwith/cloudcats / annotate

Function annotate

worker/vision.js:13–39  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

11const bucket = storage.bucket(bucketName);
12
13async function annotate(url) {
14 const name = uuid.v4();
15 const file = bucket.file(name);
16
17 const response = await request({
18 url,
19 responseType: 'stream'
20 });
21 if (!response.data) {
22 throw new Error('Response failed to return data.');
23 }
24
25 await new Promise(resolve => {
26 response.data
27 .pipe(file.createWriteStream())
28 .on('finish', () => {
29 resolve();
30 });
31 });
32
33 const labels = await vision.labelDetection(`gs://${bucketName}/${name}`);
34 file.delete();
35 return {
36 url,
37 labels: labels[0].labelAnnotations.map(x => x.description)
38 };
39}
40
41const api = {
42 annotate

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected