Skip to content

Commit bc09893

Browse files
committed
Implement VR V4 Node
1 parent 8580f0c commit bc09893

3 files changed

Lines changed: 532 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"watson-text-to-speech-v1": "services/text_to_speech/v1.js",
5454
"watson-text-to-speech-corpus-builder-v1": "services/text_to_speech/v1-corpus-builder.js",
5555
"watson-tone-analyzer-v3": "services/tone_analyzer/v3.js",
56-
"watson-visual-recognition-v3": "services/visual_recognition/v3.js"
56+
"watson-visual-recognition-v3": "services/visual_recognition/v3.js",
57+
"watson-visual-recognition-collection-utils-v4": "services/visual_recognition/v4-collection-utils.js"
5758
}
5859
},
5960
"engines": {
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<!--
2+
Copyright 2020 IBM Corp.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
18+
<script type="text/x-red" data-template-name="visual-recognition-util-v4">
19+
<div class="form-row">
20+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
21+
<input type="text" id="node-input-name" placeholder="Name">
22+
</div>
23+
<div id="credentials-check" class="form-row">
24+
<div class="form-tips">
25+
<i class="fa fa-question-circle"></i><b> Please wait: </b> Checking for bound service credentials...
26+
</div>
27+
</div>
28+
<div class="form-row credentials" style="display: none;">
29+
<label for="node-input-apikey"><i class="fa fa-key"></i> API Key</label>
30+
<input type="password" id="node-input-apikey" placeholder="API Key">
31+
</div>
32+
<div class="form-row credentials">
33+
<label for="node-input-vr-service-endpoint"><i class="fa fa-tag"></i> Service Endpoint</label>
34+
<input type="text" id="node-input-vr-service-endpoint" placeholder="https://gateway.watsonplatform.net/visual-recognition/api">
35+
</div>
36+
37+
<div class="form-row">
38+
<label for="node-input-image-feature"><i class="fa fa-book"></i> Mode: </label>
39+
<select type="text" id="node-input-image-feature" style="display: inline-block; width: 70%;">
40+
<option value="createCollection">Create a collection</option>
41+
<option value="listCollections">List collections</option>
42+
<option value="getCollection">Get collection details</option>
43+
<option value="updateCollection">Update name or description of a collection</option>
44+
<option value="deleteCollection">Delete a collection</option>
45+
<option value="deleteAllCollections">Delete all collections</option>
46+
</select>
47+
</div>
48+
</script>
49+
50+
51+
<script type="text/javascript">
52+
53+
// Need to simulate a namespace, as some of the variables had started to leak across nodes
54+
function VISUALRECOGNITIONV4 () {
55+
}
56+
57+
// This is the namespace for VISUALRECOGNITIONV4. Currently only contains models, but more vars and functions may need to be
58+
// moved in if there is a clash with other nodes.
59+
var visualrecognitionv4 = new VISUALRECOGNITIONV4();
60+
visualrecognitionv4.language_selected = '';
61+
62+
// Save the values in the dynamic lists to the hidden fields.
63+
function oneditsave(){
64+
visualrecognitionv4.language_selected = $('#node-input-lang').val();
65+
}
66+
67+
(function() {
68+
RED.nodes.registerType('visual-recognition-util-v4', {
69+
category: 'IBM Watson',
70+
defaults: {
71+
name: {value: ""},
72+
'vr-service-endpoint' :{value: 'https://gateway.watsonplatform.net/visual-recognition/api'},
73+
"image-feature": {value: ""}
74+
},
75+
credentials: {
76+
apikey: {type:"password"}
77+
},
78+
color: 'rgb(228, 189, 200)',
79+
inputs: 1,
80+
outputs: 1,
81+
icon: "VR-v3-pink.png",
82+
paletteLabel: "visual recognition V4 collection utilities",
83+
label: function() {
84+
return this.name || "visual recognition V4 collection utilities";
85+
},
86+
labelStyle: function() {
87+
return this.name ? "node_label_italic" : "";
88+
},
89+
oneditprepare: function() {
90+
$.getJSON('watson-visual-recognition-v4/vcap/')
91+
.done(function (service) {
92+
$('.credentials').toggle(!service);
93+
})
94+
.fail(function () {
95+
$('.credentials').show();
96+
})
97+
.always(function () {
98+
$('#credentials-check').hide();
99+
})
100+
}
101+
});
102+
})();
103+
</script>
104+
105+
<script type="text/x-red" data-help-name="visual-recognition-util-v4">
106+
<p> This node enables you to use the training features of the Watson Visual Recognition service V4
107+
that aims to identify scenes and objects in images you upload to the service.
108+
Using this node you can create and train a custom classifier to identify subjects that suit
109+
your needs.</p>
110+
<p>The following features are available :</p>
111+
<ul>
112+
<li><b>Create a collection</b></li>
113+
<li><b>List listCollections</b></li>
114+
<li><b>Get collection details</b></li>
115+
<li><b>Update collection</b></li>
116+
<li><b>Delete collection</b></li>
117+
<li><b>Delete all collections</b></li>
118+
</ul>
119+
120+
<p>All Results will made available at <code>msg.payload</code></p>
121+
122+
<p><b>Create a collection</b></p>
123+
<p>this feature should be provided in input : </p>
124+
<ul>
125+
<li><code>msg.params["name"]</code> : The name of the collection (Required)</li>
126+
<li><code>msg.params["description"]</code> : The description of the collection (Required)</li>
127+
</ul>
128+
<p>More information on this
129+
<a href="https://cloud.ibm.com/apidocs/visual-recognition/visual-recognition-v4?code=node#create-a-collection">
130+
API documentation</a>.</p>
131+
132+
<p><b>List collections</b></p>
133+
<p>No input parameters are required : </p>
134+
<p>More information on this
135+
<a href="https://cloud.ibm.com/apidocs/visual-recognition/visual-recognition-v4?code=node#list-collections">
136+
API documentation</a>.</p>
137+
138+
<p><b>Get collection details</b></p>
139+
<p>this feature should be provided in input : </p>
140+
<ul>
141+
<li><code>msg.params["collectionId"]</code> : The identifier of the collection (Required)</li>
142+
</ul>
143+
<p>More information on this
144+
<a href="https://cloud.ibm.com/apidocs/visual-recognition/visual-recognition-v4?code=node#get-collection-details">
145+
API documentation</a>.</p>
146+
147+
<p><b>Update collection</b></p>
148+
<p>this feature should be provided in input : </p>
149+
<ul>
150+
<li><code>msg.params["collectionId"]</code> : The identifier of the collection (Required)</li>
151+
<li><code>msg.params["name"]</code> : The name of the collection (Optional)</li>
152+
<li><code>msg.params["description"]</code> : The description of the collection (Optional)</li>
153+
</ul>
154+
<p>More information on this
155+
<a href="https://cloud.ibm.com/apidocs/visual-recognition/visual-recognition-v4?code=node#get-collection-details">
156+
API documentation</a>.</p>
157+
158+
<p><b>Delete collection</b></p>
159+
<p>this feature should be provided in input : </p>
160+
<ul>
161+
<li><code>msg.params["collectionId"]</code> : The identifier of the collection (Required)</li>
162+
</ul>
163+
<p>More information on this
164+
<a href="https://cloud.ibm.com/apidocs/visual-recognition/visual-recognition-v4?code=node#update-a-collection">
165+
API documentation</a>.</p>
166+
167+
<p><b>Delete all collections</b></p>
168+
<p>No input parameters are required : </p>
169+
170+
171+
</script>

0 commit comments

Comments
 (0)