Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@foyer-inc/insight-sdk

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foyer-inc/insight-sdk

SDK for connecting to Foyer's Insight service(s)

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
3
Weekly downloads
 
Created
Source

Foyer Insight

npm MIT License

Listed below is example usage of the insight-sdk

import { ClassifyResult, Insight } from "insight-sdk";

//can be initialized with authorization and other defaults or with nothing
const insight = new Insight() or new Insight(options)

const options = {
    // bypass login call by providing authorization
    // defaults to ''
    authorization: string,
    // run full model even if cached data exists for this image
    // defaults to false
    force: boolean,
     // must be true for class methods to function
     // defaults to false
    includeSegmentations: boolean,
    // returns tagpoints for location of detection
    // defaults to false
    includeTagpoints: boolean,
    // if only certain detections should be returned include them here
    // defaults to ['all']
    detectionsRequested: string[]
}
/*
* if not initialized with authorization string you may call login with
* credentials. The authorization token is returned and is also
* automatically added to your insight instance
*/
const authorization = await insight.login('email', 'password')

const url = 'https://myfakewebsite.com/myfakeimage.jpg'
const file = //base 64 encoded string representation of image
/*
*Below are example calls to the classification service
* you can use async/await or promise with a callback function
*/

const result: ClassifyResult = await insight.classify(url)

//Can include a variety of options
//options provided will overrule those set on the insight instance
const anotherResult: ClassifyResult = await insight.classify(url, options)

insight.classify(url)
    .then( (result: ClassifyResult) => {
        // additional work or call class methods
    });
}

// A sample of functions available on the result
// an image, as a base64 encoded string, with the requested detection blurred
const blurredImage = await result.blurDetection('detectionName')
// an image of the requested detection with a transparent background
const extractedImage = await result.extractDetection('detectionName')

// returns an array of shape [r,g,b] for the dominant color of the named detection
const color = await result.getDetectionColor('detectionName')
//can also be passed the already extracted detection
const anotherColor = await result.getDetectionColor(extractedImage)

//also possible to check if a detection exists in the result
//returns true or false if detection is present
const found = result.checkDetection('detectionName')
//returns true or false if all detections listed are present
const multipleFound = result.checkDetection(['detectionName', 'anotherDetectionName'])

FAQs

Package last updated on 23 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc