Skip to main content

Calculate the number of tokens used for images in vision language models

Project description

Vision Token Calculator

A Python tool for calculating the number of tokens generated when processing images with various Vision Language Models (VLMs).

Features

  • Calculate image tokens for different VLMs
  • Support for both existing images and dummy images
  • Detailed token analysis including image size and token count
  • Easy-to-use command line interface

Installation

Option 1: Install as editable package (recommended)

pip install -e .

This will install the package in development mode and make the vt-calc command available system-wide.

Option 2: Install dependencies only

pip install -r requirements.txt

Usage

Method 1: Using the vt-calc command (after pip install -e .)

After installing with pip install -e ., you can use the vt-calc command directly:

# Using an existing image
vt-calc --image path/to/your/image.jpg

# Creating a dummy image with specific dimensions
vt-calc --size 1920 1080

# Specifying a different model
vt-calc --image path/to/your/image.jpg --model-path "model/path"

Method 2: Direct python execution

# Using an existing image
python calculate.py --image path/to/your/image.jpg

# Creating a dummy image with specific dimensions
python calculate.py --size 1920 1080

# Specifying a different model
python calculate.py --image path/to/your/image.jpg --model-path "model/path"

Supported Models

Model Model size
Qwen2.5-VL 3B / 7B / 32B / 72B
Gemma3 4B / 12B / 27B
InternVL3 1B / 2B / 8B / 14B / 38B / 78B

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

vt_calc-0.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

vt_calc-0.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file vt_calc-0.0.2.tar.gz.

File metadata

  • Download URL: vt_calc-0.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for vt_calc-0.0.2.tar.gz
Algorithm Hash digest
SHA256 777d6cf5fd9da8dd8251db272a267707665f2c80e7532292c7e3ec1c0d8081c7
MD5 4a07f57c02b47e0d419936421790cfe8
BLAKE2b-256 61f20daae55d576888056cc2d236cf4973f49412f563675ed9f44aee47bf45b7

See more details on using hashes here.

File details

Details for the file vt_calc-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: vt_calc-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for vt_calc-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cf38e3b5250c9e5a18ae992aff2288f840f6e82871b35a3d7aef227b23be1ab6
MD5 3244f66fb9bd385a07262320a6574c9a
BLAKE2b-256 6eceafe9a9b16cd6ce90051bf520529c0d986ed7e15a1d530538322c91b8c584

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