Skip to content

Commit 9019990

Browse files
chyomin06fracape
authored andcommitted
[fix] if-else for the final bits count
1 parent 41f57f7 commit 9019990

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

compressai_vision/pipelines/remote_inference/image_remote_inference.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,12 @@ def __call__(
172172
out_res["qp"] = (
173173
"uncmp" if codec.qp_value is None else codec.qp_value
174174
) # Assuming one qp will be used
175-
if self.configs["codec"]["decode_only"]:
175+
176+
if not isinstance(res["bitstream"], dict):
176177
out_res["bytes"] = os.stat(res["bitstream"]).st_size
177178
else:
178179
out_res["bytes"] = res["bytes"][0]
180+
179181
out_res["coded_order"] = e
180182
out_res["org_input_size"] = f'{d[0]["height"]}x{d[0]["width"]}'
181183
output_list.append(out_res)

compressai_vision/pipelines/remote_inference/video_remote_inference.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,12 @@ def __call__(
197197
"uncmp" if codec.qp_value is None else codec.qp_value
198198
) # Assuming one qp will be used
199199

200-
if self.configs["codec"]["decode_only"]:
201-
out_res["bytes"] = bitstream_bytes / len(dataloader)
200+
if not isinstance(res["bitstream"], dict):
201+
out_res["bytes"] = os.stat(res["bitstream"]).st_size / len(dataloader)
202202
else:
203+
assert len(res["bytes"]) == len(dataloader)
203204
out_res["bytes"] = res["bytes"][e]
205+
204206
out_res["coded_order"] = e
205207
out_res["org_input_size"] = f'{d[0]["height"]}x{d[0]["width"]}'
206208

compressai_vision/pipelines/split_inference/image_split_inference.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,11 @@ def __call__(
229229
"uncmp" if codec.qp_value is None else codec.qp_value
230230
) # Assuming one qp will be used
231231

232-
out_res["bytes"] = os.stat(res["bitstream"]).st_size
232+
if not isinstance(res["bitstream"], dict):
233+
out_res["bytes"] = os.stat(res["bitstream"]).st_size
234+
else:
235+
out_res["bytes"] = res["bytes"][0]
236+
233237
out_res["coded_order"] = e
234238
out_res["org_input_size"] = f'{d[0]["height"]}x{d[0]["width"]}'
235239
out_res["input_size"] = dec_features["input_size"][0]

compressai_vision/pipelines/split_inference/video_split_inference.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ def __call__(
319319
out_res = dec_features.copy()
320320
del (out_res["data"], out_res["org_input_size"])
321321

322-
if self.configs["codec"]["decode_only"]:
323-
out_res["bytes"] = bitstream_bytes / len(dataloader)
322+
if not isinstance(res["bitstream"], dict):
323+
out_res["bytes"] = os.stat(res["bitstream"]).st_size / len(dataloader)
324324
else:
325325
assert len(res["bytes"]) == len(dataloader)
326-
out_res["bytes"] = os.stat(res["bitstream"]).st_size / len(dataloader)
326+
out_res["bytes"] = res["bytes"][e]
327327

328328
out_res["coded_order"] = e
329329
out_res["input_size"] = dec_features["input_size"][0]

0 commit comments

Comments
 (0)