Giter VIP home page Giter VIP logo

visual-recognition-nodejs's Introduction

๐Ÿš€ Visual Recognition Sample Application

This Node.js app demonstrates some of the Visual Recognition service features.

Travis semantic-release

DEPRECATED: this repo is no longer actively maintained. It can still be used as reference, but may contain outdated or unpatched code.

This demo application has been replaced by a newer version, and thus this repo has been deprecated. You can view the updated application running live here. The new application has not been made public yet, so in the meantime this repo can still be used as reference.

The Visual Recognition Service uses deep learning algorithms to analyze images for scenes, objects, faces, text, and other subjects that can give you insights into your visual content. You can organize image libraries, understand an individual image, and create custom classifiers for specific results that are tailored to your needs.

Prerequisites

  1. Sign up for an IBM Cloud account.
  2. Download the IBM Cloud CLI.
  3. Create an instance of the Visual Recognition service and get your credentials:
    • Go to the Visual Recognition page in the IBM Cloud Catalog.
    • Log in to your IBM Cloud account.
    • Click Create.
    • Click Show to view the service credentials.
    • Copy the apikey value.
    • Copy the url value.

Configuring the application

  1. In the application folder, copy the .env.example file and create a file called .env

    cp .env.example .env
    
  2. Open the .env file and add the service credentials that you obtained in the previous step.

    Example .env file that configures the apikey and url for a Visual Recognition service instance hosted in the US East region:

    VISUAL_RECOGNITION_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
    VISUAL_RECOGNITION_URL=https://gateway.watsonplatform.net/visual-recognition/api
    

Running locally

  1. Install the dependencies

    npm install
    
  2. Run the application

    npm start
    
  3. View the application in a browser at localhost:3000

Deploying to IBM Cloud as a Cloud Foundry Application

  1. Login to IBM Cloud with the IBM Cloud CLI

    ibmcloud login
    
  2. Target a Cloud Foundry organization and space.

    ibmcloud target --cf
    
  3. Edit the manifest.yml file. Change the name field to something unique.
    For example, - name: my-app-name.

  4. Deploy the application

    ibmcloud app push
    
  5. View the application online at the app URL.
    For example: https://my-app-name.mybluemix.net

Environment Variables

  • VISUAL_RECOGNITION_IAM_API_KEY : This is the IAM API key for the vision service, used if you don't have one in your IBM Cloud account.
  • PRESERVE_CLASSIFIERS : Set if you don't want classifiers to be deleted after one hour. (optional)
  • PORT : The port the server should run on. (optional, defaults to 3000)
  • OVERRIDE_CLASSIFIER_ID : Set to a classifer ID if you want to always use a custom classifier. This classifier will be used instead of training a new one. (optional)

Changing the Included Images

Sample Images

The sample images are the first 7 images when the site loads. They are called from a Jade mixin found in views/mixins/sampleImages.jade. If you just want to replace those images with different images, you can replace them in public/images/samples and they are numbered 1 - 7 and are jpg formatted.

Custom Classifier Bundles

Adding new/different custom classifer bundles is much more invovled. You can follow the template of the existing bundles found in views/includes/train.jade.

Or, you can train a custom classifier using the api or the form and then use the classifier ID.

Getting the Classifier ID

When you train a custom classifier, the name of the classifier is displayed in the test form.

Classifier ID Tooltip

If you hover your mouse over the classifier name, the classifier ID will be shown in the tooltip. You can also click on the name, and it will toggle between the classifier name and the classifier ID.

You can then use this custom classifier id by placing it after the hash in the request URL. For example, lets say you are running the system locally, so the base URL is http://localhost:3000 and then you train a classifier. This newly trained classifier might have an id like SatelliteImagery_859438478. If you wanted to use this classifier instead of training a new one, you can navigate to http://localhost:3000/train#SatelliteImagery_859438478 and use the training form with your existing classifier.

License

This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the IBM Github Page.

visual-recognition-nodejs's People

Contributors

andresfvilla avatar anirvan avatar beth avatar dentarg avatar ehdsouza avatar germanattanasio avatar greenkeeperio-bot avatar jeff-arn avatar jsstylos avatar jzhang300 avatar kcheat avatar kognate avatar kyleslachta avatar ldthorne avatar lhuihui avatar mamoonraja avatar nfriedly avatar ptitzler avatar sirspidey avatar vancevu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

visual-recognition-nodejs's Issues

visualRecognition. detectFaces method doesn't recognise key locally

According to the visualRecognition documentation there is a method called detectFaces which takes in similar parameters as the .classify() method.

const fs = require('fs'),
    VisualRecognitionV3 = require('watson-developer-cloud/visual-recognition/v3'),
    visualRecognition = new VisualRecognitionV3({
        api_key: '[MY_REAL_API_KEY]',
        version: '2016-05-20'
    });

const params = {
  images_file: fs.createReadStream('./peter.jpg')
};

visualRecognition.detectFaces(params, (err, res) => {
  if (err) {
    console.log(err);
  } else {
    console.log(JSON.stringify(res, null, 2));
  }
});

The classify works good when I send over a picture and returns JSON alright, when I try to use the .detectFaces() with the same parameters I get an error:

