Tensorboard text logging report as debug samples (.txt files), instead of as console output.

This commit is contained in:
allegroai
2020-07-04 22:55:29 +03:00
parent 934771184d
commit 2f5b519cd8
4 changed files with 65 additions and 11 deletions

View File

@@ -192,7 +192,8 @@ class UploadEvent(MetricsEventAdapter):
file_history_size=None, delete_after_upload=False, **kwargs):
# param override_filename: override uploaded file name (notice extension will be added from local path
# param override_filename_ext: override uploaded file extension
if image_data is not None and (not hasattr(image_data, 'shape') and not isinstance(image_data, six.BytesIO)):
if image_data is not None and (
not hasattr(image_data, 'shape') and not isinstance(image_data, (six.StringIO, six.BytesIO))):
raise ValueError('Image must have a shape attribute')
self._image_data = image_data
self._local_image_path = local_image_path
@@ -263,7 +264,7 @@ class UploadEvent(MetricsEventAdapter):
last_count = self._get_metric_count(self.metric, self.variant, next=False)
if abs(self._count - last_count) > self._file_history_size:
output = None
elif isinstance(self._image_data, six.BytesIO):
elif isinstance(self._image_data, (six.StringIO, six.BytesIO)):
output = self._image_data
elif self._image_data is not None:
image_data = self._image_data

View File

@@ -277,7 +277,7 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
:type iter: int
:param path: A path to an image file. Required unless matrix is provided.
:type path: str
:param stream: File stream
:param stream: File/String stream
:param file_extension: file extension to use when stream is passed
:param max_history: maximum number of files to store per metric/variant combination
use negative value for unlimited. default is set in global configuration (default=5)
@@ -288,6 +288,9 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
raise ValueError('Upload configuration is required (use setup_upload())')
if len([x for x in (path, stream) if x is not None]) != 1:
raise ValueError('Expected only one of [filename, stream]')
if isinstance(stream, six.string_types):
stream = six.StringIO(stream)
kwargs = dict(metric=self._normalize_name(title), variant=self._normalize_name(series), iter=iter,
file_history_size=max_history)
ev = MediaEvent(stream=stream, upload_uri=upload_uri, local_image_path=path,