Paint Your Dream with AI PC

OpenVINO™ toolkit
OpenVINO-toolkit
Published in
7 min readMay 16, 2024
An image of Rome generated by Latent Consistency Models, optimized by OpenVINO™.

Authors: Dmitriy Pastushenkov

Contributors: Ria Cheruvu, Max Domeika, Paula Ramos

In our previous blog, we discussed how to create a virtual assistant to plan a trip to Rome. Now, let’s consider how Generative AI can help to not only write your dream but also visualize it, on an AI PC! To learn more about AI PC development, you can also catch our first blog in this series here. It’s quite convenient to do this using the OpenVINO™ toolkit from Intel®, which supports various visual Generative AI models and use cases such as text-to-image, image-to-image, text-to-video, in-painting, and many more. Most of these visual generative AI applications are implemented using several models, as they involve not only image generation but also an understanding of the text provided as a prompt.

The best place to start exploring what is possible with OpenVINO™ is the OpenVINO Notebooks Github page, where you can easily select the category you’re interested in and find the models applicable to your use case.

Figure 1: An overview of the OpenVINO notebooks Github page, to navigate and find the right model for your use case.

As we discussed in the first blog of this series, the Intel® Core™ Ultra processor provides three compute engines– the Neural Processing Unit (NPU) (for more details, see our docs), CPU, and GPU. With this case of visual generative AI, the built-in Intel® Arc™ GPU can be a great choice as it provides high throughput.

So, let’s look at how it works on the AI PC locally. One of the most popular models for text-to-image generation is the Latent Consistency Model or LCM for short.

Generating Images Using Latent Consistency Models (LCM)

LCM represents the next generation of generative models, following Latent Diffusion Models (LDMs), and it achieves remarkable results in synthesizing high-resolution images. LCM helps to overcome the slow iterative sampling process of Latent Diffusion Models, enabling fast inference with minimal steps on any pre-trained LDMs (e.g., Stable Diffusion).

LCM can generate high-quality images with just 4 iterations, or even with 2 iterations, for example as shown in Figure 2! You can find some examples and a more detailed explanation of the LCM methods here.

Figure 2: An image of “a pink unicorn” text prompt, generated by an LCM model optimized with OpenVINO

After installing OpenVINO™ on the AI PC as described in the first blog post, you can navigate over to this notebook “Latent Consistency Model using Optimum-Intel OpenVINO” to follow along. It demonstrates how to run inference of an LCM model using Optimum-Intel with OpenVINO as a backend.

In the first cell, you need to install all the dependencies required for the notebook and LCM model inference.

Please note that this notebook is self-contained, meaning it describes all the dependencies that are needed.

Running this cell below on the AI PC allows us to see all the devices that are available for AI inference:

Available devices:

CPU: Intel® Core™ Ultra 7 155H
GPU: Intel® Arc™ Graphics (iGPU)
NPU: Intel® AI Boost

So, you can see here not only the CPU and NPU, which are suitable for low latency and AI offloading but also the GPU: Intel® Arc™ Graphics (iGPU), which is well-suited for our scenario. Using this notebook, you can learn how to run the LCM on the CPU with Hugging Face Diffusers.

Let’s focus on AI inference with Optimum Intel and OpenVINO on the iGPU with a simple code snippet:

This is a very simple code snippet above that allows you to download the model from the Hugging Face Hub, export it, and save it in the OpenVINO IR format.

You can see that it is sufficient to download and export the model only once. Next time the model will be loaded from the local disk.

You are also free to use any image resolution you prefer. In this case, a resolution of 512x512 is used. As a result, we create an OpenVINO™ pipeline and, by selecting the GPU for inference, compile the model for the GPU.

Model compilation can take time during the first execution, but for any execution runs afterward, it will be very fast as the compiled model is cached locally. Model caching is enabled in the Optimum-Intel package by default and does not require additional configuration. You can read more about model caching and its details to understand how it works here.

Creating a Virtual Postcard

