Close Menu
techwavedispatch.com

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    How To Get Better Results From Google Gemini

    November 14, 2026

    Accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO

    November 14, 2026

    That Key Left Of ‘1’ On Many Keyboards Is Actually Crucial For Programmers

    November 14, 2026
    Facebook X (Twitter) Instagram
    Trending
    • How To Get Better Results From Google Gemini
    • Accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO
    • That Key Left Of ‘1’ On Many Keyboards Is Actually Crucial For Programmers
    • Fine-Tune Whisper For Multilingual ASR with ๐Ÿค— Transformers
    • How To Clear The Cache On Your Xbox Series X
    • Training Stable Diffusion with Dreambooth using Diffusers
    • Here’s When A Dedicated Graphics Card Is Worth It
    • Elon Musk, other tech execs sign petition calling on Nvidia to reinstate Jensen Huang
    Facebook X (Twitter) Instagram
    techwavedispatch.com
    Subscribe
    Saturday, November 14
    • Home
    • AI Tools & Software
    • Machine Learning
    • Generative AI
    • Robotics & Automation
    • Future Tech & Hardware
    • AI in Business
    • Ethics & Regulations
    • More
      • Gadgets & Smart Devices
      • Cybersecurity & AI
      • Tech Breakthroughs
    techwavedispatch.com
    Home»AI Tools & Software»Accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO
    AI Tools & Software

    Accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO

    adminBy adminNovember 14, 2026No Comments5 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO
    Share
    Facebook Twitter LinkedIn Pinterest Email

    image

    Last July, we announced that Intel and Hugging Face would collaborate on building state-of-the-art yet simple hardware acceleration tools for Transformer models.
    โ€‹
    Today, we are very happy to announce that we added Intel OpenVINO to Optimum Intel. You can now easily perform inference with OpenVINO Runtime on a variety of Intel processors (see the full list of supported devices) using Transformers models which can be hosted either on the Hugging Face hub or locally. You can also quantize your model with the OpenVINO Neural Network Compression Framework (NNCF), and reduce its size and prediction latency in near minutes. โ€‹

    This first release is based on OpenVINO 2022.2 and enables inference for a large quantity of PyTorch models using our OVModels. Post-training static quantization and quantization aware training can be applied on many encoder models (BERT, DistilBERT, etc.). More encoder models will be supported in the upcoming OpenVINO release. Currently the quantization of Encoder Decoder models is not enabled, however this restriction should be lifted with our integration of the next OpenVINO release.

    โ€‹Let us show you how to get started in minutes!โ€‹



    Quantizing a Vision Transformer with Optimum Intel and OpenVINO

    โ€‹
    In this example, we will run post-training static quantization on a Vision Transformer (ViT) model fine-tuned for image classification on the food101 dataset.
    โ€‹

    Quantization is a process that lowers memory and compute requirements by reducing the bit width of model parameters. Reducing the number of bits means that the resulting model requires less memory at inference time, and that operations like matrix multiplication can be performed faster thanks to integer arithmetic.

    First, let’s create a virtual environment and install all dependencies.โ€‹

    virtualenv openvino
    source openvino/bin/activate
    pip install pip --upgrade
    pip install optimum[openvino,nncf] torchvision evaluate
    

    Next, moving to a Python environment, we import the appropriate modules and download the original model as well as its processor.
    โ€‹

    from transformers import AutoImageProcessor, AutoModelForImageClassification
    โ€‹
    model_id = "juliensimon/autotrain-food101-1471154050"
    model = AutoModelForImageClassification.from_pretrained(model_id)
    processor = AutoImageProcessor.from_pretrained(model_id)
    

    โ€‹
    Post-training static quantization requires a calibration step where data is fed through the network in order to compute the quantized activation parameters. Here, we take 300 samples from the original dataset to build the calibration dataset.
    โ€‹

    from optimum.intel.openvino import OVQuantizer
    โ€‹
    quantizer = OVQuantizer.from_pretrained(model)
    calibration_dataset = quantizer.get_calibration_dataset(
        "food101",
        num_samples=300,
        dataset_split="train",
    )
    

    As usual with image datasets, we need to apply the same image transformations that were used at training time. We use the preprocessing defined in the processor. We also define a data collation function to feed the model batches of properly formatted tensors.
    โ€‹

    import torch
    from torchvision.transforms import (
        CenterCrop,
        Compose,
        Normalize,
        Resize,
        ToTensor,
    )
    โ€‹
    normalize = Normalize(mean=processor.image_mean, std=processor.image_std)
    size = processor.size["height"]
    _val_transforms = Compose(
        [
            Resize(size),
            CenterCrop(size),
            ToTensor(),
            normalize,
        ]
    )
    def val_transforms(example_batch):
        example_batch["pixel_values"] = [_val_transforms(pil_img.convert("RGB")) for pil_img in example_batch["image"]]
        return example_batch
    โ€‹
    calibration_dataset.set_transform(val_transforms)
    โ€‹
    def collate_fn(examples):
        pixel_values = torch.stack([example["pixel_values"] for example in examples])
        labels = torch.tensor([example["label"] for example in examples])
        return {"pixel_values": pixel_values, "labels": labels}
    

    For our first attempt, we use the default configuration for quantization. You can also specify the number of samples to use during the calibration step, which is by default 300.

    from optimum.intel.openvino import OVConfig
    โ€‹
    quantization_config = OVConfig()
    quantization_config.compression["initializer"]["range"]["num_init_samples"] = 300
    

    We’re now ready to quantize the model. The OVQuantizer.quantize() method quantizes the model and exports it to the OpenVINO format. The resulting graph is represented with two files: an XML file describing the network topology and a binary file describing the weights. The resulting model can run on any target Intelยฎ device.

    save_dir = "quantized_model"
    
    
    quantizer.quantize(
        quantization_config=quantization_config,
        calibration_dataset=calibration_dataset,
        data_collator=collate_fn,
        remove_unused_columns=False,
        save_directory=save_dir,
    )
    processor.save_pretrained(save_dir)
    

    A minute or two later, the model has been quantized. We can then easily load it with our OVModelForXxx classes, the equivalent of the Transformers AutoModelForXxx classes found in the transformers library. Likewise, we can create pipelines and run inference with OpenVINO Runtime.
    โ€‹

    from transformers import pipeline
    from optimum.intel.openvino import OVModelForImageClassification
    โ€‹
    ov_model = OVModelForImageClassification.from_pretrained(save_dir)
    ov_pipe = pipeline("image-classification", model=ov_model, image_processor=processor)
    outputs = ov_pipe("http://farm2.staticflickr.com/1375/1394861946_171ea43524_z.jpg")
    print(outputs)
    

    โ€‹To verify that quantization did not have a negative impact on accuracy, we applied an evaluation step to compare the accuracy of the original model with its quantized counterpart. We evaluate both models on a subset of the dataset (taking only 20% of the evaluation dataset). We observed little to no loss in accuracy with both models having an accuracy of 87.6.

    from datasets import load_dataset
    from evaluate import evaluator
    
    
    eval_dataset = load_dataset("food101", split="validation").select(range(5050))
    task_evaluator = evaluator("image-classification")
    
    ov_eval_results = task_evaluator.compute(
        model_or_pipeline=ov_pipe,
        data=eval_dataset,
        metric="accuracy",
        label_mapping=ov_pipe.model.config.label2id,
    )
    
    trfs_pipe = pipeline("image-classification", model=model, image_processor=processor)
    trfs_eval_results = task_evaluator.compute(
        model_or_pipeline=trfs_pipe,
        data=eval_dataset,
        metric="accuracy",
        label_mapping=trfs_pipe.model.config.label2id,
    )
    print(trfs_eval_results, ov_eval_results)
    

    Looking at the quantized model, we see that its memory size decreased by 3.8x from 344MB to 90MB. Running a quick benchmark on 5050 image predictions, we also notice a speedup in latency of 2.4x, from 98ms to 41ms per sample. That’s not bad for a few lines of code!

    โš ๏ธ An important thing to mention is that the model is compiled just before the first inference, which will inflate the latency of the first inference. So before doing your own benchmark, make sure to first warmup your model by doing at least one prediction.

    You can find the resulting model hosted on the Hugging Face hub. To load it, you can easily do as follows:

    from optimum.intel.openvino import OVModelForImageClassification
    โ€‹
    ov_model = OVModelForImageClassification.from_pretrained("echarlaix/vit-food101-int8")
    



    Now it’s your turn

    โ€‹
    As you can see, it’s pretty easy to accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO. If you’d like to get started, please visit the Optimum Intel repository, and don’t forget to give it a star โญ. You’ll also find additional examples there. If you’d like to dive deeper into OpenVINO, the Intel documentation has you covered.

    โ€‹
    Give it a try and let us know what you think. We’d love to hear your feedback on the Hugging Face forum, and please feel free to request features or file issues on Github.
    โ€‹

    Have fun with ๐Ÿค— Optimum Intel, and thank you for reading.

    โ€‹

    Accelerate Intel Models OpenVINO Optimum
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    admin
    • Website

    Related Posts

    Fine-Tune Whisper For Multilingual ASR with ๐Ÿค— Transformers

    November 14, 2026

    Training Stable Diffusion with Dreambooth using Diffusers

    November 14, 2026

    Generating Human-level Text with Contrastive Search in Transformers ๐Ÿค—

    November 14, 2026
    Leave A Reply Cancel Reply

    Top Posts

    NVIDIA Is Investigating Reports That CEO Jensen Huang Was The Target Of Chinese Spy Efforts

    November 8, 202619 Views

    ADIndex: Layer-Adaptive Sparse Attention Indexing via Group-Level Distillation

    November 11, 20265 Views

    Anthropic releases new Mythos and Fable models amid RSI concerns

    November 9, 20265 Views

    One Policy for 100 Household Tasks: Our Solution for the 2026 BEHAVIOR Challenge

    November 11, 20264 Views
    Don't Miss
    Gadgets & Smart Devices

    How To Get Better Results From Google Gemini

    By adminNovember 14, 20260

    These tips and tricks will help you prompt Gemini better. Cheng…

    Accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO

    November 14, 2026

    That Key Left Of ‘1’ On Many Keyboards Is Actually Crucial For Programmers

    November 14, 2026

    Fine-Tune Whisper For Multilingual ASR with ๐Ÿค— Transformers

    November 14, 2026
    About Us

    Welcome to TechWave Dispatch

    At TechWave Dispatch, we bring you the latest news, insights, and developments from the ever-evolving world of technology. Our mission is to keep readers informed about the innovations shaping our digital future.

    From artificial intelligence and machine learning to cybersecurity, robotics, smart devices, and groundbreaking technologies, we cover the topics that matter in today's fast-moving tech landscape.

    Our Picks

    How To Get Better Results From Google Gemini

    November 14, 2026

    Accelerate your models with ๐Ÿค— Optimum Intel and OpenVINO

    November 14, 2026

    That Key Left Of ‘1’ On Many Keyboards Is Actually Crucial For Programmers

    November 14, 2026
    Most Popular

    Who Controls Scientific Discovery? โ€“ Oโ€™Reilly

    November 6, 20260 Views

    After blocking Muse, Amazon now lets users text Alexa to help them shop

    November 6, 20260 Views

    A controlled world for robot learning and evaluation

    November 6, 20260 Views
    Facebook X (Twitter) Instagram Pinterest
    • Terms and Conditions
    • Privacy Policy
    • Contact Us
    • About Us
    ยฉ 2026 TechWave Dispatch. All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.