All Projects → caoscott → Srec

caoscott / Srec

Licence: mit
PyTorch Implementation of "Lossless Image Compression through Super-Resolution"

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Srec

Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (-20.05%)
Mutual labels:  compression
Compressonator
Tool suite for Texture and 3D Model Compression, Optimization and Analysis using CPUs, GPUs and APUs
Stars: ✭ 785 (-9.56%)
Mutual labels:  compression
Compressed Vec
SIMD Floating point and integer compressed vector library
Stars: ✭ 25 (-97.12%)
Mutual labels:  compression
Lz4
Extremely Fast Compression algorithm
Stars: ✭ 6,623 (+663.02%)
Mutual labels:  compression
Minizip Ng
Fork of the popular zip manipulation library found in the zlib distribution.
Stars: ✭ 750 (-13.59%)
Mutual labels:  compression
Zlib Ng
zlib replacement with optimizations for "next generation" systems.
Stars: ✭ 807 (-7.03%)
Mutual labels:  compression
Caesium Image Compressor
Caesium is a cross-platform image compression software aimed at helping photographers, bloggers, webmasters, businesses or casual users at storing, sending and sharing digital pictures. Based on libcaesium.
Stars: ✭ 595 (-31.45%)
Mutual labels:  compression
Image Actions
A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
Stars: ✭ 844 (-2.76%)
Mutual labels:  compression
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (-12.21%)
Mutual labels:  compression
Blosc.jl
Blosc compression for the Julia language
Stars: ✭ 24 (-97.24%)
Mutual labels:  compression
Acl
Animation Compression Library
Stars: ✭ 716 (-17.51%)
Mutual labels:  compression
C Blosc
A blocking, shuffling and loss-less compression library that can be faster than `memcpy()`.
Stars: ✭ 742 (-14.52%)
Mutual labels:  compression
Peazip
Free Zip / Unzip software and Rar file extractor. Cross-platform file and archive manager. Features volume spanning, compression, authenticated encryption. Supports 7Z, 7-Zip sfx, ACE, ARJ, Brotli, BZ2, CAB, CHM, CPIO, DEB, GZ, ISO, JAR, LHA/LZH, NSIS, OOo, PAQ/LPAQ, PEA, QUAD, RAR, RPM, split, TAR, Z, ZIP, ZIPX, Zstandard.
Stars: ✭ 827 (-4.72%)
Mutual labels:  compression
Wavideobox
秒级! 三行代码实现iOS视频压缩、变速、混音、合并、GIF水印、旋转、换音、裁剪 ! 支持不同分辩率,支持你能想到的各种混合操作! 扩展性强...更多功能不断增加中... iOS 8.0 + 有需要的功能或错误欢迎issue,笔者会及时更新
Stars: ✭ 707 (-18.55%)
Mutual labels:  compression
Scn
Scale-wise Convolution for Image Restoration
Stars: ✭ 26 (-97%)
Mutual labels:  compression
Bareos
Main repository with the code for the libraries and daemons
Stars: ✭ 651 (-25%)
Mutual labels:  compression
Gan Compression
[CVPR 2020] GAN Compression: Efficient Architectures for Interactive Conditional GANs
Stars: ✭ 800 (-7.83%)
Mutual labels:  compression
Lib
single header libraries for C/C++
Stars: ✭ 866 (-0.23%)
Mutual labels:  compression
Nippy
High-performance serialization library for Clojure
Stars: ✭ 838 (-3.46%)
Mutual labels:  compression
Borgmatic
Simple, configuration-driven backup software for servers and workstations
Stars: ✭ 902 (+3.92%)
Mutual labels:  compression

Lossless Image Compression through Super-Resolution

Sheng Cao, Chao-Yuan Wu, Philipp Krähenbühl.

[Paper]

Citation

@article{cao2020lossless,
  title={Lossless Image Compression through Super-Resolution},
  author={Cao, Sheng and Wu, Chao-Yuan and and Kr{\"a}henb{\"u}hl, Philipp},
  year={2020},
  journal={arXiv preprint arXiv:2004.02872},
}

If you use our codebase, please consider also citing L3C

Overview

This is the official implementation of SReC in PyTorch. SReC frames lossless compression as a super-resolution problem and applies neural networks to compress images. SReC can achieve state-of-the-art compression rates on large datasets with practical runtimes. Training, compression, and decompression are fully supported and open-sourced.

Getting Started

We recommend the following steps for getting started.

  1. Install the necessary dependencies
  2. Download the Open Images validation set
  3. Run compression on Open Images validation set with trained model weights

Installation

See here for installation instructions.

Model Weights

We've released trained models for both ImageNet64 and Open Images (PNG). All compression results are measured in bits per subpixel (bpsp).

Dataset Bpsp Model Weights
ImageNet64 4.29 models/imagenet64.pth
Open Images 2.70 models/openimages.pth

Training

To run code, you need to be in top level directory.

python3 -um src.train \
  --train-path "path to directory of training images" \
  --train-file "list of filenames of training images, one filename per line" \
  --eval-path "path to directory of eval images" \
  --eval-file "list of filenames of eval images, one filename per line" \
  --plot "directory to store model output" \
  --batch "batch size"

The training images must be organized in form of train-path/filename from filename in train-file. Same thing applies to eval images.

We've included our training and eval files used for ImageNet64 and Open Images (PNG) in datasets directory.

For ImageNet64, we use a slightly different set of hyperparameters than Open Images hyperparameters, which are the default. To train ImageNet64 based on settings from our paper, run

python3 -um src.train \
  --train-path "path to directory of training images" \
  --train-file "list of filenames of training images, one filename per line" \
  --eval-path "path to directory of eval images" \
  --eval-file "list of filenames of eval images, one filename per line" \
  --plot "directory to store model output" \
  --batch "batch size" \
  --epochs 10 \
  --lr-epochs 1 \
  --crop 64

Run python3 -um src.train --help for a list of tunable hyperparameters.

Evaluation

Given a model checkpoint, this evaluates theoretical bits/subpixel (bpsp) based on log-likelihood. The log-likelihood bpsp lower-bounds the actual compression bpsp.

python3 -um src.eval \
  --path "path to directory of images" \
  --file "list of filenames of images, one filename per line" \
  --load "path to model weights"

Compression/Decompression

With torchac installed, you can run compression/decompression to convert any image into .srec files. The following compresses a directory of images.

python3 -um src.encode \
  --path "path to directory of images" \ 
  --file "list of filenames of images, one filename per line" \
  --save-path "directory to save new .srec files" \
  --load "path to model weights"

If you want an accurate runtime, we recommend running python with -O flag to disable asserts. We also include an optional --decode flag so that you can check if decompressing the .srec file gives the original image, as well as provide runtime for decoding.

To convert .srec files into PNG, you can run

python3 -um src.decode \
  --path "path to directory of .srec images" \ 
  --file "list of filenames of .srec images, one filename per line" \
  --save-path "directory to save png files" \
  --load "path to model weights"

Downloading ImageNet64

You can download ImageNet64 training and validation sets here.

Preparing Open Images Dataset (PNG)

We use the same set of training and validation images of Open Images as L3C.

For validation images, you can download them here.

For training images, please clone the L3C repo and run script from here

See this issue for differences between Open Images JPEG and Open Images PNG.

Acknowledgment

Thanks to L3C for implementations of EDSR, logistic mixtures, and arithmetic coding. Special thanks to Fabian Mentzer for letting us know about issues with the preprocessing script for Open Images JPEG and resolving them quickly.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].