🚀 TF-ID:学術論文の表/図識別器
TF-ID(Table/Figure IDentifier)は、胡逸飛によって作成された一連の物体検出モデルです。このモデルは、微調整を行うことで学術論文から表と図を抽出するために使用できます。このモデルは、科研者が学術文献内の図表情報をより効率的に処理するのに役立つ、非常に実用的な価値を持っています。
🚀 クイックスタート
以下のコードを使って、このモデルを使用し始めましょう。
import requests
from PIL import Image
from transformers import AutoProcessor, AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("yifeihu/TF-ID-base", trust_remote_code=True)
processor = AutoProcessor.from_pretrained("yifeihu/TF-ID-base", trust_remote_code=True)
prompt = "<OD>"
url = "https://huggingface.co/yifeihu/TF-ID-base/resolve/main/arxiv_2305_10853_5.png?download=true"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=prompt, images=image, return_tensors="pt")
generated_ids = model.generate(
input_ids=inputs["input_ids"],
pixel_values=inputs["pixel_values"],
max_new_tokens=1024,
do_sample=False,
num_beams=3
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
parsed_answer = processor.post_process_generation(generated_text, task="<OD>", image_size=(image.width, image.height))
print(parsed_answer)
結果を視覚化するには、このチュートリアルノートブックを参照して詳細を確認してください。
✨ 主な機能
- TF-IDモデルには4つのバージョンがあり、必要に応じてタイトルテキストを含むまたは含まない表と図を抽出することができます。
- すべてのTF-IDモデルは、microsoft/Florence - 2のチェックポイントを基に微調整されています。
- モデルは、単ページの学術論文の画像を入力として受け取り、指定されたページ内のすべての表と図のバウンディングボックスを返します。
💻 使用例
基本的な使用法
import requests
from PIL import Image
from transformers import AutoProcessor, AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("yifeihu/TF-ID-base", trust_remote_code=True)
processor = AutoProcessor.from_pretrained("yifeihu/TF-ID-base", trust_remote_code=True)
prompt = "<OD>"
url = "https://huggingface.co/yifeihu/TF-ID-base/resolve/main/arxiv_2305_10853_5.png?download=true"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=prompt, images=image, return_tensors="pt")
generated_ids = model.generate(
input_ids=inputs["input_ids"],
pixel_values=inputs["pixel_values"],
max_new_tokens=1024,
do_sample=False,
num_beams=3
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
parsed_answer = processor.post_process_generation(generated_text, task="<OD>", image_size=(image.width, image.height))
print(parsed_answer)
📚 ドキュメント
モデル概要
TF-ID(Table/Figure IDentifier)は、一連の物体検出モデルで、4つのバージョンがあります。
モデル |
モデルサイズ |
モデル説明 |
TF-ID-base[HF] |
0.23B |
表/図とそのタイトルテキストを抽出 |
TF-ID-large[HF](推奨) |
0.77B |
表/図とそのタイトルテキストを抽出 |
TF-ID-base-no-caption[HF] |
0.23B |
表/図を抽出(タイトルテキストを含まない) |
TF-ID-large-no-caption[HF](推奨) |
0.77B |
表/図を抽出(タイトルテキストを含まない) |
すべてのTF-IDモデルは、microsoft/Florence - 2のチェックポイントを基に微調整されています。
- モデルは、Hugging Face Daily Papersの論文を使用して微調整されており、すべてのバウンディングボックスは手動で注釈付けされ、確認されています。
- TF-IDモデルは、単ページの学術論文の画像を入力として受け取り、指定されたページ内のすべての表と図のバウンディングボックスを返します。
- TF-ID-baseとTF-ID-largeは、表/図とそのタイトルテキストの周りにバウンディングボックスを描画します。
- TF-ID-base-no-captionとTF-ID-large-no-captionは、表/図の周りにバウンディングボックスを描画しますが、タイトルテキストは含みません。
大きなモデルの使用を強くおすすめします!

物体検出結果の形式:
{'': {'bboxes': [[x1, y1, x2, y2], ...],
'labels': ['label1', 'label2', ...]} }
訓練コードとデータセット
ベンチマークテスト
私たちは、訓練データセット以外の論文ページでモデルをテストしました。これらの論文は、Hugging Faceの毎日の論文のサブセットです。
正しい出力 - モデルが指定されたページ内の各表/図に正しいバウンディングボックスを描画する。
モデル |
総画像数 |
正しい出力数 |
成功率 |
TF-ID-base[HF] |
258 |
251 |
97.29% |
TF-ID-large[HF] |
258 |
253 |
98.06% |
モデル |
総画像数 |
正しい出力数 |
成功率 |
TF-ID-base-no-caption[HF] |
261 |
253 |
96.93% |
TF-ID-large-no-caption[HF] |
261 |
254 |
97.32% |
使用シーンによっては、一部の「不正解」出力でも十分に使用可能な場合があります。例えば、モデルが2つのサブコンポーネントを含む画像に2つのバウンディングボックスを描画する場合です。
📄 ライセンス
このプロジェクトはMITライセンスを採用しており、詳細はライセンスリンクを参照してください。
📖 BibTexと引用情報
@misc{TF-ID,
author = {Yifei Hu},
title = {TF-ID: Table/Figure IDentifier for academic papers},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/ai8hyf/TF-ID}},
}