scope 0.5.3__tar.gz → 0.5.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scope
3
- Version: 0.5.3
3
+ Version: 0.5.4
4
4
  Summary: Metrics logging and analysis
5
5
  Home-page: http://github.com/danijar/scope
6
6
  Classifier: Intended Audience :: Science/Research
@@ -1,6 +1,7 @@
1
1
  av
2
2
  elements>=3.16.6
3
3
  fastapi
4
+ mediapy
4
5
  numpy
5
6
  pillow
6
7
  uvicorn[standard]
@@ -1,4 +1,4 @@
1
- __version__ = '0.5.3'
1
+ __version__ = '0.5.4'
2
2
 
3
3
  from .reader import Reader
4
4
  from .writer import Writer
@@ -176,6 +176,47 @@ class Video:
176
176
  return files_length(path)
177
177
 
178
178
 
179
+ class MediapyVideo:
180
+
181
+ def __init__(self, ext='mp4', fps=10):
182
+ self.ext = ext
183
+ self.fps = fps
184
+
185
+ @property
186
+ def extension(self):
187
+ return self.ext
188
+
189
+ def valid(self, x):
190
+ return (
191
+ isinstance(x, np.ndarray) and
192
+ x.dtype == np.uint8 and
193
+ x.ndim == 4 and
194
+ x.shape[-1] in (1, 3))
195
+
196
+ def convert(self, x):
197
+ return x
198
+
199
+ def create(self, path):
200
+ path.mkdir(exist_ok=True)
201
+
202
+ def write(self, path, steps, values):
203
+ files_write(path, steps, values, self.encode)
204
+
205
+ def read(self, path):
206
+ return files_read(path)
207
+
208
+ def encode(self, value):
209
+ import mediapy
210
+ return mediapy.compress_video(value, fps=self.fps)
211
+
212
+ def decode(self, buffer):
213
+ import mediapy
214
+ return mediapy.decompress_video(buffer)
215
+
216
+ def length(self, path):
217
+ return files_length(path)
218
+
219
+
179
220
  def table_append(filename, fmt, *cols):
180
221
  rows = tuple(zip(*cols))
181
222
  size = struct.calcsize(fmt)
@@ -7,13 +7,12 @@ import numpy as np
7
7
 
8
8
  from . import formats
9
9
 
10
- FPS = 10
11
10
 
12
11
  FORMATS = [
13
12
  formats.Text(),
14
13
  formats.Float(),
15
14
  formats.Image(),
16
- formats.Video(fps=FPS),
15
+ formats.Video(fps=10),
17
16
  ]
18
17
 
19
18
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes