scope 0.2.1__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.
- {scope-0.2.1/scope.egg-info → scope-0.2.2}/PKG-INFO +1 -1
- {scope-0.2.1 → scope-0.2.2}/scope/__init__.py +1 -1
- {scope-0.2.1 → scope-0.2.2}/scope/columns.py +13 -9
- {scope-0.2.1 → scope-0.2.2/scope.egg-info}/PKG-INFO +1 -1
- {scope-0.2.1 → scope-0.2.2}/MANIFEST.in +0 -0
- {scope-0.2.1 → scope-0.2.2}/README.md +0 -0
- {scope-0.2.1 → scope-0.2.2}/pyproject.toml +0 -0
- {scope-0.2.1 → scope-0.2.2}/requirements.txt +0 -0
- {scope-0.2.1 → scope-0.2.2}/scope/reader.py +0 -0
- {scope-0.2.1 → scope-0.2.2}/scope/writer.py +0 -0
- {scope-0.2.1 → scope-0.2.2}/scope.egg-info/SOURCES.txt +0 -0
- {scope-0.2.1 → scope-0.2.2}/scope.egg-info/dependency_links.txt +0 -0
- {scope-0.2.1 → scope-0.2.2}/scope.egg-info/requires.txt +0 -0
- {scope-0.2.1 → scope-0.2.2}/scope.egg-info/top_level.txt +0 -0
- {scope-0.2.1 → scope-0.2.2}/setup.cfg +0 -0
- {scope-0.2.1 → scope-0.2.2}/setup.py +0 -0
- {scope-0.2.1 → scope-0.2.2}/tests/test_float.py +0 -0
- {scope-0.2.1 → scope-0.2.2}/tests/test_image.py +0 -0
- {scope-0.2.1 → scope-0.2.2}/tests/test_video.py +0 -0
|
@@ -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]
|
|
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]
|
|
160
|
+
value.shape[-1] in (1, 3)), (value.dtype, value.shape)
|
|
159
161
|
return value
|
|
160
162
|
|
|
161
|
-
def encode(self,
|
|
162
|
-
|
|
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(
|
|
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
|
-
|
|
183
|
+
value = []
|
|
180
184
|
for frame in container.decode(video=0):
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
value.append(frame.to_ndarray(format='rgb24'))
|
|
186
|
+
value = np.stack(value)
|
|
183
187
|
container.close()
|
|
184
|
-
return
|
|
188
|
+
return value
|
|
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
|
|
File without changes
|