yifeipet/AFP-GIC

Space

AFP-GIC: Interactive Compression Demo

1

10 commits

1 linked in READMEs

updated Oct 4, 2026

See the code

README

AFP-GIC: Interactive Compression Demo

Adaptive Fused Prior Transfer for Controllable Generative Image Compression

Yifei Pei, Ying Liu, and Nam Ling. IEEE Access, 2026.

Paper · Code · arXiv

Features

  • Three Kodak examples with the paper's saved reconstructions at all five operating points.
  • Original/reconstruction comparison slider and separate image views.
  • Live compression and decompression for uploaded images using the public checkpoint.
  • Independent .afp upload and decompression without the original image.
  • Actual bpp computed from the serialized bitstream, including headers and payload lengths.
  • Saved-RGB PSNR and single-scale SSIM for live uploads; paper metrics for cached examples.
  • Downloads for reconstruction PNG, live bitstream, and metrics CSV.

The five target labels are nominal operating points, not guaranteed per-image bitrates. Cached examples are labeled as paper examples and do not pretend to be live inference. Only live inference provides bitstreams and session timing. Standalone decompression reports dimensions, bitrate, and operating point, not reference-based quality metrics. It accepts this model's .afp files, not arbitrary archive formats. Uploaded entropy streams are parsed with size bounds. Live operations use a Gradio queue and, on ZeroGPU hardware, a GPU allocation limited to 120 seconds per request. Timing is not comparable to the paper's unified benchmark. Uploads retain their original resolution after EXIF orientation by default; optional Resize mode limits the longest edge to 1024, 1536 or 2048 pixels without upscaling. Metrics use the actual RGB encoder input, so resized results are not full-resolution quality comparisons. The demo accepts up to 12 MiB and 24 megapixels, with each dimension between 64 and 65535 pixels. Resource limits may prevent processing large images; there is no automatic downscaling. Inputs are converted to RGB; transparent pixels are composited over white. Results expire after one hour.

Deploy to Hugging Face

  1. Create a Gradio Space. Upload this folder's deployment files, preserving static/ and public_release/. Do not upload .venv or test artifacts.
  2. The paper-example browser works without model weights.
  3. For live inference, upload the trusted public checkpoint unchanged to checkpoint/afp_gic_release.pth.tar. A separate model repository is optional.
  4. If using a separate model repository, set AFP_MODEL_REPO in Space Settings. The default filename is afp_gic_release.pth.tar; change AFP_MODEL_FILENAME if needed. Optionally pin AFP_MODEL_REVISION to a verified commit. For private model repos, store a read-only token as the HF_TOKEN secret, never in source code.
  5. Explicitly select ZeroGPU hardware. Account eligibility is required; adding the decorator on CPU Basic does not allocate a GPU. Queues and quotas apply. Do not select an hourly billed GPU unless you intend to pay for it.

Alternatively, set AFP_CHECKPOINT to a checkpoint already present inside the container. Only load your trusted release checkpoint. Do not accept user-supplied checkpoints.

No Space, model repository, paid hardware, or public upload is created by these files. Check Hugging Face's current account eligibility and hardware pricing before deployment.

Local execution

Use Python 3.10 and the pinned deployment stack:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export AFP_CHECKPOINT=/absolute/path/to/afp_gic_release.pth.tar
python zerogpu_app.py

Run exactly one worker: the codec lock and admission control are process-local. One live request runs at a time; up to eight requests can wait in the Gradio queue. AFP_DEVICE=cpu forces CPU evaluation. AFP_CPU_THREADS defaults to 2. Results are stored in a dedicated temporary directory and expire after one hour. Local tests do not validate cloud GPU allocation or account quotas; test these after upload.

Rights and attribution

The public runtime is copied unchanged from the AFP-GIC evaluation release. The demo adapter maps CompressAI's renamed entropy-bottleneck keys and strictly checks every checkpoint key; it does not modify the trained weight values. Images narrower than the released tiler's 512-pixel window use whole-frame decoding in the adapter, without resizing. The license and third-party notices apply; this demo does not relicense the model or its dependencies. The example images are Kodak benchmark material, not newly authored images. Confirm the applicable image redistribution terms before publishing the Space. Uploaded images remain the uploader's responsibility and are not used for training.

The interface uses Lucide icons (ISC license; see static/vendor/LUCIDE_LICENSE). The vendored Gradio browser client uses Apache-2.0 (see static/vendor/GRADIO_CLIENT_LICENSE).

gradio

