--- library_name: timm pipeline_tag: image-classification tags: - timm - bamboo - arxiv:2203.07845 --- # vit_base_patch16_224.bamboo A ViT-B/16 pretrained on Bamboo-CLS, converted from the [authors' release](https://github.com/ZhangYuanhan-AI/Bamboo) 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](https://arxiv.org/abs/2203.07845) - 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](https://github.com/ZhangYuanhan-AI/Bamboo/blob/f6337a76b3e48a1c5eff2bbd5b9dd044e42f0654/Bamboo-Benchmark/configs/models_cfg/ViTB16_bamboo_v0_1.yaml): 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 ```python 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](https://huggingface.co/spaces/CVPR/Bamboo_ViT-B16_demo/blob/2bbf27dfb670d5e1b1d3f1e0b97596f95e4c62a0/README.md) declares CC-BY-4.0; the [dataset access instructions](https://github.com/ZhangYuanhan-AI/Bamboo/tree/f6337a76b3e48a1c5eff2bbd5b9dd044e42f0654#downloads) state academic, non-commercial use. These are upstream statements, not a new license grant for the converted weights. ## Citation ```bibtex @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} } ```