aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/tf_image_dashboard/tf-image-dashboard.html
blob: 0700a8c0e7622a35355315132511a8cd69a39ef1 (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
<!--
@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-dialog/paper-dialog.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../tf-backend/tf-backend.html">
<link rel="import" href="../tf-color-scale/tf-color-scale.html">
<link rel="import" href="../tf-dashboard-common/tf-dashboard.html">
<link rel="import" href="../tf-dashboard-common/tf-panes-helper.html">
<link rel="import" href="../tf-dashboard-common/tf-sidebar-helper.html">
<link rel="import" href="tf-image-loader.html">

<!--
tf-image-dashboard displays a dashboard that loads images from a TensorFlow run.
-->
<dom-module id="tf-image-dashboard">
  <template>
    <paper-dialog with-backdrop id="actual-image-size-dialog"></paper-dialog>
    <div id="plumbing">
      <tf-color-scale
        id="colorScale"
        runs="[[runs]]"
        out-color-scale="{{_colorScale}}"
        ></tf-color-scale>
    </div>

    <tf-dashboard-layout>
      <div class="sidebar">
        <tf-sidebar-helper
          backend="[[backend]]"
          categories="{{_categories}}"
          color-scale="[[_colorScale]]"
          run2tag="[[run2tag]]"
          runs="[[runs]]"
          selected-runs="{{_selectedRuns}}"
          >
        </tf-sidebar-helper>
      </div>
      <div class="center">
        <tf-panes-helper
          categories="[[_categories]]"
          color-scale="[[_colorScale]]"
          data-type="[[dataType]]"
          data-provider="[[dataProvider]]"
          data-not-found="[[dataNotFound]]"
          run2tag="[[run2tag]]"
          selected-runs="[[_selectedRuns]]"
          repeat-for-runs
          >
          <template>
            <tf-image-loader color-scale="[[_colorScale]]"></tf-image-loader>
            <paper-icon-button
              class="actual-size-button"
              icon="aspect-ratio"
              on-tap="_showActualSize"
              title="Show the image at its true pixel size"
              ></paper-icon-button>
          </template>
        </tf-panes-helper>
      </div>
    </tf-dashboard-layout>
    <style include="dashboard-style"></style>
    <style>
      tf-panes-helper {
        --card-width: 340px;
        --card-height: auto;
        --card-expanded-width: 700px;
        --card-expanded-height: auto;
      }

      .actual-size-button {
        background: #fff;
        border-radius: 100%;
        bottom: -35px;
        color: #2196f3;
        height: 32px;
        left: 35px;
        padding: 4px;
        pointer-events: auto;
        position: absolute;
        width: 32px;
      }

      .actual-size-button-selected {
        background: var(--tb-ui-light-accent);
      }

      #actual-image-size-dialog {
        overflow: auto;
      }
    </style>
  </template>
  <script>
    TF.Dashboard.TfImageDashboard = Polymer({
      is: "tf-image-dashboard",
      factoryImpl: function(backend) {
        this.backend = backend;
      },
      properties: {
        backend: Object,
        dataType: {
          type: String,
          value: "image"
        },
      },
      behaviors: [
        TF.Dashboard.DashboardBehavior("images"),
        TF.Dashboard.ReloadBehavior("tf-chart-scaffold"),
        TF.Backend.BackendBehavior,
      ],
      attached: function() {
        this.async(function() {
          this.fire("rendered");
        });
      },
      _showActualSize: function(e) {
        var currentTarget = Polymer.dom(e.currentTarget);
        var card = currentTarget.node.closest('.card');

        // Create a full-size copy of the image.
        var newImage = card.querySelector('#img').cloneNode();
        newImage.style.height = 'auto';
        newImage.style.width = 'auto';
        newImage.style.margin = 0;
        newImage.style.padding = 0;
        newImage.classList.add("actual-size-image");

        // When the user clicks on the image, empty and close the dialog.
        var dialog = this.$$('#actual-image-size-dialog');
        newImage.addEventListener('click', function() {
          dialog.close();
        });

        // Update dialog content. Show the dialog.
        dialog.innerHTML = '';
        dialog.appendChild(newImage);
        dialog.open();
      }
    });
  </script>
</dom-module>