ILSVRC/imagenet-1k
Viewer • Updated • 1.43M • 87.4k • 804
How to use INC4AI/vit-base-patch16-224-int8-static-inc with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-classification", model="INC4AI/vit-base-patch16-224-int8-static-inc")
pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png") # Load model directly
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("INC4AI/vit-base-patch16-224-int8-static-inc")
model = AutoModelForImageClassification.from_pretrained("INC4AI/vit-base-patch16-224-int8-static-inc")# Load model directly
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("INC4AI/vit-base-patch16-224-int8-static-inc")
model = AutoModelForImageClassification.from_pretrained("INC4AI/vit-base-patch16-224-int8-static-inc")This is an INT8 PyTorch model quantized with Intel® Neural Compressor.
The original fp32 model comes from the fine-tuned model google/vit-base-patch16-224.
The calibration dataloader is the train dataloader. The default calibration sampling size 1000 because of 1000 classes of imagenet-1k.
The linear modules vit.encoder.layer.5.output.dense, vit.encoder.layer.9.attention.attention.query.module, fall back to fp32 for less than 1% relative accuracy loss.
| INT8 | FP32 | |
|---|---|---|
| Accuracy (eval-acc) | 80.576 | 81.326 |
| Model size (MB) | 94 | 331 |
from neural_compressor.utils.load_huggingface import OptimizedModel
int8_model = OptimizedModel.from_pretrained(
'Intel/vit-base-patch16-224-int8-static',
)
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="INC4AI/vit-base-patch16-224-int8-static-inc") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")