Skip to content

Commit

Permalink
Add very low MS-ILLM rates (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmuckley authored Sep 18, 2024
1 parent f207980 commit 8e9c2ed
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
46 changes: 46 additions & 0 deletions hubconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from neuralcompression.zoo import msillm_quality_4 as _msillm_quality_4
from neuralcompression.zoo import msillm_quality_5 as _msillm_quality_5
from neuralcompression.zoo import msillm_quality_6 as _msillm_quality_6
from neuralcompression.zoo import msillm_quality_vlo1 as _msillm_quality_vlo1
from neuralcompression.zoo import msillm_quality_vlo2 as _msillm_quality_vlo2
from neuralcompression.zoo import noganms_quality_1 as _noganms_quality_1
from neuralcompression.zoo import noganms_quality_2 as _noganms_quality_2
from neuralcompression.zoo import noganms_quality_3 as _noganms_quality_3
Expand All @@ -23,6 +25,50 @@
dependencies = ["torch"]


def msillm_quality_vlo1(pretrained=True, **kwargs):
"""
Pretrained MS-ILLM model
This model was trained for the very low rates in the paper:
M Careil, MJ Muckley, J Verbeek, S Lathuliere.
Towards image compression with perfect realism at ultra-low bitrates.
In *ICLR*, 2024.
The target bitrate is 0.00218 bits per pixel
The pretrained weights are released under the CC-BY-NC 4.0 license
available at
https://github.com/facebookresearch/NeuralCompression/blob/main/WEIGHTS_LICENSE
pretrained (bool): kwargs, load pretrained weights into the model
"""

return _msillm_quality_vlo1(pretrained=pretrained, **kwargs)


def msillm_quality_vlo2(pretrained=True, **kwargs):
"""
Pretrained MS-ILLM model
This model was trained for the very low rates in the paper:
M Careil, MJ Muckley, J Verbeek, S Lathuliere.
Towards image compression with perfect realism at ultra-low bitrates.
In *ICLR*, 2024.
The target bitrate is 0.00438 bits per pixel
The pretrained weights are released under the CC-BY-NC 4.0 license
available at
https://github.com/facebookresearch/NeuralCompression/blob/main/WEIGHTS_LICENSE
pretrained (bool): kwargs, load pretrained weights into the model
"""

return _msillm_quality_vlo2(pretrained=pretrained, **kwargs)


def msillm_quality_1(pretrained=True, **kwargs):
"""
Pretrained MS-ILLM model
Expand Down
2 changes: 2 additions & 0 deletions neuralcompression/zoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
msillm_quality_4,
msillm_quality_5,
msillm_quality_6,
msillm_quality_vlo1,
msillm_quality_vlo2,
)
from ._msillm_vqvae import vqvae_xcit_p8_ch64_cb1024_h8
from ._noganms import (
Expand Down
20 changes: 20 additions & 0 deletions neuralcompression/zoo/_msillm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
LOGGER = logging.getLogger(__file__)

VALID_WEIGHTS = [
"target_0.00218bpp",
"target_0.00438bpp",
"target_0.035bpp",
"target_0.07bpp",
"target_0.14bpp",
Expand Down Expand Up @@ -48,6 +50,24 @@ def _build_msillm(weights: Optional[str] = None):
return model


def msillm_quality_vlo1(pretrained=False, **kwargs):
if pretrained is True:
weights = "target_0.00218bpp"
else:
weights = None

return _build_msillm(weights=weights)


def msillm_quality_vlo2(pretrained=False, **kwargs):
if pretrained is True:
weights = "target_0.00438bpp"
else:
weights = None

return _build_msillm(weights=weights)


def msillm_quality_1(pretrained=False, **kwargs):
if pretrained is True:
weights = "target_0.035bpp"
Expand Down

0 comments on commit 8e9c2ed

Please sign in to comment.