Skip to content

Commit ff49d4b

Browse files
committed
[dev] update fcm api interface and output bitstream size calculation corrected
1 parent 3af9d0c commit ff49d4b

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

compressai_vision/codecs/fctm.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ class FCTM(feature_coding_model):
4545
"""Does no encoding/decoding whatsoever. Use for debugging."""
4646

4747
def __init__(self, **kwargs):
48-
super().__init__(
49-
kwargs["coding_behaviour"],
50-
kwargs["tools"],
51-
kwargs["device"],
52-
kwargs["verbosity"],
53-
kwargs["mac_computation"],
54-
)
48+
49+
enc_configs = kwargs.pop("enc_configs")
50+
self.qp = enc_configs["qp"]
51+
self.eval_encode = kwargs.pop("eval_encode")
52+
53+
super().__init__(**kwargs)
5554

5655
tools = kwargs["tools"]
5756
if (
@@ -68,9 +67,6 @@ def __init__(self, **kwargs):
6867

6968
raise SystemExit()
7069

71-
self.qp = kwargs["enc_configs"]["qp"]
72-
self.eval_encode = kwargs["eval_encode"]
73-
7470
@property
7571
def qp_value(self):
7672
return self.qp

compressai_vision/pipelines/split_inference/image_split_inference.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,8 @@ def __call__(
222222
out_res["qp"] = (
223223
"uncmp" if codec.qp_value is None else codec.qp_value
224224
) # Assuming one qp will be used
225-
if self.configs["codec"]["decode_only"]:
226-
out_res["bytes"] = os.stat(res["bitstream"]).st_size
227-
else:
228-
out_res["bytes"] = res["bytes"][0]
225+
226+
out_res["bytes"] = os.stat(res["bitstream"]).st_size
229227
out_res["coded_order"] = e
230228
out_res["org_input_size"] = f'{d[0]["height"]}x{d[0]["width"]}'
231229
out_res["input_size"] = dec_features["input_size"][0]

compressai_vision/pipelines/split_inference/video_split_inference.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

3030

31+
import os
3132
from typing import Dict, List, Tuple, TypeVar
3233

3334
import torch
@@ -304,10 +305,13 @@ def __call__(
304305

305306
out_res = dec_features.copy()
306307
del (out_res["data"], out_res["org_input_size"])
308+
307309
if self.configs["codec"]["decode_only"]:
308310
out_res["bytes"] = bitstream_bytes / len(dataloader)
309311
else:
310-
out_res["bytes"] = res["bytes"][e]
312+
assert len(res["bytes"]) == len(dataloader)
313+
out_res["bytes"] = os.stat(res["bitstream"]).st_size / len(dataloader)
314+
311315
out_res["coded_order"] = e
312316
out_res["input_size"] = dec_features["input_size"][0]
313317
out_res["org_input_size"] = (

0 commit comments

Comments
 (0)