Skip to main content

Official implementation of Charm tokenizer for ViTs

Project description

Charm: The Missing Piece in ViT fine-tuning for Image Aesthetic Assessment

Accepted at CVPR 2025

We introduce Charm , a novel tokenization approach that preserves Composition, High-resolution, Aspect Ratio, and Multi-scale information simultaneously. By preserving critical aesthetic information, Charm achieves significant performance improvement across different image aesthetic assessment datasets.

Quick Inference

  • Step 1) Check our GitHub Page and install the requirements.
pip install -r requirements.txt
  • Step 2) Install Charm tokenizer.
pip install Charm_tokenizer
  • Step 3) Tokenization + Position embedding preparation
from Charm_tokenizer.ImageProcessor import Charm_Tokenizer

img_path = r"img.png"

charm_tokenizer = Charm_Tokenizer(patch_selection='frequency', training_dataset='tad66k', without_pad_or_dropping=True)
tokens, pos_embed, mask_token = charm_tokenizer.preprocess(img_path)

The mask_token indicates which patches are in high resolution and which are in low resolution.

  • Step 4) Predicting aesthetic score
from Charm_tokenizer.Backbone import backbone

model = backbone(training_dataset='tad66k', device='cpu')
prediction = model.predict(tokens, pos_embed, mask_token)

Note:

  1. While random patch selection during training helps avoid overfitting,for consistent results during inference, fully deterministic patch selection approaches should be used.
  2. For the training code, check our GitHub Page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Charm_tokenizer-1.0.9.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Charm_tokenizer-1.0.9-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file Charm_tokenizer-1.0.9.tar.gz.

File metadata

  • Download URL: Charm_tokenizer-1.0.9.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for Charm_tokenizer-1.0.9.tar.gz
Algorithm Hash digest
SHA256 cf5a03f6096a007bbae4405ab600601487f47973845eb9822c2525216eda2924
MD5 0bf75ba231ef9f0e5a8033237347d5ec
BLAKE2b-256 3ad738b6ca9bcb6992fd587a849efcf2cac67f9bacffc489488d5a642c79a668

See more details on using hashes here.

File details

Details for the file Charm_tokenizer-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for Charm_tokenizer-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 96bf67f3668d3bb483ce55b05dcb75c4cc77fafe514c665586bb7c515e869d7c
MD5 99eb77ea674b4426ec375122c175d847
BLAKE2b-256 068150f1ac59144e3d423cf615598ba19dc58d1ea4d6c0c254a9e0bc32a936cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page