yifeipet/AFP-GIC

Space

AFP-GIC: Interactive Compression Demo

1

10 commits

1 linked in READMEs

updated Oct 4, 2026

See the code

README

AFP-GIC: Interactive Compression Demo

Adaptive Fused Prior Transfer for Controllable Generative Image Compression

Yifei Pei, Ying Liu, and Nam Ling. IEEE Access, 2026.

Paper · Code · arXiv

Features

  • Three Kodak examples with the paper's saved reconstructions at all five operating points.
  • Original/reconstruction comparison slider and separate image views.
  • Live compression and decompression for uploaded images using the public checkpoint.
  • Independent .afp upload and decompression without the original image.
  • Actual bpp computed from the serialized bitstream, including headers and payload lengths.
  • Saved-RGB PSNR and single-scale SSIM for live uploads; paper metrics for cached examples.
  • Downloads for reconstruction PNG, live bitstream, and metrics CSV.

The five target labels are nominal operating points, not guaranteed per-image bitrates. Cached examples are labeled as paper examples and do not pretend to be live inference. Only live inference provides bitstreams and session timing. Standalone decompression reports dimensions, bitrate, and operating point, not reference-based quality metrics. It accepts this model's .afp files, not arbitrary archive formats. Uploaded entropy streams are parsed with size bounds. Live operations use a Gradio queue and, on ZeroGPU hardware, a GPU allocation limited to 120 seconds per request. Timing is not comparable to the paper's unified benchmark. Uploads retain their original resolution after EXIF orientation by default; optional Resize mode limits the longest edge to 1024, 1536 or 2048 pixels without upscaling. Metrics use the actual RGB encoder input, so resized results are not full-resolution quality comparisons. The demo accepts up to 12 MiB and 24 megapixels, with each dimension between 64 and 65535 pixels. Resource limits may prevent processing large images; there is no automatic downscaling. Inputs are converted to RGB; transparent pixels are composited over white. Results expire after one hour.

Deploy to Hugging Face

  1. Create a Gradio Space. Upload this folder's deployment files, preserving static/ and public_release/. Do not upload .venv or test artifacts.
  2. The paper-example browser works without model weights.
  3. For live inference, upload the trusted public checkpoint unchanged to checkpoint/afp_gic_release.pth.tar. A separate model repository is optional.
  4. If using a separate model repository, set AFP_MODEL_REPO in Space Settings. The default filename is afp_gic_release.pth.tar; change AFP_MODEL_FILENAME if needed. Optionally pin AFP_MODEL_REVISION to a verified commit. For private model repos, store a read-only token as the HF_TOKEN secret, never in source code.
  5. Explicitly select ZeroGPU hardware. Account eligibility is required; adding the decorator on CPU Basic does not allocate a GPU. Queues and quotas apply. Do not select an hourly billed GPU unless you intend to pay for it.

Alternatively, set AFP_CHECKPOINT to a checkpoint already present inside the container. Only load your trusted release checkpoint. Do not accept user-supplied checkpoints.

No Space, model repository, paid hardware, or public upload is created by these files. Check Hugging Face's current account eligibility and hardware pricing before deployment.

Local execution

Use Python 3.10 and the pinned deployment stack:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export AFP_CHECKPOINT=/absolute/path/to/afp_gic_release.pth.tar
python zerogpu_app.py

Run exactly one worker: the codec lock and admission control are process-local. One live request runs at a time; up to eight requests can wait in the Gradio queue. AFP_DEVICE=cpu forces CPU evaluation. AFP_CPU_THREADS defaults to 2. Results are stored in a dedicated temporary directory and expire after one hour. Local tests do not validate cloud GPU allocation or account quotas; test these after upload.

Rights and attribution

The public runtime is copied unchanged from the AFP-GIC evaluation release. The demo adapter maps CompressAI's renamed entropy-bottleneck keys and strictly checks every checkpoint key; it does not modify the trained weight values. Images narrower than the released tiler's 512-pixel window use whole-frame decoding in the adapter, without resizing. The license and third-party notices apply; this demo does not relicense the model or its dependencies. The example images are Kodak benchmark material, not newly authored images. Confirm the applicable image redistribution terms before publishing the Space. Uploaded images remain the uploader's responsibility and are not used for training.

The interface uses Lucide icons (ISC license; see static/vendor/LUCIDE_LICENSE). The vendored Gradio browser client uses Apache-2.0 (see static/vendor/GRADIO_CLIENT_LICENSE).

gradio