Socket
Socket
Sign inDemoInstall

roboflow

Package Overview
Dependencies
244
Maintainers
8
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.13 to 0.0.14

80

cli/commands/upload.js
const fs = require("fs");
const path = require("path");
const pLimit = require("p-limit");

@@ -7,2 +8,33 @@ const { selectProjectFromWorkspace, getApiKeyWorWorkspace } = require("../core.js");

async function uploadWithAnnotation(f, annotationFilename, projectUrl, apiKey, extraOptions) {
const uploadResult = await api.uploadImage(f, projectUrl, apiKey, extraOptions);
const imageId = uploadResult.id;
if (annotationFilename.includes("[filename]")) {
annotationFilename = annotationFilename.replace("[filename]", path.parse(f).name);
}
if (fs.existsSync(annotationFilename)) {
const annotationResult = await api.uploadAnnotation(
imageId,
annotationFilename,
projectUrl,
apiKey
);
console.log(` ${f} uploaded: `, uploadResult);
console.log(" annotation upload:", annotationResult);
} else {
console.log(` ${f} uploaded: `, uploadResult);
console.log(
` cant stat annotation file: '${annotationFilename}'. image uploaded without annotation`
);
return;
}
}
async function uploadSimple(f, projectUrl, apiKey, extraOption) {
const result = await api.uploadImage(f, projectUrl, apiKey, extraOptions);
console.log(" image uploaded:", result);
}
async function uploadImage(args, options) {

@@ -34,39 +66,27 @@ const workspaceUrl = options.workspace;

if (options.annotation) {
for (var f of args) {
// console.log("upload:", f, projectUrl, apiKey, extraOptions);
const uploadResult = await api.uploadImage(f, projectUrl, apiKey, extraOptions);
console.log("image uploaded: ", uploadResult);
const imageId = uploadResult.id;
let concurrency = 10;
if (options.concurrent) {
concurrency = parseInt(options.concurrent);
}
let annotationFilename = options.annotation;
const uploadPromises = [];
if (annotationFilename.includes("[filename]")) {
annotationFilename = annotationFilename.replace("[filename]", path.parse(f).name);
}
const limit = pLimit(concurrency);
if (fs.existsSync(annotationFilename)) {
const annotationResult = await api.uploadAnnotation(
imageId,
annotationFilename,
projectUrl,
apiKey
);
console.log("annotation uploaded:", annotationResult);
} else {
console.log(
`cant stat annotation file: '${annotationFilename}'. image uplaoded without annotation`
);
continue;
}
if (options.annotation) {
for (let f of args) {
const p = limit(() =>
uploadWithAnnotation(f, options.annotation, projectUrl, apiKey, extraOptions)
);
uploadPromises.push(p);
}
} else {
// console.log("upload unanotated", args, options);
for (var f of args) {
// console.log("upload:", f, projectUrl, apiKey, extraOptions);
const result = await api.uploadImage(f, projectUrl, apiKey, extraOptions);
console.log("image uplaoded:", result);
for (let f of args) {
const p = limit(() => uploadSimple(f, projectUrl, apiKey, extraOptions));
uploadPromises.push(p);
}
}
await Promise.all(uploadPromises);
}

@@ -73,0 +93,0 @@

@@ -123,3 +123,3 @@ #! /usr/bin/env node

)
.option("-c --concurrent [n]", "how many image uploads to perform concurrently", 10)
.argument("<files...>")

@@ -126,0 +126,0 @@ .option("-b --batch <batch>", "specify a batch to add the uploaded image to")

{
"name": "roboflow",
"version": "0.0.13",
"version": "0.0.14",
"description": "Roboflow.ai node module and CLI tools",
"main": "index.js",
"scripts": {
},
"scripts": {},
"repository": {

@@ -26,2 +24,3 @@ "type": "git",

"open": "^8.4.0",
"p-limit": "^3.1.0",
"terminal-link": "^2.1.1"

@@ -28,0 +27,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc