Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update method for safe search detection #533

Closed
aliciawilliams opened this issue Dec 11, 2017 · 1 comment
Closed

Update method for safe search detection #533

aliciawilliams opened this issue Dec 11, 2017 · 1 comment

Comments

@aliciawilliams
Copy link

aliciawilliams commented Dec 11, 2017

The method for safe search detection has been changed. I made a few changes to the code in order to complete this tutorial: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/functions/imagemagick/index.js. This is my first Github contribution (ever), so let me know if/how to proceed.

  1. Added new const request immediately after the const file declaration.
const request = {
    source: {
      imageUri: `gs://${object.bucket}/${file.name}`
    }
  };
  1. Changed method name in line 44 from vision.detectSafeSearch(file) to vision.safeSearchDetection(request)
  2. Updated the evaluation for determining an inappropriate image to account for new format of JSON response. Now looks for adult and violence outcomes of VERY_LIKELY or LIKELY.
.then((results) => {
      const detections = results[0].safeSearchAnnotation;
      if (detections.adult == 'VERY_LIKELY' || detections.adult == 'LIKELY' || detections.violence == 'VERY_LIKELY' || detections.violence == 'LIKELY') {
        console.log(`The image ${file.name} has been detected as inappropriate.`);
        return blurImage(file);
      } else {
        console.log(`The image ${file.name} has been detected as OK.`);
      }
    });
```javascript
@fhinkel
Copy link
Contributor

fhinkel commented Nov 8, 2018

Closed due to inactivity. Feel free to reopen if needed.

@fhinkel fhinkel closed this as completed Nov 8, 2018
NimJay pushed a commit that referenced this issue Nov 19, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
NimJay pushed a commit that referenced this issue Nov 19, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants