aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/vz_projector/vz-projector-data-panel.html
blob: d8dfd6e978c489ff78f5ad15b44808e8da679f03 (plain)
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<!--
@license
Copyright 2016 The TensorFlow Authors. All Rights Reserved.

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.
-->

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-input/paper-textarea.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../paper-dialog/paper-dialog.html">
<link rel="import" href="../paper-dialog-scrollable/paper-dialog-scrollable.html">
<link rel="import" href="../paper-tooltip/paper-tooltip.html">
<link rel="import" href="../tf-imports/d3.html">
<link rel="import" href="vz-projector-legend.html">
<link rel="import" href="styles.html">
<link rel="import" href="bundle.html">

<dom-module id="vz-projector-data-panel">
<template>
<style include="vz-projector-styles"></style>
<style>
.container {
  padding: 10px 20px 20px 20px;
}

input[type=file] {
  display: none;
}

.file-name {
  margin-right: 10px;
}

.dirs {
  color: rgba(0, 0, 0, 0.7);
  font-size: 12px;
}

.dirs table tr {
  vertical-align: top;
}

.dirs table tr td {
  padding-bottom: 10px;
}

paper-item {
  --paper-item-disabled: {
    border-bottom: 1px solid black;
    justify-content: center;
    font-size: 12px;
    line-height: normal;
    min-height: 0px;
  };
}

.item-details {
  margin-left: 5px;
  color: gray;
  font-size: 12px;
}

paper-dropdown-menu {
  width: 100%;
}

paper-dropdown-menu paper-item {
  justify-content: space-between;
}

.title {
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  color: black;
  display: flex;
  font-weight: 500;
  height: 59px;
  padding-left: 20px;
}

#normalize-data-checkbox {
  margin: 10px 0;
}

#projector-config-template {
  --paper-input-container-input: {
    line-height: 13px;
    font-family: monospace;
    font-size: 12px;
  };
}

#generate-share-url {
  padding: 16px;
  margin-left: 24px;
}

#projector-share-button-container {
  margin: 10px 0;
}

.config-checkbox {
  display: inline-block;
  font-size: 11px;
  margin-left: 10px;
}

.projector-config-options {
  margin-top: 12px;
}

.projector-config-dialog-container {
  padding: 24px;
}

.code {
  background-color: #f7f7f7;
  display: table;
  font-family: monospace;
  margin-top: 7px;
  padding: 15px;
}

.delimiter {
  color: #B71C1C;
}

.upload-step {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.upload-step paper-button {
  margin-left: 30px;
}

.step-label {
  color: rgb(38, 180, 226);
}

.scrollable-container {
  margin-top: 0;
  min-width: 400px;
}

#projectorConfigDialog p {
  margin: 8px 0 8px;
}

.data-step {
  margin-top: 40px;
}

.data-step-contents {
  display: table;
  width: 100%;
}

.data-step-contents-contents {
  display: table-cell;
  margin-top: 6px;
}

.data-step-contents-upload {
  display: table-cell;
  text-align: right;
  vertical-align: bottom;
}

#demo-data-buttons-container {
  display: none;
}

.colorby-container {
  margin-bottom: 10px;
}
</style>
<div class="title">DATA</div>
<div class="container">
  <!-- List of runs -->
  <template is="dom-if" if="[[_hasChoices(runNames)]]">
    <paper-dropdown-menu no-animations label="[[_getNumRunsLabel(runNames)]] found">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedRun}}">
        <template is="dom-repeat" items="[[runNames]]">
          <paper-item value="[[item]]" label="[[item]]">
            [[item]]
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
  </template>

  <template is="dom-if" if="[[tensorNames]]">
    <!-- List of tensors in checkpoint -->
    <paper-dropdown-menu no-animations label="[[_getNumTensorsLabel(tensorNames)]] found">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedTensor}}">
        <template is="dom-repeat" items="[[tensorNames]]">
          <paper-item value="[[item.name]]" label="[[item.name]]">
            [[item.name]]
            <span class="item-details">
              [[item.shape.0]]x[[item.shape.1]]
            </span>
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
  </template>
  <!-- Label by -->
  <template is="dom-if" if="[[_hasChoices(labelOptions)]]">
    <paper-dropdown-menu no-animations label="Label by">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedLabelOption}}">
        <template is="dom-repeat" items="[[labelOptions]]">
          <paper-item value="[[item]]" label="[[item]]">
            [[item]]
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
  </template>

  <!-- Color by -->
  <div hidden$="[[!_hasChoices(colorOptions)]]" class="colorby-container">
    <paper-dropdown-menu id="colorby" no-animations label="Color by">
      <paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedColorOptionName}}">
        <template is="dom-repeat" items="[[colorOptions]]">
          <paper-item class$="[[getSeparatorClass(item.isSeparator)]]" value="[[item.name]]" label="[[item.name]]" disabled="[[item.isSeparator]]">
            [[item.name]]
            <span class="item-details">[[item.desc]]</span>
          </paper-item>
        </template>
      </paper-listbox>
    </paper-dropdown-menu>
    <div hidden$="[[!showForceCategoricalColorsCheckbox]]">
      <paper-checkbox id="force-categorical-checkbox"></paper-checkbox>
      Use categorical coloring
      <paper-icon-button icon="help" class="help-icon"></paper-icon-button>
      <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds>
        For metadata fields that have many unique values we use a gradient color map
        by default. This checkbox allows you to force categorical coloring by a given
        metadata field.
      </paper-tooltip>
    </div>
    <template dom-if="[[colorLegendRenderInfo]]">
      <vz-projector-legend render-info="[[colorLegendRenderInfo]]"></vz-projector-legend>
    </template>
  </div>
  <paper-checkbox id="normalize-data-checkbox" checked="{{normalizeData}}">
    Sphereize data
    <paper-icon-button icon="help" class="help-icon"></paper-icon-button>
    <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds>
      The data is normalized by shifting each point by the centroid and making
      it unit norm.
    </paper-tooltip>
  </paper-checkbox>
  <p id="demo-data-buttons-container">
    <span>
      <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds>
        Load data from your computer
      </paper-tooltip>
      <paper-button id="upload" class="ink-button" onclick="dataDialog.open()">Load data</paper-button>
    </span>
    <span id="publish-container">
      <paper-tooltip position="bottom" animation-delay="0" fit-to-visible-bounds>
        Publish your embedding visualization and data
      </paper-tooltip>
      <paper-button id="host-embedding" class="ink-button" onclick="projectorConfigDialog.open()">Publish</paper-button>
    </span>
  </p>
  <div>
    <paper-dialog id="dataDialog" with-backdrop>
      <h2>Load data from your computer</h2>
      <paper-dialog-scrollable class="scrollable-container">
        <div class="data-step" id="upload-tensors-step-container">
          <div class="upload-step">
            <div>
                <b><span class="step-label">Step 1:</span> Load a TSV file of vectors.</b>
            </div>
          </div>
          <div class="data-step-contents">
            <div class="data-step-contents-contents">
              Example of 3 vectors with dimension 4:
              <div class="code">
                0.1<span class="delimiter">\t</span>0.2<span class="delimiter">\t</span>0.5<span class="delimiter">\t</span>0.9<br/>
                0.2<span class="delimiter">\t</span>0.1<span class="delimiter">\t</span>5.0<span class="delimiter">\t</span>0.2<br/>
                0.4<span class="delimiter">\t</span>0.1<span class="delimiter">\t</span>7.0<span class="delimiter">\t</span>0.8
              </div>
            </div>
            <div class="data-step-contents-upload">
              <paper-button id="upload-tensors" title="Choose a TSV tensor file">Choose file</paper-button>
              <input type="file" id="file" name="file"/>
            </div>
          </div>
        </div>
        <div class="data-step">
          <div class="upload-step">
            <div>
                <span class="step-label" id="upload-metadata-label"><b>Step 2</b> (optional):</span> <b>Load a TSV file of metadata.</b>
            </div>
          </div>
          <div class="data-step-contents">
            <div class="data-step-contents-contents">
              Example of 3 data points and 2 columns.<br/>
              <i>Note: If there is more than one column, the first row will be parsed as column labels.</i>
              <div class="code">
                <b>Pokémon<span class="delimiter">\t</span>Species</b><br/>
                Wartortle<span class="delimiter">\t</span>Turtle<br/>
                Venusaur<span class="delimiter">\t</span>Seed<br/>
                Charmeleon<span class="delimiter">\t</span>Flame
              </div>
            </div>
            <div class="data-step-contents-upload">
              <paper-button id="upload-metadata" title="Choose a TSV metadata file" class="ink-button">Choose file</paper-button>
              <input type="file" id="file-metadata" name="file-metadata"/>
            </div>
          </div>
        </div>
      </paper-dialog-scrollable>
      <div class="dismiss-dialog-note">Click outside to dismiss.</div>
    </paper-dialog>
    <paper-dialog id="projectorConfigDialog" with-backdrop>
      <h2>Publish your embedding visualization and data</h2>
      <paper-dialog-scrollable class="scrollable-container">
        <div>
          <p>
            If you'd like to share your visualization with the world, follow these simple steps.
            See <a target=_blank href="https://www.tensorflow.org/get_started/embedding_viz">this tutorial</a> for more.
          </p>
          <h4><span class="step-label">Step 1:</span> Make data public</h4>
          <p>
            Host tensors, metadata, sprite image, and bookmarks TSV files <i>publicly</i> on the web.
          </p>
          <p>
            One option is using a <a target=_blank href="https://gist.github.com/">github gist</a>.
            If you choose this approach, make sure to link directly to the raw file.
          </p>
        </div>
        <div>
          <h4><span class="step-label">Step 2:</span> Projector config</h4>
          <div class="projector-config-options">
            <i>Optional:</i>
            <div class="config-checkbox">
              <paper-checkbox id="config-metadata-checkbox" checked>Metadata</paper-checkbox>
            </div>
            <div class="config-checkbox">
              <paper-checkbox id="config-sprite-checkbox">Sprite</paper-checkbox>
            </div>
            <div class="config-checkbox">
              <paper-checkbox id="config-bookmarks-checkbox">Bookmarks</paper-checkbox>
            </div>
          </div>
        </div>
        <paper-textarea id="projector-config-template" label="template_projector_config.json"></paper-textarea>
        <div>
          <h4><span class="step-label">Step 3:</span> Host projector config</h4>
          After you have hosted the projector config JSON file you built above, paste the URL to the config below.
        </div>
        <paper-input id="projector-config-url" label="Path to projector config"></paper-input>
        <paper-input id="projector-share-url" label="Your shareable URL" readonly></paper-input>
        <div id="projector-share-button-container">
          <a target=_blank id="projector-share-url-link">
            <paper-button title="Test your shareable URL" class="ink-button">Test your shareable URL</paper-button>
          </a>
        </div>
      </paper-dialog-scrollable>
      <div class="dismiss-dialog-note">Click outside to dismiss.</div>
    </paper-dialog>
  </div>
  <div class="dirs">
    <table>
      <tr>
        <td>Checkpoint:</td>
        <td><span id="checkpoint-file"></span></td>
      </tr>
      <tr>
        <td>Metadata:</td>
        <td><span id="metadata-file"></span></td>
      </tr>
    </table>
  </div>
</div>
<!-- Closing global template -->
</template>
<script src="vz-projector-data-panel.js"></script>
</dom-module>