Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add very low MS-ILLM rates #241

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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