Closed LiuXiangrui closed 2 years ago
Not sure I understand your problem. You seem to reference lines in the module "bench" where it runs a codec specified by its binary executable files.
I just checked running something like
python3 -m compressai.utils.bench hm ~/data/datasets/kodak -q 45 -b ~/HM-16.20+SCM-8.8/bin -c ~/HM-16.20+SCM-8.8/cfg/encoder_intra_main_rext.cfg
which runs successfully.
As for BPG, -m is not a reliable way of tuning the target quality. It has several levels only and aims at driving encoder speed (I suspect it deactivates some prediction tools, performs some early terminations in searching encoding modes). We use the quantization parameter -q [0,51]
Thanks for your reply :)
When I tried to test the BPG using command:
python -m compressai.utils.bench bpg "E:\test" --encoder-path D:/BPG/bpgenc.exe --decoder-path D:/BPG/bpgdec.exe -m 420 -b 8 -c ycbcr -q 27
It raised the error Could not read '<PIL.Image.Image image mode=RGB size=512x512 at 0x2711FB9A670>'
But when I change the code in codecs.py
, line 161 like this:
def run(
self,
img,
quality: int,
metrics: Optional[List[str]] = None,
return_rec: bool = False,
):
img_name = img # I changed this line
img = self._load_img(img)
# info, rec = self._run_impl(img, quality) # I changed this line
info, rec = self._run_impl(img_name , quality)
info.update(compute_metrics(rec, img, metrics))
if return_rec:
return info, rec
return info
It works. So I think when using the BPG, the function run()
passes the incorrect argument img
to self._run_impl()
.
And the original codes work well for HM, because HM using the yuv file path instead of the variable img
to assemble the command in codecs.py
, line 682.
ok, got it thanks. Your modification would break the call to other codecs. I'll fix that soon
Thanks :)
In line 169, the type of variable 'img' is, while in line 246, the function '__get_encode_cmd()' needs the argument 'img' to be a string.
That will cause a error, and you can fix it in line 169 by passing the filename of the image to function '__run_impl()'
By the way, it would be better to add the argument '-m' for BPG to control the compression level :)