Instructions to use timm/vit_base_patch16_224.bamboo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use timm/vit_base_patch16_224.bamboo with timm:
import timm model = timm.create_model("hf-hub:timm/vit_base_patch16_224.bamboo", pretrained=True) - Notebooks
- Google Colab
- Kaggle
vit_base_patch16_224.bamboo
A ViT-B/16 pretrained on Bamboo-CLS, converted from the
authors' release to native timm weights. No fine-tuning or weight rescaling was performed.
The checkpoint wrapper and any module. prefix were removed. The original 115,217-class classifier is retained.
Model details
- Paper: Bamboo
- Parameters: 174,400,529
- Input: RGB, 224 x 224
- Classifier outputs: 115,217
- Feature dimension: 768
- Training data: Bamboo-CLS
Preprocessing
Uses the authors' benchmark configuration: bicubic resize of the shorter side
to 224, then a 224 x 224 center crop (crop_pct=1.0).
- Mean:
(0.48145466, 0.4578275, 0.40821073) - Standard deviation:
(0.26862954, 0.26130258, 0.27577711)
The ViT benchmark uses CLIP normalization; the ResNet benchmark uses ImageNet normalization. The authors' separate ViT classification demo uses a different recipe. This export follows the benchmark.
Usage
import timm
import torch
from PIL import Image
model = timm.create_model("hf-hub:timm/vit_base_patch16_224.bamboo", pretrained=True).eval()
transform = timm.data.create_transform(**timm.data.resolve_model_data_config(model), is_training=False)
image = Image.open("image.jpg").convert("RGB")
with torch.inference_mode():
output = model(transform(image).unsqueeze(0))
probabilities, indices = output.softmax(dim=-1).topk(5)
labels = model.pretrained_cfg["label_names"]
descriptions = model.pretrained_cfg["label_descriptions"]
for index, probability in zip(indices[0].tolist(), probabilities[0].tolist()):
label_id = labels[index]
print(label_id, descriptions[label_id], probability)
Labels
config.json includes label_names (classifier index to stable Bamboo concept ID) and
label_descriptions (concept ID to English names/synonyms). Indices are ordered numerically
using the authors' trainid2nid.json, not the ordering of the broader Bamboo taxonomy.
The original trainid2name.json and trainid2nid.json are included alongside the weights.
Names are not unique: distinct concepts can share an English name. Preserve concept IDs
when interpreting predictions. Blank source names use their concept ID as a fallback.
Fallback rows: 5831 (Q24760423).
Pass num_classes=0 to extract pooled 768-dimensional features, or set num_classes
to replace the pretrained classifier for fine-tuning.
Source and licensing
Source URLs and SHA256 hashes are recorded in conversion.json.
The authors' demo metadata declares CC-BY-4.0;
the dataset access instructions state academic,
non-commercial use. These are upstream statements, not a new license grant for the converted weights.
Citation
@misc{zhang2022bamboo,
title={Bamboo: Building Mega-Scale Vision Dataset Continually with Human-Machine Synergy},
author={Yuanhan Zhang and Qinghong Sun and Yichun Zhou and Zexin He and Zhenfei Yin and
Kun Wang and Lu Sheng and Yu Qiao and Jing Shao and Ziwei Liu},
year={2022},
eprint={2203.07845},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
- Downloads last month
- -