Official implementation of Charm tokenizer for ViTs
Project description
💫 Charm: The Missing Piece in ViT fine-tuning for Image Aesthetic Assessment
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:
- While random patch selection during training helps avoid overfitting,for consistent results during inference, fully deterministic patch selection approaches should be used.
- For the training code, check our GitHub Page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Charm_tokenizer-1.0.8.tar.gz.
File metadata
- Download URL: Charm_tokenizer-1.0.8.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a338edba31ca226444b19de60e43a364abbb9c7ea9fd3910d6023d5bd744cc5c
|
|
| MD5 |
f0cb6e8d69c4430052c39c5f42f9e717
|
|
| BLAKE2b-256 |
97d9cf27382311ef54b3b986032a18b4e73042dd53a47928a12947ce32f06ace
|
File details
Details for the file Charm_tokenizer-1.0.8-py3-none-any.whl.
File metadata
- Download URL: Charm_tokenizer-1.0.8-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bebc8bfbc6c292d2629df59ac263da2c0f8b7fbf44d17e4f6afae8aae0356fe
|
|
| MD5 |
3fda4248469e7e67554f1a5708f52ddc
|
|
| BLAKE2b-256 |
c9365f76b2a14c19329f9ba5546d70a9dd8711a30dbf64c902262fbf6db9bc10
|