Before we implemented a virtual assistant using OpenVINO™ using a local Large Language Model (LLM). What if we could enhance the experience by sending a virtual postcard to friends or relatives from Rome, which was included in the travel plan? To achieve this, we could use a prompt to generate an image of a famous Rome attraction. For example:

prompt = “ A photo of Coliseum in Rome on a sunny day, highly detailed, masterpiece “

So, let’s finally run AI inference on the integrated GPU of the AI PC with the above code snippet! You can find the generated image below, in Figure 3.

Figure 3: (Left) Photograph by Jorgen Hendriksen (Right) Our virtual postcard image of Rome, generated by LCM, optimized with OpenVINO

Surely, it is possible to buy a postcard at any tourist location, but in this case, you can surprise your family with something very special that you’ve also created yourself. Feel free to experiment with your prompt to generate more images and select the most appropriate one. Thanks to the great performance of the AI PC for visual generative AI tasks, it is easy to experiment and generate as many images as you want. Take a look at Figure 4 for an example.

Figure 4: A GIF of multiple virtual postcard images of Rome, generated by our optimized LCM model

What’s next?

Try it out yourself on an AI PC or any Intel hardware by using this notebook. If you’d like to keep posted on more updates, join the AI PC Developer Program to stay updated on new resources, at this page!

About Dmitriy Pastushenkov

Dmitriy Pastushenkov is a passionate AI PC Evangelist at Intel Germany with more than 20 years of comprehensive and international experience in industrial automation, industrial Internet of Things (IIoT), and real-time operating systems and AI. Dmitriy has held various roles in software development and enablement, software architecture, and technical management. As an AI PC Evangelist Dmitriy focuses on OpenVINO and other components of AI Software Stack for the new Intel AI PC. Dmitriy has a Master’s degree in Computer Science from Moscow Power Engineering Institute (Technical University).

About Ria Cheruvu

Ria Cheruvu is an AI Software Architect and Evangelist at Intel. She has a master’s degree in data science from Harvard University and is an instructor of data science curricula. Ria holds multiple patents and publications on AI and trustworthy AI and is an accomplished industry speaker, having delivered keynotes and technical talks for Women in Data Science, QS EduData Summit, TEDx, DEF CON loT Village, and other communities to inform on challenges and solutions in the space. As a technical pathfinder, she is passionate about the importance of open-source communities and women in STEM and enjoys learning about and contributing to disruptive technology spaces.

About Max Domeika

Max Domeika is a principal engineer at Intel focusing on AI Software Application Development. Max holds multiple patents as a result of his innovative work and is the author of two books, “Software Development for Embedded Multi-core Systems” from Elsevier and “Break Away with Intel Atom Processors” from Intel Press. Max earned a BS in Computer Science from the University of Puget Sound, an MS in Computer Science from Clemson University, and an MS in Management in Science and Technology from Oregon Graduate Institute. Max has been with Intel for 28 years.

About Paula Ramos

Paula Ramos has a PhD in Computer Vision, with more the 19 years of experience in the technological field. She has been working on developing novel integrated engineering technologies, mainly in the field of Computer Vision, robotics and Machine Learning applied to agriculture, since the early 2000s in Colombia. During her PhD and postgrad research, she deployed multiple low-cost, smart edge & IoT computing technologies that can be operated without expertise in computer vision systems such as farmers. The central objective of Paula’s research has been to develop intelligent systems/machines that can understand and recreate the visual world around us to solve real-world needs, such as those in the agricultural industry. Currently, she’s an AI Evangelist at Intel. Here you can find her LinkedIn profile and her most recent talks.

Notices & Disclaimers

Intel technologies may require enabled hardware, software, or service activation.

No product or component can be absolutely secure.

Your costs and results may vary.

© Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others.

--

--

OpenVINO™ toolkit
OpenVINO-toolkit

Deploy high-performance deep learning productively from edge to cloud with the OpenVINO™ toolkit.