tensorbored 2.21.0rc1769983804__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tensorbored/__init__.py +112 -0
- tensorbored/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/__init__.py +125 -0
- tensorbored/_vendor/bleach/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/__init__.py +35 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_ihatexml.py +289 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_inputstream.py +918 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_tokenizer.py +1735 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/__init__.py +5 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/_base.py +40 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/py.py +67 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_utils.py +159 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/constants.py +2946 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/alphabeticalattributes.py +29 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/base.py +12 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/inject_meta_charset.py +73 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/lint.py +93 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/optionaltags.py +207 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/sanitizer.py +916 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/whitespace.py +38 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/html5parser.py +2795 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/serializer.py +409 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/__init__.py +30 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/genshi.py +54 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/sax.py +50 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/__init__.py +88 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/base.py +417 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/dom.py +239 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree.py +343 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree_lxml.py +392 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/__init__.py +154 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/base.py +252 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/dom.py +43 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree.py +131 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree_lxml.py +215 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/genshi.py +69 -0
- tensorbored/_vendor/bleach/_vendor/parse.py +1078 -0
- tensorbored/_vendor/bleach/callbacks.py +32 -0
- tensorbored/_vendor/bleach/html5lib_shim.py +757 -0
- tensorbored/_vendor/bleach/linkifier.py +633 -0
- tensorbored/_vendor/bleach/parse_shim.py +1 -0
- tensorbored/_vendor/bleach/sanitizer.py +638 -0
- tensorbored/_vendor/bleach/six_shim.py +19 -0
- tensorbored/_vendor/webencodings/__init__.py +342 -0
- tensorbored/_vendor/webencodings/labels.py +231 -0
- tensorbored/_vendor/webencodings/mklabels.py +59 -0
- tensorbored/_vendor/webencodings/x_user_defined.py +325 -0
- tensorbored/assets.py +36 -0
- tensorbored/auth.py +102 -0
- tensorbored/backend/__init__.py +0 -0
- tensorbored/backend/application.py +604 -0
- tensorbored/backend/auth_context_middleware.py +38 -0
- tensorbored/backend/client_feature_flags.py +113 -0
- tensorbored/backend/empty_path_redirect.py +46 -0
- tensorbored/backend/event_processing/__init__.py +0 -0
- tensorbored/backend/event_processing/data_ingester.py +276 -0
- tensorbored/backend/event_processing/data_provider.py +535 -0
- tensorbored/backend/event_processing/directory_loader.py +142 -0
- tensorbored/backend/event_processing/directory_watcher.py +272 -0
- tensorbored/backend/event_processing/event_accumulator.py +950 -0
- tensorbored/backend/event_processing/event_file_inspector.py +463 -0
- tensorbored/backend/event_processing/event_file_loader.py +292 -0
- tensorbored/backend/event_processing/event_multiplexer.py +521 -0
- tensorbored/backend/event_processing/event_util.py +68 -0
- tensorbored/backend/event_processing/io_wrapper.py +223 -0
- tensorbored/backend/event_processing/plugin_asset_util.py +104 -0
- tensorbored/backend/event_processing/plugin_event_accumulator.py +721 -0
- tensorbored/backend/event_processing/plugin_event_multiplexer.py +522 -0
- tensorbored/backend/event_processing/reservoir.py +266 -0
- tensorbored/backend/event_processing/tag_types.py +29 -0
- tensorbored/backend/experiment_id.py +71 -0
- tensorbored/backend/experimental_plugin.py +51 -0
- tensorbored/backend/http_util.py +263 -0
- tensorbored/backend/json_util.py +70 -0
- tensorbored/backend/path_prefix.py +67 -0
- tensorbored/backend/process_graph.py +74 -0
- tensorbored/backend/security_validator.py +202 -0
- tensorbored/compat/__init__.py +69 -0
- tensorbored/compat/proto/__init__.py +0 -0
- tensorbored/compat/proto/allocation_description_pb2.py +35 -0
- tensorbored/compat/proto/api_def_pb2.py +82 -0
- tensorbored/compat/proto/attr_value_pb2.py +80 -0
- tensorbored/compat/proto/cluster_pb2.py +58 -0
- tensorbored/compat/proto/config_pb2.py +271 -0
- tensorbored/compat/proto/coordination_config_pb2.py +45 -0
- tensorbored/compat/proto/cost_graph_pb2.py +87 -0
- tensorbored/compat/proto/cpp_shape_inference_pb2.py +70 -0
- tensorbored/compat/proto/debug_pb2.py +65 -0
- tensorbored/compat/proto/event_pb2.py +149 -0
- tensorbored/compat/proto/full_type_pb2.py +74 -0
- tensorbored/compat/proto/function_pb2.py +157 -0
- tensorbored/compat/proto/graph_debug_info_pb2.py +111 -0
- tensorbored/compat/proto/graph_pb2.py +41 -0
- tensorbored/compat/proto/histogram_pb2.py +39 -0
- tensorbored/compat/proto/meta_graph_pb2.py +254 -0
- tensorbored/compat/proto/node_def_pb2.py +61 -0
- tensorbored/compat/proto/op_def_pb2.py +81 -0
- tensorbored/compat/proto/resource_handle_pb2.py +48 -0
- tensorbored/compat/proto/rewriter_config_pb2.py +93 -0
- tensorbored/compat/proto/rpc_options_pb2.py +35 -0
- tensorbored/compat/proto/saved_object_graph_pb2.py +193 -0
- tensorbored/compat/proto/saver_pb2.py +38 -0
- tensorbored/compat/proto/step_stats_pb2.py +116 -0
- tensorbored/compat/proto/struct_pb2.py +144 -0
- tensorbored/compat/proto/summary_pb2.py +111 -0
- tensorbored/compat/proto/tensor_description_pb2.py +38 -0
- tensorbored/compat/proto/tensor_pb2.py +68 -0
- tensorbored/compat/proto/tensor_shape_pb2.py +46 -0
- tensorbored/compat/proto/tfprof_log_pb2.py +307 -0
- tensorbored/compat/proto/trackable_object_graph_pb2.py +90 -0
- tensorbored/compat/proto/types_pb2.py +105 -0
- tensorbored/compat/proto/variable_pb2.py +62 -0
- tensorbored/compat/proto/verifier_config_pb2.py +38 -0
- tensorbored/compat/proto/versions_pb2.py +35 -0
- tensorbored/compat/tensorflow_stub/__init__.py +38 -0
- tensorbored/compat/tensorflow_stub/app.py +124 -0
- tensorbored/compat/tensorflow_stub/compat/__init__.py +131 -0
- tensorbored/compat/tensorflow_stub/compat/v1/__init__.py +20 -0
- tensorbored/compat/tensorflow_stub/dtypes.py +692 -0
- tensorbored/compat/tensorflow_stub/error_codes.py +169 -0
- tensorbored/compat/tensorflow_stub/errors.py +507 -0
- tensorbored/compat/tensorflow_stub/flags.py +124 -0
- tensorbored/compat/tensorflow_stub/io/__init__.py +17 -0
- tensorbored/compat/tensorflow_stub/io/gfile.py +1011 -0
- tensorbored/compat/tensorflow_stub/pywrap_tensorflow.py +285 -0
- tensorbored/compat/tensorflow_stub/tensor_shape.py +1035 -0
- tensorbored/context.py +129 -0
- tensorbored/data/__init__.py +0 -0
- tensorbored/data/grpc_provider.py +365 -0
- tensorbored/data/ingester.py +46 -0
- tensorbored/data/proto/__init__.py +0 -0
- tensorbored/data/proto/data_provider_pb2.py +517 -0
- tensorbored/data/proto/data_provider_pb2_grpc.py +374 -0
- tensorbored/data/provider.py +1365 -0
- tensorbored/data/server_ingester.py +301 -0
- tensorbored/data_compat.py +159 -0
- tensorbored/dataclass_compat.py +224 -0
- tensorbored/default.py +124 -0
- tensorbored/errors.py +130 -0
- tensorbored/lazy.py +99 -0
- tensorbored/main.py +48 -0
- tensorbored/main_lib.py +62 -0
- tensorbored/manager.py +487 -0
- tensorbored/notebook.py +441 -0
- tensorbored/plugin_util.py +266 -0
- tensorbored/plugins/__init__.py +0 -0
- tensorbored/plugins/audio/__init__.py +0 -0
- tensorbored/plugins/audio/audio_plugin.py +229 -0
- tensorbored/plugins/audio/metadata.py +69 -0
- tensorbored/plugins/audio/plugin_data_pb2.py +37 -0
- tensorbored/plugins/audio/summary.py +230 -0
- tensorbored/plugins/audio/summary_v2.py +124 -0
- tensorbored/plugins/base_plugin.py +367 -0
- tensorbored/plugins/core/__init__.py +0 -0
- tensorbored/plugins/core/core_plugin.py +981 -0
- tensorbored/plugins/custom_scalar/__init__.py +0 -0
- tensorbored/plugins/custom_scalar/custom_scalars_plugin.py +320 -0
- tensorbored/plugins/custom_scalar/layout_pb2.py +85 -0
- tensorbored/plugins/custom_scalar/metadata.py +35 -0
- tensorbored/plugins/custom_scalar/summary.py +79 -0
- tensorbored/plugins/debugger_v2/__init__.py +0 -0
- tensorbored/plugins/debugger_v2/debug_data_multiplexer.py +631 -0
- tensorbored/plugins/debugger_v2/debug_data_provider.py +634 -0
- tensorbored/plugins/debugger_v2/debugger_v2_plugin.py +504 -0
- tensorbored/plugins/distribution/__init__.py +0 -0
- tensorbored/plugins/distribution/compressor.py +158 -0
- tensorbored/plugins/distribution/distributions_plugin.py +116 -0
- tensorbored/plugins/distribution/metadata.py +19 -0
- tensorbored/plugins/graph/__init__.py +0 -0
- tensorbored/plugins/graph/graph_util.py +129 -0
- tensorbored/plugins/graph/graphs_plugin.py +336 -0
- tensorbored/plugins/graph/keras_util.py +328 -0
- tensorbored/plugins/graph/metadata.py +42 -0
- tensorbored/plugins/histogram/__init__.py +0 -0
- tensorbored/plugins/histogram/histograms_plugin.py +144 -0
- tensorbored/plugins/histogram/metadata.py +63 -0
- tensorbored/plugins/histogram/plugin_data_pb2.py +34 -0
- tensorbored/plugins/histogram/summary.py +234 -0
- tensorbored/plugins/histogram/summary_v2.py +292 -0
- tensorbored/plugins/hparams/__init__.py +14 -0
- tensorbored/plugins/hparams/_keras.py +93 -0
- tensorbored/plugins/hparams/api.py +130 -0
- tensorbored/plugins/hparams/api_pb2.py +208 -0
- tensorbored/plugins/hparams/backend_context.py +606 -0
- tensorbored/plugins/hparams/download_data.py +158 -0
- tensorbored/plugins/hparams/error.py +26 -0
- tensorbored/plugins/hparams/get_experiment.py +71 -0
- tensorbored/plugins/hparams/hparams_plugin.py +206 -0
- tensorbored/plugins/hparams/hparams_util_pb2.py +69 -0
- tensorbored/plugins/hparams/json_format_compat.py +38 -0
- tensorbored/plugins/hparams/list_metric_evals.py +57 -0
- tensorbored/plugins/hparams/list_session_groups.py +1040 -0
- tensorbored/plugins/hparams/metadata.py +125 -0
- tensorbored/plugins/hparams/metrics.py +41 -0
- tensorbored/plugins/hparams/plugin_data_pb2.py +69 -0
- tensorbored/plugins/hparams/summary.py +205 -0
- tensorbored/plugins/hparams/summary_v2.py +597 -0
- tensorbored/plugins/image/__init__.py +0 -0
- tensorbored/plugins/image/images_plugin.py +232 -0
- tensorbored/plugins/image/metadata.py +65 -0
- tensorbored/plugins/image/plugin_data_pb2.py +34 -0
- tensorbored/plugins/image/summary.py +159 -0
- tensorbored/plugins/image/summary_v2.py +130 -0
- tensorbored/plugins/mesh/__init__.py +14 -0
- tensorbored/plugins/mesh/mesh_plugin.py +292 -0
- tensorbored/plugins/mesh/metadata.py +152 -0
- tensorbored/plugins/mesh/plugin_data_pb2.py +37 -0
- tensorbored/plugins/mesh/summary.py +251 -0
- tensorbored/plugins/mesh/summary_v2.py +214 -0
- tensorbored/plugins/metrics/__init__.py +0 -0
- tensorbored/plugins/metrics/metadata.py +17 -0
- tensorbored/plugins/metrics/metrics_plugin.py +623 -0
- tensorbored/plugins/pr_curve/__init__.py +0 -0
- tensorbored/plugins/pr_curve/metadata.py +75 -0
- tensorbored/plugins/pr_curve/plugin_data_pb2.py +34 -0
- tensorbored/plugins/pr_curve/pr_curves_plugin.py +241 -0
- tensorbored/plugins/pr_curve/summary.py +574 -0
- tensorbored/plugins/profile_redirect/__init__.py +0 -0
- tensorbored/plugins/profile_redirect/profile_redirect_plugin.py +49 -0
- tensorbored/plugins/projector/__init__.py +67 -0
- tensorbored/plugins/projector/metadata.py +26 -0
- tensorbored/plugins/projector/projector_config_pb2.py +54 -0
- tensorbored/plugins/projector/projector_plugin.py +795 -0
- tensorbored/plugins/projector/tf_projector_plugin/index.js +32 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.html +524 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.js +15536 -0
- tensorbored/plugins/scalar/__init__.py +0 -0
- tensorbored/plugins/scalar/metadata.py +60 -0
- tensorbored/plugins/scalar/plugin_data_pb2.py +34 -0
- tensorbored/plugins/scalar/scalars_plugin.py +181 -0
- tensorbored/plugins/scalar/summary.py +109 -0
- tensorbored/plugins/scalar/summary_v2.py +124 -0
- tensorbored/plugins/text/__init__.py +0 -0
- tensorbored/plugins/text/metadata.py +62 -0
- tensorbored/plugins/text/plugin_data_pb2.py +34 -0
- tensorbored/plugins/text/summary.py +114 -0
- tensorbored/plugins/text/summary_v2.py +124 -0
- tensorbored/plugins/text/text_plugin.py +288 -0
- tensorbored/plugins/wit_redirect/__init__.py +0 -0
- tensorbored/plugins/wit_redirect/wit_redirect_plugin.py +49 -0
- tensorbored/program.py +910 -0
- tensorbored/summary/__init__.py +35 -0
- tensorbored/summary/_output.py +124 -0
- tensorbored/summary/_tf/__init__.py +14 -0
- tensorbored/summary/_tf/summary/__init__.py +178 -0
- tensorbored/summary/_writer.py +105 -0
- tensorbored/summary/v1.py +51 -0
- tensorbored/summary/v2.py +25 -0
- tensorbored/summary/writer/__init__.py +13 -0
- tensorbored/summary/writer/event_file_writer.py +291 -0
- tensorbored/summary/writer/record_writer.py +50 -0
- tensorbored/util/__init__.py +0 -0
- tensorbored/util/encoder.py +116 -0
- tensorbored/util/grpc_util.py +311 -0
- tensorbored/util/img_mime_type_detector.py +40 -0
- tensorbored/util/io_util.py +20 -0
- tensorbored/util/lazy_tensor_creator.py +110 -0
- tensorbored/util/op_evaluator.py +104 -0
- tensorbored/util/platform_util.py +20 -0
- tensorbored/util/tb_logging.py +24 -0
- tensorbored/util/tensor_util.py +617 -0
- tensorbored/util/timing.py +122 -0
- tensorbored/version.py +21 -0
- tensorbored/webfiles.zip +0 -0
- tensorbored-2.21.0rc1769983804.dist-info/METADATA +49 -0
- tensorbored-2.21.0rc1769983804.dist-info/RECORD +271 -0
- tensorbored-2.21.0rc1769983804.dist-info/WHEEL +5 -0
- tensorbored-2.21.0rc1769983804.dist-info/entry_points.txt +6 -0
- tensorbored-2.21.0rc1769983804.dist-info/licenses/LICENSE +739 -0
- tensorbored-2.21.0rc1769983804.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""TensorBoard 3D mesh visualizer plugin."""
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
from werkzeug import wrappers
|
|
19
|
+
|
|
20
|
+
from tensorbored.backend import http_util
|
|
21
|
+
from tensorbored.data import provider
|
|
22
|
+
from tensorbored.plugins import base_plugin
|
|
23
|
+
from tensorbored.plugins.mesh import metadata
|
|
24
|
+
from tensorbored.plugins.mesh import plugin_data_pb2
|
|
25
|
+
from tensorbored import plugin_util
|
|
26
|
+
|
|
27
|
+
_DEFAULT_DOWNSAMPLING = 100 # meshes per time series
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class MeshPlugin(base_plugin.TBPlugin):
|
|
31
|
+
"""A plugin that serves 3D visualization of meshes."""
|
|
32
|
+
|
|
33
|
+
plugin_name = metadata.PLUGIN_NAME
|
|
34
|
+
|
|
35
|
+
def __init__(self, context):
|
|
36
|
+
"""Instantiates a MeshPlugin via TensorBoard core.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
context: A base_plugin.TBContext instance. A magic container that
|
|
40
|
+
TensorBoard uses to make objects available to the plugin.
|
|
41
|
+
"""
|
|
42
|
+
self._data_provider = context.data_provider
|
|
43
|
+
self._downsample_to = (context.sampling_hints or {}).get(
|
|
44
|
+
self.plugin_name, _DEFAULT_DOWNSAMPLING
|
|
45
|
+
)
|
|
46
|
+
self._version_checker = plugin_util._MetadataVersionChecker(
|
|
47
|
+
data_kind="mesh",
|
|
48
|
+
latest_known_version=0,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def _instance_tag_metadata(self, ctx, experiment, run, instance_tag):
|
|
52
|
+
"""Gets the `MeshPluginData` proto for an instance tag."""
|
|
53
|
+
results = self._data_provider.list_tensors(
|
|
54
|
+
ctx,
|
|
55
|
+
experiment_id=experiment,
|
|
56
|
+
plugin_name=metadata.PLUGIN_NAME,
|
|
57
|
+
run_tag_filter=provider.RunTagFilter(
|
|
58
|
+
runs=[run], tags=[instance_tag]
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
content = results[run][instance_tag].plugin_content
|
|
62
|
+
return metadata.parse_plugin_metadata(content)
|
|
63
|
+
|
|
64
|
+
def _tag(self, ctx, experiment, run, instance_tag):
|
|
65
|
+
"""Gets the user-facing tag name for an instance tag."""
|
|
66
|
+
return self._instance_tag_metadata(
|
|
67
|
+
ctx, experiment, run, instance_tag
|
|
68
|
+
).name
|
|
69
|
+
|
|
70
|
+
def _instance_tags(self, ctx, experiment, run, tag):
|
|
71
|
+
"""Gets the instance tag names for a user-facing tag."""
|
|
72
|
+
index = self._data_provider.list_tensors(
|
|
73
|
+
ctx,
|
|
74
|
+
experiment_id=experiment,
|
|
75
|
+
plugin_name=metadata.PLUGIN_NAME,
|
|
76
|
+
run_tag_filter=provider.RunTagFilter(runs=[run]),
|
|
77
|
+
)
|
|
78
|
+
return [
|
|
79
|
+
instance_tag
|
|
80
|
+
for (instance_tag, ts) in index.get(run, {}).items()
|
|
81
|
+
if tag == metadata.parse_plugin_metadata(ts.plugin_content).name
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
@wrappers.Request.application
|
|
85
|
+
def _serve_tags(self, request):
|
|
86
|
+
"""A route (HTTP handler) that returns a response with tags.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
request: The werkzeug.Request object.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
A response that contains a JSON object. The keys of the object
|
|
93
|
+
are all the runs. Each run is mapped to a (potentially empty)
|
|
94
|
+
list of all tags that are relevant to this plugin.
|
|
95
|
+
"""
|
|
96
|
+
ctx = plugin_util.context(request.environ)
|
|
97
|
+
experiment = plugin_util.experiment_id(request.environ)
|
|
98
|
+
all_runs = self._data_provider.list_tensors(
|
|
99
|
+
ctx,
|
|
100
|
+
experiment_id=experiment,
|
|
101
|
+
plugin_name=metadata.PLUGIN_NAME,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# tagToContent is itself a dictionary mapping tag name to string
|
|
105
|
+
# SummaryMetadata.plugin_data.content. Retrieve the keys of that dictionary
|
|
106
|
+
# to obtain a list of tags associated with each run. For each tag estimate
|
|
107
|
+
# number of samples.
|
|
108
|
+
response = dict()
|
|
109
|
+
for run, tags in all_runs.items():
|
|
110
|
+
response[run] = dict()
|
|
111
|
+
for instance_tag, metadatum in tags.items():
|
|
112
|
+
md = metadata.parse_plugin_metadata(metadatum.plugin_content)
|
|
113
|
+
if not self._version_checker.ok(md.version, run, instance_tag):
|
|
114
|
+
continue
|
|
115
|
+
# Make sure we only operate on user-defined tags here.
|
|
116
|
+
tag = self._tag(ctx, experiment, run, instance_tag)
|
|
117
|
+
meta = self._instance_tag_metadata(
|
|
118
|
+
ctx, experiment, run, instance_tag
|
|
119
|
+
)
|
|
120
|
+
# Batch size must be defined, otherwise we don't know how many
|
|
121
|
+
# samples were there.
|
|
122
|
+
response[run][tag] = {"samples": meta.shape[0]}
|
|
123
|
+
return http_util.Respond(request, response, "application/json")
|
|
124
|
+
|
|
125
|
+
def get_plugin_apps(self):
|
|
126
|
+
"""Gets all routes offered by the plugin.
|
|
127
|
+
|
|
128
|
+
This method is called by TensorBoard when retrieving all the
|
|
129
|
+
routes offered by the plugin.
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
A dictionary mapping URL path to route that handles it.
|
|
133
|
+
"""
|
|
134
|
+
# Note that the methods handling routes are decorated with
|
|
135
|
+
# @wrappers.Request.application.
|
|
136
|
+
return {
|
|
137
|
+
"/tags": self._serve_tags,
|
|
138
|
+
"/meshes": self._serve_mesh_metadata,
|
|
139
|
+
"/data": self._serve_mesh_data,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
def is_active(self):
|
|
143
|
+
return False # `list_plugins` as called by TB core suffices
|
|
144
|
+
|
|
145
|
+
def frontend_metadata(self):
|
|
146
|
+
return base_plugin.FrontendMetadata(element_name="mesh-dashboard")
|
|
147
|
+
|
|
148
|
+
def _get_sample(self, tensor_datum, sample):
|
|
149
|
+
"""Returns a single sample from a batch of samples."""
|
|
150
|
+
return tensor_datum.numpy[sample].tolist()
|
|
151
|
+
|
|
152
|
+
def _get_tensor_metadata(
|
|
153
|
+
self, event, content_type, components, data_shape, config
|
|
154
|
+
):
|
|
155
|
+
"""Converts a TensorDatum into a JSON-compatible response.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
event: TensorDatum object containing data in proto format.
|
|
159
|
+
content_type: enum plugin_data_pb2.MeshPluginData.ContentType value,
|
|
160
|
+
representing content type in TensorDatum.
|
|
161
|
+
components: Bitmask representing all parts (vertices, colors, etc.) that
|
|
162
|
+
belong to the summary.
|
|
163
|
+
data_shape: list of dimensions sizes of the tensor.
|
|
164
|
+
config: rendering scene configuration as dictionary.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
Dictionary of transformed metadata.
|
|
168
|
+
"""
|
|
169
|
+
return {
|
|
170
|
+
"wall_time": event.wall_time,
|
|
171
|
+
"step": event.step,
|
|
172
|
+
"content_type": content_type,
|
|
173
|
+
"components": components,
|
|
174
|
+
"config": config,
|
|
175
|
+
"data_shape": list(data_shape),
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
def _get_tensor_data(self, event, sample):
|
|
179
|
+
"""Convert a TensorDatum into a JSON-compatible response."""
|
|
180
|
+
data = self._get_sample(event, sample)
|
|
181
|
+
return data
|
|
182
|
+
|
|
183
|
+
def _collect_tensor_events(self, request, step=None):
|
|
184
|
+
"""Collects list of tensor events based on request."""
|
|
185
|
+
ctx = plugin_util.context(request.environ)
|
|
186
|
+
experiment = plugin_util.experiment_id(request.environ)
|
|
187
|
+
run = request.args.get("run")
|
|
188
|
+
tag = request.args.get("tag")
|
|
189
|
+
|
|
190
|
+
tensor_events = [] # List of tuples (meta, tensor) that contain tag.
|
|
191
|
+
for instance_tag in self._instance_tags(ctx, experiment, run, tag):
|
|
192
|
+
tensors = self._data_provider.read_tensors(
|
|
193
|
+
ctx,
|
|
194
|
+
experiment_id=experiment,
|
|
195
|
+
plugin_name=metadata.PLUGIN_NAME,
|
|
196
|
+
run_tag_filter=provider.RunTagFilter(
|
|
197
|
+
runs=[run], tags=[instance_tag]
|
|
198
|
+
),
|
|
199
|
+
downsample=self._downsample_to,
|
|
200
|
+
)[run][instance_tag]
|
|
201
|
+
meta = self._instance_tag_metadata(
|
|
202
|
+
ctx, experiment, run, instance_tag
|
|
203
|
+
)
|
|
204
|
+
tensor_events += [(meta, tensor) for tensor in tensors]
|
|
205
|
+
|
|
206
|
+
if step is not None:
|
|
207
|
+
tensor_events = [
|
|
208
|
+
event for event in tensor_events if event[1].step == step
|
|
209
|
+
]
|
|
210
|
+
else:
|
|
211
|
+
# Make sure tensors sorted by step in ascending order.
|
|
212
|
+
tensor_events = sorted(
|
|
213
|
+
tensor_events, key=lambda tensor_data: tensor_data[1].step
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
return tensor_events
|
|
217
|
+
|
|
218
|
+
@wrappers.Request.application
|
|
219
|
+
def _serve_mesh_data(self, request):
|
|
220
|
+
"""A route that returns data for particular summary of specified type.
|
|
221
|
+
|
|
222
|
+
Data can represent vertices coordinates, vertices indices in faces,
|
|
223
|
+
vertices colors and so on. Each mesh may have different combination of
|
|
224
|
+
abovementioned data and each type/part of mesh summary must be served as
|
|
225
|
+
separate roundtrip to the server.
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
request: werkzeug.Request containing content_type as a name of enum
|
|
229
|
+
plugin_data_pb2.MeshPluginData.ContentType.
|
|
230
|
+
|
|
231
|
+
Returns:
|
|
232
|
+
werkzeug.Response either float32 or int32 data in binary format.
|
|
233
|
+
"""
|
|
234
|
+
step = float(request.args.get("step", 0.0))
|
|
235
|
+
tensor_events = self._collect_tensor_events(request, step)
|
|
236
|
+
content_type = request.args.get("content_type")
|
|
237
|
+
try:
|
|
238
|
+
content_type = plugin_data_pb2.MeshPluginData.ContentType.Value(
|
|
239
|
+
content_type
|
|
240
|
+
)
|
|
241
|
+
except ValueError:
|
|
242
|
+
return http_util.Respond(
|
|
243
|
+
request, "Bad content_type", "text/plain", 400
|
|
244
|
+
)
|
|
245
|
+
sample = int(request.args.get("sample", 0))
|
|
246
|
+
|
|
247
|
+
response = [
|
|
248
|
+
self._get_tensor_data(tensor, sample)
|
|
249
|
+
for meta, tensor in tensor_events
|
|
250
|
+
if meta.content_type == content_type
|
|
251
|
+
]
|
|
252
|
+
|
|
253
|
+
np_type = {
|
|
254
|
+
plugin_data_pb2.MeshPluginData.VERTEX: np.float32,
|
|
255
|
+
plugin_data_pb2.MeshPluginData.FACE: np.int32,
|
|
256
|
+
plugin_data_pb2.MeshPluginData.COLOR: np.uint8,
|
|
257
|
+
}[content_type]
|
|
258
|
+
|
|
259
|
+
response = np.array(response, dtype=np_type)
|
|
260
|
+
# Looks like reshape can take around 160ms, so why not store it reshaped.
|
|
261
|
+
response = response.reshape(-1).tobytes()
|
|
262
|
+
|
|
263
|
+
return http_util.Respond(request, response, "arraybuffer")
|
|
264
|
+
|
|
265
|
+
@wrappers.Request.application
|
|
266
|
+
def _serve_mesh_metadata(self, request):
|
|
267
|
+
"""A route that returns the mesh metadata associated with a tag.
|
|
268
|
+
|
|
269
|
+
Metadata consists of wall time, type of elements in tensor, scene
|
|
270
|
+
configuration and so on.
|
|
271
|
+
|
|
272
|
+
Args:
|
|
273
|
+
request: The werkzeug.Request object.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
A JSON list of mesh data associated with the run and tag
|
|
277
|
+
combination.
|
|
278
|
+
"""
|
|
279
|
+
tensor_events = self._collect_tensor_events(request)
|
|
280
|
+
|
|
281
|
+
# We convert the tensor data to text.
|
|
282
|
+
response = [
|
|
283
|
+
self._get_tensor_metadata(
|
|
284
|
+
tensor,
|
|
285
|
+
meta.content_type,
|
|
286
|
+
meta.components,
|
|
287
|
+
meta.shape,
|
|
288
|
+
meta.json_config,
|
|
289
|
+
)
|
|
290
|
+
for meta, tensor in tensor_events
|
|
291
|
+
]
|
|
292
|
+
return http_util.Respond(request, response, "application/json")
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""Internal information about the mesh plugin."""
|
|
16
|
+
|
|
17
|
+
import dataclasses
|
|
18
|
+
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from tensorbored.compat.proto import summary_pb2
|
|
22
|
+
from tensorbored.plugins.mesh import plugin_data_pb2
|
|
23
|
+
|
|
24
|
+
PLUGIN_NAME = "mesh"
|
|
25
|
+
|
|
26
|
+
# The most recent value for the `version` field of the
|
|
27
|
+
# `MeshPluginData` proto.
|
|
28
|
+
_PROTO_VERSION = 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclasses.dataclass(frozen=True)
|
|
32
|
+
class MeshTensor:
|
|
33
|
+
"""A mesh tensor.
|
|
34
|
+
|
|
35
|
+
Attributes:
|
|
36
|
+
data: Tensor of shape `[dim_1, ..., dim_n, 3]` representing the mesh data
|
|
37
|
+
of one of the following:
|
|
38
|
+
- 3D coordinates of vertices
|
|
39
|
+
- Indices of vertices within each triangle
|
|
40
|
+
- Colors for each vertex
|
|
41
|
+
content_type: Type of the mesh plugin data content.
|
|
42
|
+
data_type: Data type of the elements in the tensor.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
data: Any # Expects type `tf.Tensor`, not specified here to avoid heavy TF dep.
|
|
46
|
+
content_type: plugin_data_pb2.MeshPluginData.ContentType
|
|
47
|
+
data_type: Any # Expects type `tf.DType`, not specified here to avoid heavy TF dep.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def get_components_bitmask(content_types):
|
|
51
|
+
"""Creates bitmask for all existing components of the summary.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
content_type: list of plugin_data_pb2.MeshPluginData.ContentType,
|
|
55
|
+
representing all components related to the summary.
|
|
56
|
+
Returns: bitmask based on passed tensors.
|
|
57
|
+
"""
|
|
58
|
+
components = 0
|
|
59
|
+
for content_type in content_types:
|
|
60
|
+
if content_type == plugin_data_pb2.MeshPluginData.UNDEFINED:
|
|
61
|
+
raise ValueError("Cannot include UNDEFINED content type in mask.")
|
|
62
|
+
components = components | (1 << content_type)
|
|
63
|
+
return components
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def get_current_version():
|
|
67
|
+
"""Returns current verions of the proto."""
|
|
68
|
+
return _PROTO_VERSION
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_instance_name(name, content_type):
|
|
72
|
+
"""Returns a unique instance name for a given summary related to the
|
|
73
|
+
mesh."""
|
|
74
|
+
return "%s_%s" % (
|
|
75
|
+
name,
|
|
76
|
+
plugin_data_pb2.MeshPluginData.ContentType.Name(content_type),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def create_summary_metadata(
|
|
81
|
+
name,
|
|
82
|
+
display_name,
|
|
83
|
+
content_type,
|
|
84
|
+
components,
|
|
85
|
+
shape,
|
|
86
|
+
description=None,
|
|
87
|
+
json_config=None,
|
|
88
|
+
):
|
|
89
|
+
"""Creates summary metadata which defined at MeshPluginData proto.
|
|
90
|
+
|
|
91
|
+
Arguments:
|
|
92
|
+
name: Original merged (summaries of different types) summary name.
|
|
93
|
+
display_name: The display name used in TensorBoard.
|
|
94
|
+
content_type: Value from MeshPluginData.ContentType enum describing data.
|
|
95
|
+
components: Bitmask representing present parts (vertices, colors, etc.) that
|
|
96
|
+
belong to the summary.
|
|
97
|
+
shape: list of dimensions sizes of the tensor.
|
|
98
|
+
description: The description to show in TensorBoard.
|
|
99
|
+
json_config: A string, JSON-serialized dictionary of ThreeJS classes
|
|
100
|
+
configuration.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
A `summary_pb2.SummaryMetadata` protobuf object.
|
|
104
|
+
"""
|
|
105
|
+
# Shape should be at least BxNx3 where B represents the batch dimensions
|
|
106
|
+
# and N - the number of points, each with x,y,z coordinates.
|
|
107
|
+
if len(shape) != 3:
|
|
108
|
+
raise ValueError(
|
|
109
|
+
"Tensor shape should be of shape BxNx3, but got %s." % str(shape)
|
|
110
|
+
)
|
|
111
|
+
mesh_plugin_data = plugin_data_pb2.MeshPluginData(
|
|
112
|
+
version=get_current_version(),
|
|
113
|
+
name=name,
|
|
114
|
+
content_type=content_type,
|
|
115
|
+
components=components,
|
|
116
|
+
shape=shape,
|
|
117
|
+
json_config=json_config,
|
|
118
|
+
)
|
|
119
|
+
content = mesh_plugin_data.SerializeToString()
|
|
120
|
+
return summary_pb2.SummaryMetadata(
|
|
121
|
+
display_name=display_name, # Will not be used in TensorBoard UI.
|
|
122
|
+
summary_description=description,
|
|
123
|
+
plugin_data=summary_pb2.SummaryMetadata.PluginData(
|
|
124
|
+
plugin_name=PLUGIN_NAME, content=content
|
|
125
|
+
),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def parse_plugin_metadata(content):
|
|
130
|
+
"""Parse summary metadata to a Python object.
|
|
131
|
+
|
|
132
|
+
Arguments:
|
|
133
|
+
content: The `content` field of a `SummaryMetadata` proto
|
|
134
|
+
corresponding to the mesh plugin.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
A `MeshPluginData` protobuf object.
|
|
138
|
+
Raises: Error if the version of the plugin is not supported.
|
|
139
|
+
"""
|
|
140
|
+
if not isinstance(content, bytes):
|
|
141
|
+
raise TypeError("Content type must be bytes.")
|
|
142
|
+
result = plugin_data_pb2.MeshPluginData.FromString(content)
|
|
143
|
+
# Add components field to older version of the proto.
|
|
144
|
+
if result.components == 0:
|
|
145
|
+
result.components = get_components_bitmask(
|
|
146
|
+
[
|
|
147
|
+
plugin_data_pb2.MeshPluginData.VERTEX,
|
|
148
|
+
plugin_data_pb2.MeshPluginData.FACE,
|
|
149
|
+
plugin_data_pb2.MeshPluginData.COLOR,
|
|
150
|
+
]
|
|
151
|
+
)
|
|
152
|
+
return result
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: tensorbored/plugins/mesh/plugin_data.proto
|
|
4
|
+
"""Generated protocol buffer code."""
|
|
5
|
+
from google.protobuf import descriptor as _descriptor
|
|
6
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
7
|
+
from google.protobuf import message as _message
|
|
8
|
+
from google.protobuf import reflection as _reflection
|
|
9
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
10
|
+
# @@protoc_insertion_point(imports)
|
|
11
|
+
|
|
12
|
+
_sym_db = _symbol_database.Default()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n*tensorbored/plugins/mesh/plugin_data.proto\x12\x10tensorbored.mesh\"\xea\x01\n\x0eMeshPluginData\x12\x0f\n\x07version\x18\x01 \x01(\x05\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x42\n\x0c\x63ontent_type\x18\x03 \x01(\x0e\x32,.tensorbored.mesh.MeshPluginData.ContentType\x12\x13\n\x0bjson_config\x18\x05 \x01(\t\x12\r\n\x05shape\x18\x06 \x03(\x05\x12\x12\n\ncomponents\x18\x07 \x01(\r\"=\n\x0b\x43ontentType\x12\r\n\tUNDEFINED\x10\x00\x12\n\n\x06VERTEX\x10\x01\x12\x08\n\x04\x46\x41\x43\x45\x10\x02\x12\t\n\x05\x43OLOR\x10\x03\x62\x06proto3')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
_MESHPLUGINDATA = DESCRIPTOR.message_types_by_name['MeshPluginData']
|
|
22
|
+
_MESHPLUGINDATA_CONTENTTYPE = _MESHPLUGINDATA.enum_types_by_name['ContentType']
|
|
23
|
+
MeshPluginData = _reflection.GeneratedProtocolMessageType('MeshPluginData', (_message.Message,), {
|
|
24
|
+
'DESCRIPTOR' : _MESHPLUGINDATA,
|
|
25
|
+
'__module__' : 'tensorbored.plugins.mesh.plugin_data_pb2'
|
|
26
|
+
# @@protoc_insertion_point(class_scope:tensorbored.mesh.MeshPluginData)
|
|
27
|
+
})
|
|
28
|
+
_sym_db.RegisterMessage(MeshPluginData)
|
|
29
|
+
|
|
30
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
31
|
+
|
|
32
|
+
DESCRIPTOR._options = None
|
|
33
|
+
_MESHPLUGINDATA._serialized_start=65
|
|
34
|
+
_MESHPLUGINDATA._serialized_end=299
|
|
35
|
+
_MESHPLUGINDATA_CONTENTTYPE._serialized_start=238
|
|
36
|
+
_MESHPLUGINDATA_CONTENTTYPE._serialized_end=299
|
|
37
|
+
# @@protoc_insertion_point(module_scope)
|