~/Git/watson-developer-cloud ๏ฃฟ node watsonImageRecognition.js 
{
  "status": "ERROR",
  "statusInfo": "invalid-api-key-permissions"
}

Am I missing something in the parameters to run this locally?
I tried exporting in the environment variable VISUAL_RECOGNITION_API_KEY=[MY_REAL_API_KEY]
but that did nothing also. It works fine with classify() just the detectFaces does nothing and asks for the API_KEY... any thoughts?

VR V3 don't deploy.

Visual Recognition don't deploy on my Bluemix. Generates error on the final of the process when was trying to upload something.

issues with npm start

When I run npm start, I get the following in the gitbash :
$ npm start

[email protected] start c:\BlueMix\visual-recognition-nodejs
node server.js

c:\BlueMix\visual-recognition-nodejs\node_modules\watson-developer-cloud\visual-recognition\v3.js:154
throw new Error('Argument error: api_key was not specified');
^

Error: Argument error: api_key was not specified
at VisualRecognitionV3.initCredentials (c:\BlueMix\visual-recognition-nodejs\node_modules\watson-developer-cloud\visual-recognition\v3.js:154:13)
at VisualRecognitionV3.BaseService (c:\BlueMix\visual-recognition-nodejs\node_modules\watson-developer-cloud\lib\base_service.js:45:18)
at new VisualRecognitionV3 (c:\BlueMix\visual-recognition-nodejs\node_modules\watson-developer-cloud\visual-recognition\v3.js:122:15)
at Object. (c:\BlueMix\visual-recognition-nodejs\app.js:39:25)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "c:\Program Files\nodejs\node.exe" "c:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the VisualRecognition package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs VisualRecognition
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls VisualRecognition
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! c:\BlueMix\visual-recognition-nodejs\npm-debug.log

I think perhaps I did step 7 wrong, which was not very clear. What should the .env file be called? I named it "process.env" and the following are its contents:

Environment variables

VISUAL_RECOGNITION_API_KEY=[snip]

TeaLeaf appears to broken

Alyssa has reported that the Tealeaf tracking in the demo appears to not be working. Don't have additional info at the moment.

Watson Vis Rec doesn't work

Hi. I am developing or trying to develop an app with Watson Visual Recognition scripts available on GitHub but that doesn't work on the Blue Mix environment. Follows attached prints. Someone saw something similar. I did all the manual's steps. Thanks in advance.

bluemix1
bluemix2
bluemix3

Strange behavior of Demo Classifier

Hi,

Let me share with you a strange behavior of the Demo Classifier in your application.

Select Dog Breeds and All categories (if you don't select all results are different and it works fine: no match). Then classify the following image https://i.ytimg.com/vi/8o44asJt8ZA/maxresdefault.jpg

The result classifies this image as a Dalmation!!!
error

Strange results with https://tse1.mm.bing.net/th?id=OIP.Ma5dddfee9cd0a3e59653cfb1a7547606o0&pid=15.1&P=0&w=300&h=81

Similar results with other images which are not dogs.
Similar results with other categories: Moleskine and Satellite (but different with Insurance Claim)

Chunk images for some browsers

Some browsers cannot handle loading hundreds of images at once and will consequently crash. However, it will not crash if images were loaded one chunk at a time.

The limit is around 55-57mb of data at a time.

EDIT:

Do browser detection, and generate message about browsers accordingly.

Getting error when trying to access JSON result

When clicking on the JSON button to see the raw json that is returned by the service, it opens a blank page and doesn't show anything.

When opening the browser console, I'm seeing the following error message:

https://visual-recognition-demo.mybluemix.net/js/bundle.js:543 Not allowed to navigate top frame to data URL: data:application/json,%7B%0A%20%22classes%22%3A%20%5B%0A%20%20%7B%0A%20%20%20%22class%22%3A%20%22chocolate%20chip%20pancakes%22%2C%0A%20%20%20%22score%22%3A%201%2C%0A%20%20%20%22type_hierarchy%22%3A%20%22%2Fsweet%20treat%2Fsweet%20cooked%20dough%2Fsweet%20pancakes%2Fchocolate%20chip%20pancakes%22%0A%20%20%7D%2C%0A%20%20%7B%0A%20%20%20%22class%22%3A%20%22sweet%20pancakes%22%2C%0A%20%20%20%22score%22%3A%201%0A%20%20%7D%2C%0A%20%20%7B%0A%20%20%20%22class%22%3A%20%22sweet%20cooked%20dough%22%2C%0A%20%20%20%22s...A%201%0A%20%20%7D%2C%0A%20%20%7B%0A%20%20%20%22class%22%3A%20%22sweet%20treat%22%2C%0A%20%20%20%22score%22%3A%201%0A%20%20%7D%2C%0A%20%20%7B%0A%20%20%20%22class%22%3A%20%22baked%20Alaska%22%2C%0A%20%20%20%22score%22%3A%200.5%2C%0A%20%20%20%22type_hierarchy%22%3A%20%22%2Fdessert%2Fbaked%20Alaska%22%0A%20%20%7D%2C%0A%20%20%7B%0A%20%20%20%22class%22%3A%20%22dessert%22%2C%0A%20%20%20%22score%22%3A%200.503%0A%20%20%7D%0A%20%5D%2C%0A%20%22classifier_id%22%3A%20%22food%22%2C%0A%20%22name%22%3A%20%22food%22%0A%7D
value @ https://visual-recognition-demo.mybluemix.net/js/bundle.js:543

I'm running Chrome Version 61.0.3163.100 (Official Build) (64-bit)

Integrate Web Workers

Integrating web workers can increase the performance of loading 1000+ images.

However, image resizing would no longer be using canvas and would have to implement my own resizing algorithm. Here is a JSFiddle Example.

Visual recog. demo text updates

Change, "Visual Recognition allows you to derive insights from an image based on its visual content. You can organize image libraries, understand an individual image, and create custom classifiers for specific results that are tailored to your needs."
to, "Visual Recognition partnered with Alchemy Vision, allows you to derive insights from an image based on its visual content. You can organize image libraries, understand an individual image, and create custom classifiers for specific results that are tailored to your needs."

Change, "These results are from AlchemyVision"
To, "Powered by AlchemyVision" (same font as "Drag from your computer" and nested right under the image)

Unable to Load .zip file for Classifier

I am trying to train Visual Recognition by loading zip files. When I attempt to load I receive an error message "You can only upload zipped archives of images". See the image in the attached file.
visual recognition error

I tried Winzip and Windows Explorer file compression. A representative zip file is attached.
Bridges.zip

I experience the same problem on the Visual Recognition demo site.

Image URL doesn't work

The "Paste image URL here" box does not deliver results.

Both on the "Try it" tab and the "Test" tab.

Example App Not working?

I've cloned the app with my own Watson credentials and It's unfortunately not working.

I keep getting the error :

Error processing the request. Please try again.

The JS console is telling me the server is throwing a 500 error.
I've gotten the same error on local and on the web app. 2013 MacBook Air.

zip files lead to 404 error

I was trying to download the 2 zip files towards the end and got 404 errors for both of them. Please update or send me the new links for the both of them

Make tests passable on pull requests

Some of our integration tests now require credentials. We store encrypted credentials in the .travis.yml file, but travis only decrypts these for commits and PRs from people with commit permissions on github. For PRs from other people, these are not decrypted and then the tests that require them fail (e.g. #107 )

Here are two possible options to resolve this:

  • Split out the tests that require credentials and skip them if credentials are not available (this is probably easier, it's what we do in the node SDK)
  • Mock the API server (the Speech JS SDK does this, it's a bit more work)

Sample requires to use the "Standard" plan

The README tells us to create the service with a "standard" plan:

cf create-service watson_vision_combined standard visual-recognition-service

The plan comes at a cost. Any way to have the sample use the "Free" plan?

VR V3 AlchemyAPI

Hi everybody . Is it still necessary in Visual Recognition V3 to use the Alchemy API and then set the environments variables in manual mode as fig. attached.
cfa96906-f684-11e5-9b2e-233753333f79

Page keeps refreshing in Safari

When using your website in Safari the page just keeps refreshing continuously. Very frustrating. I am using Safari 9.0.1.

can't retrain on the free plan

{ [Error: Cannot retrain a classifier under the free plan. ]
code: 400,
error: 'Cannot retrain a classifier under the free plan. ' } [ 'classifier_id', 'beagle_positive_examples' ] null

Deploy failing

I have tried master and the latest beta release, but both are failing to deploy on Bluemix.
This is a screenshot of the error on the application
screenshot from 2016-06-13 10-07-48
This is the log showing the only error. It's unfortunate that there isn't any reason why there is an error so I could try figuring this out on my own.
screenshot from 2016-06-13 10-08-43

Argument error

Hi, i followed the steps provided. but i hit this error when run it on cmd.

capture

! "Visual Recognition is not available right now..."

Team, I'm giving a demo to a major customer today at 2:30 today (4 hours from now) using visual recognition to identify damaged packages.

It was working a couple days ago. Today it doesn't.

I upload the same .zip files I used a couple days ago (less than 5MB with more than 50 images), let the blue wheel spin for 6 seconds, then get the error "Visual Recognition is not available right now..."

I get this error both on the standard demo instance (http://visual-recognition-demo.mybluemix.net/train) and my own (http://visual-recognition-nodejs-igarbo-2146.mybluemix.net/train).

screen shot 2016-10-06 at 9 54 03 am

good.zip
smashed.zip

Issue with manifest.yml file

The manifest.yml file is missing a ":" on line 3 of the declared-service name "visual-recognition-free"

    ---
declared-services:
  visual-recognition-free
    label: watson_vision_combined
    plan: free
applications:
- services:
  - visual-recognition-free
  name: visual-recognition-demo
  command: npm start
  path: .
  memory: 512M

Should be defined as the following:

    ---
declared-services:
  visual-recognition-free:
    label: watson_vision_combined
    plan: free
applications:
- services:
  - visual-recognition-free
  name: visual-recognition-demo
  command: npm start
  path: .
  memory: 512M

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.