scope 0.2.0__tar.gz → 0.2.2__tar.gz

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.
@@ -0,0 +1 @@
1
+ include requirements.txt
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scope
3
- Version: 0.2.0
4
- Summary: Metrics logging and analysis.
3
+ Version: 0.2.2
4
+ Summary: Metrics logging and analysis
5
5
  Home-page: http://github.com/danijar/scope
6
6
  Classifier: Intended Audience :: Science/Research
7
7
  Classifier: License :: OSI Approved :: MIT License
@@ -0,0 +1,2 @@
1
+ av
2
+ numpy
@@ -1,4 +1,4 @@
1
- __version__ = '0.2.0'
1
+ __version__ = '0.2.2'
2
2
 
3
3
  from .writer import Writer
4
4
  from .reader import Reader
@@ -131,10 +131,12 @@ class ImageColumn(FileColumn):
131
131
  def validate(self, value):
132
132
  assert (
133
133
  value.dtype == np.uint8 and value.ndim == 3 and
134
- value.shape[-1] == 3), (value.dtype, value.shape)
134
+ value.shape[-1] in (1, 3)), (value.dtype, value.shape)
135
135
  return value
136
136
 
137
137
  def encode(self, value):
138
+ if value.shape[-1] == 1:
139
+ value = value.repeat(3, -1)
138
140
  fmt = ('jpeg' if self.fmt == 'jpg' else self.fmt).upper()
139
141
  fp = io.BytesIO()
140
142
  Image.fromarray(value).save(fp, format=fmt, quality=self.quality)
@@ -155,11 +157,13 @@ class VideoColumn(FileColumn):
155
157
  def validate(self, value):
156
158
  assert (
157
159
  value.dtype == np.uint8 and value.ndim == 4 and
158
- value.shape[-1] == 3), (value.dtype, value.shape)
160
+ value.shape[-1] in (1, 3)), (value.dtype, value.shape)
159
161
  return value
160
162
 
161
- def encode(self, array):
162
- T, H, W, C = array.shape
163
+ def encode(self, value):
164
+ if value.shape[-1] == 1:
165
+ value = value.repeat(3, -1)
166
+ T, H, W, C = value.shape
163
167
  fp = io.BytesIO()
164
168
  output = av.open(fp, mode='w', format=self.fmt)
165
169
  stream = output.add_stream(self.codec, rate=float(self.fps))
@@ -167,7 +171,7 @@ class VideoColumn(FileColumn):
167
171
  stream.height = H
168
172
  stream.pix_fmt = 'yuv420p'
169
173
  for t in range(T):
170
- frame = av.VideoFrame.from_ndarray(array[t], format='rgb24')
174
+ frame = av.VideoFrame.from_ndarray(value[t], format='rgb24')
171
175
  frame.pts = t
172
176
  output.mux(stream.encode(frame))
173
177
  output.mux(stream.encode(None))
@@ -176,9 +180,9 @@ class VideoColumn(FileColumn):
176
180
 
177
181
  def decode(self, buffer):
178
182
  container = av.open(io.BytesIO(buffer))
179
- array = []
183
+ value = []
180
184
  for frame in container.decode(video=0):
181
- array.append(frame.to_ndarray(format='rgb24'))
182
- array = np.stack(array)
185
+ value.append(frame.to_ndarray(format='rgb24'))
186
+ value = np.stack(value)
183
187
  container.close()
184
- return array
188
+ return value
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scope
3
- Version: 0.2.0
4
- Summary: Metrics logging and analysis.
3
+ Version: 0.2.2
4
+ Summary: Metrics logging and analysis
5
5
  Home-page: http://github.com/danijar/scope
6
6
  Classifier: Intended Audience :: Science/Research
7
7
  Classifier: License :: OSI Approved :: MIT License
@@ -1,5 +1,7 @@
1
+ MANIFEST.in
1
2
  README.md
2
3
  pyproject.toml
4
+ requirements.txt
3
5
  setup.py
4
6
  scope/__init__.py
5
7
  scope/columns.py
@@ -8,6 +10,7 @@ scope/writer.py
8
10
  scope.egg-info/PKG-INFO
9
11
  scope.egg-info/SOURCES.txt
10
12
  scope.egg-info/dependency_links.txt
13
+ scope.egg-info/requires.txt
11
14
  scope.egg-info/top_level.txt
12
15
  tests/test_float.py
13
16
  tests/test_image.py
@@ -0,0 +1,2 @@
1
+ av
2
+ numpy
@@ -19,7 +19,7 @@ def parse_version(filename):
19
19
  setuptools.setup(
20
20
  name='scope',
21
21
  version=parse_version('scope/__init__.py'),
22
- description='Metrics logging and analysis.',
22
+ description='Metrics logging and analysis',
23
23
  url='http://github.com/danijar/scope',
24
24
  long_description=pathlib.Path('README.md').read_text(),
25
25
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes