-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathyolo-object-detection.html
139 lines (129 loc) · 5.64 KB
/
yolo-object-detection.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!--
Copyright 2020 T-Mobile USA, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
See the LICENSE file for additional language around the disclaimer of warranties.
Trademark Disclaimer: Neither the name of “T-Mobile, USA” nor the names of
its contributors may be used to endorse or promote products
-->
<script type="text/javascript">
RED.nodes.registerType('yolo-object-detection',{
category: 'function',
color: '#a6bbcf',
defaults: {
detectionServerPort: {value:"8888"},
name: {value:""},
modelName: {value:"yolov3"}
},
inputs:1,
outputs:1,
icon: "file.png",
label: function() {
return this.name||"yolo-object-detection";
},
oneditprepare: function() {
$("#node-input-model-name").val(this.modelName);
$("#node-config-lookup-models").click(function() {
$("#node-config-lookup-models").addClass('disabled');
$.getJSON('models',function(data) {
$("#node-config-lookup-models").removeClass('disabled');
var models = [];
$.each(data, function(i, model) {
models.push(model);
});
$("#node-input-model-name").autocomplete({
source:models,
minLength:0,
close: function( event, ui ) {
$("#node-input-model-name").autocomplete( "destroy" );
}
}).autocomplete("search","");
});
});
$('#node-config-upload-submit').click(function (e) {
var fd = new FormData();
var uploadFile = $('#node-config-upload-file')[0].files[0];
$("#node-config-upload-status").html(`Uploading file ${uploadFile.name}...`)
fd.append('file', uploadFile);
$.ajax({
url: '/models/upload',
data: fd,
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
success: function (data) {
$("#node-config-upload-status").html(`Uploaded file ${uploadFile.name}.`)
}
});
});
},
oneditsave: function() {
this.modelName = $("#node-input-model-name").val();
}
});
</script>
<script type="text/html" data-template-name="yolo-object-detection">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-model-name"><i class="fa fa-cogs"></i> Model Name</label>
<input type="text" id="node-input-model-name" style="width:70%;">
<a id="node-config-lookup-models" class="btn"><i id="node-config-lookup-models-icon" class="fa fa-search"></i></a>
</div>
<div class="form-row">
<label for="node-config-upload-file"><i class="fa fa-file-archive-o"></i> Upload Model</label>
<input type="file" id="node-config-upload-file" placeholder="Upload" style="display: inline">
<label for="node-config-upload-submit"> </label>
<input type="submit" id="node-config-upload-submit" value="Upload" name="Upload" style="width: auto;">
<span type="text" id="node-config-upload-status"></span>
</div>
</script>
<script type="text/html" data-help-name="yolo-object-detection">
<p>A simple node that converts camera input into a list of recognized objects, using the YOLO3 model.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>Name
<span class="property-type">string</span>
</dt>
<dd> Name of the node.
</dd>
<dt>Model Name
<span class="property-type">string</span>
</dt>
<dd> Searchable selection of available models. Defaults to yolov3 model.
Click on the magnifying glass search icon to see and select the
currently available models.
</dd>
<dt> Upload Model
</dt>
<dd> Upload custom model zip files you've built.
Click on the Choose File button to select a local model zip file.
Then click on Upload button to upload the model zip file.
You should then be able to select the model via the searchable Model Name
property for use in the flow.
The model zip file should contain the following folder/file structure.
<ul>
<li>model-name
<ul>
<li>anchors.txt</li>
<li>classes.txt</li>
<li>weights.h5</li>
</ul>
</li>
</ul>
Prebuilt zip packaged models for download are available
<a href="https://github.com/tmobile/node-red-contrib-yolo-object-detection/releases">here</a>.
</dd>
</dl>
</script>