スクショ画像を圧縮すると実用的かつ安くなるか実験
from 画像からカレンダーに予定を登録するdiscord botを作る
スクショ画像を圧縮すると実用的かつ安くなるか実験
1024x1024だと4つのタイルになりますが、512x512なら1つのタイルで済むので、トークン数を大幅削減できる可能性があります。
簡単にテストしてみましょう:
⏺ Bash(opr python test_compression.py)
⎿  Original image size: 183642 bytes
Current (1024x1024, Q85):
… +28 lines (ctrl+o to expand)
⏺ すごい効果です!
トークン数の比較:
1024x1024: 1168 tokens
512x512: 304 tokens (約74%削減)
384x384: 178 tokens (約85%削減)
最新のテスト結果:
Input (Prompt): 576 tokens
Output (Completion): 3,327 tokens
Total: 3,903 tokens
料金計算:
Input: 576 tokens × $0.05/1M = $0.0000288(約0.003円)
Output: 3,327 tokens × $0.40/1M = $0.001331(約0.20円)
合計: $0.001360 (約0.20円) per image
従来の1024x1024設定との比較:
従来 Input: 2,411 tokens × $0.05/1M =$0.0001206
従来 Output: 1,666 tokens × $0.40/1M =$0.0006664
従来合計: $0.000787 (約0.12円)
結果:
圧縮によりInput コストは75%削減
複数イベント抽出でOutput コストは倍増
最終的に約0.08円のコスト増加
1日10枚の画像解析でも 約2円/日 なので、機能向
上を考えると非常にリーズナブルです!