Instructions to use gperdrizet/compression_autoencoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use gperdrizet/compression_autoencoder with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://gperdrizet/compression_autoencoder") - Notebooks
- Google Colab
- Kaggle
Image compression autoencoder
A convolutional autoencoder trained to compress 256ร256 RGB images into a compact 1024-dimensional latent representation, achieving 192ร compression ratio.
Model description
This model learns to compress high-quality images by encoding them into a compact latent space, then reconstructing them with minimal quality loss. The encoder reduces a 196,608-value image (256ร256ร3) to just 1024 numbers, while the decoder reconstructs the original image from this compressed representation.
Architecture:
- Encoder: Convolutional layers with downsampling (256ร256ร3 โ 2048)
- Decoder: Transposed convolutional layers with upsampling (2048 โ 256ร256ร3)
- Activation: LeakyReLU and Sigmoid
- Normalization: Batch normalization
Performance:
- Compression ratio: 96ร
- PSNR: ~22 dB dB
- SSIM: >0.52
Intended use
This model is designed for educational purposes to demonstrate how autoencoders can learn compression automatically from data, rather than using hand-crafted rules like JPEG or PNG.
Use cases:
- Understanding autoencoder architectures
- Learning about lossy compression
- Exploring latent space representations
- Teaching AI/ML concepts in bootcamps
Training data
Trained on DF2K_OST, a combined dataset of 26.8k high-quality images from:
- DIV2K
- Flickr2K
- OutdoorSceneTraining
All images resized to 256ร256 pixels using Lanczos resampling.
Training details
Hyperparameters:
- Optimizer: Adam (lr=1e-3)
- Loss function: Mean Squared Error (MSE)
- Batch size: 4
- Epochs: Up to 100 (with early stopping)
- Train/validation split: 90/10
Callbacks:
- Early stopping (patience=10, monitoring validation loss)
- Learning rate reduction (factor=0.5, patience=5)
- Model checkpoint (best validation loss)
Hardware:
- Single NVIDIA P100 GPU with memory growth enabled
How to use
import shutil
from tensorflow import keras
from huggingface_hub import hf_hub_download
# Download model
downloaded_model = hf_hub_download(
repo_id='gperdrizet/compression_autoencoder',
filename='models/compression_ae.keras',
repo_type='model'
)
# Load model
autoencoder = keras.models.load_model(downloaded_model)
# Use for compression/decompression
compressed = autoencoder.predict(images) # images shape: (N, 256, 256, 3)
For complete examples, see the training notebook.
Limitations
- Fixed input size (256ร256 RGB images)
- Lossy compression (some quality loss)
- Not optimized for specific image types
- Slower than traditional codecs
- Educational model, not production-ready
Project repository
Full code, training notebooks, and interactive demo: gperdrizet/autoencoders
Citation
If you use this model for educational purposes, please reference the project repository.
- Downloads last month
- 69