Dickson Neoh πŸš€ Profile picture
May 3, 2022 β€’ 15 tweets β€’ 7 min read β€’ Read on X
Deploying object detection models on a CPU is a PAIN.

In this thread I will show you how I optimized and 10x my YOLOX model from 5 FPS to 50 FPS on a CPU.

Yes!! CPU!

And yes for FREE.

The optimized model runs FASTER on a CPU than GPU 🀯

dicksonneoh.com/portfolio/how_…

A thread πŸ‘‡
By the end of this thread, you will find out how we go from this πŸ‘‡πŸŒ
To this πŸ‘‡πŸš€
You will learn how to:

πŸ₯‹ Train state-of-the-art YOLOX model with your own data.

πŸ€– Convert the YOLOX PyTorch model into ONNX and Intel's OpenVINO IR format. @intel

πŸš€ Run quantization algorithm to 10x your model’s inference speed.

Let's dive inπŸ‘‡
🚦 Motivation

In production environments, CPUs are far more common than GPUs.

But object detection models are a lot slower on CPUs - Not cool to have in real-time applications like #Tesla cars.

Can we feasibly deploy real-time object detection models on CPUs?

YES we canβœ…
β›· Modeling with YOLOX

Let's model a simple task of license plate detection using the YOLOX package by @Megvii.

For that, I collected 40 images of license plates from around my neighbourhood and label them with CVAT by @IntelSoftware

The annotations are in COCO format.
Once the annotations and images are in place, training a YOLOX model is as simple as running πŸ‘‡
After the training ends, we should have a @PyTorch checkpoint. Let's use the checkpoint to run an inference on a video and see its performance.

Out of the box, that's about 5 FPS with no optimization.

Let's see how we can improve it πŸ€”
πŸ€– ONNX Runtime by @onnxai

Now let's convert the PyTorch checkpoint into the ONNX form and run it with the ONNX Runtime.

We instantly improved the FPS from 5 FPS to about 10 FPS on a CPU. That's a 2x boost.

But its still not ideal for real time detection. We need more 🦾
πŸ”— OpenVINO Intermediate Representation (IR)

#OpenVINO is a toolkit by @intel to optimize DL models.

Let's convert our ONNX model into the IR (FP16) form and run the same inference.

Doing this we bumped the speed up to 16 FPS!

We're almost there, but can we do better? πŸ‘€
πŸ›  Post-Training Quantization

#OpenVINO also comes with a Post-training Optimization Toolkit (POT) designed to supercharge the inference of DL models.

POT runs 8-bit quantization and optimizes the model to use integer tensors instead of floating-point tensors.

The result? πŸš€πŸ‘‡
This is nothing short of mindblowing! I never thought this is possible with a CPU.

For reference, the same model (using PyTorch) runs on an RTX3090 at about 40+ FPS.
In this thread, I've shown you how you can 10x your YOLOX model (from 5 PS to 50 FPS) on a CPU using simple and free techniques.

The end result is a model that runs faster on a CPU than GPU.

This is nothing short of mindblowing! I never thought this is even possible.
If you like what you see and don't wish to miss gems like these, consider following me and retweeting.

This will 10x (pun intended) my energy to keep producing contents like these! πŸ™

More details in the blog post dicksonneoh.com/portfolio/how_…
@PINTO03091
I would love to know what you think of this as someone who's experienced in Intel's software and OpenVINO. Can this be better?

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Dickson Neoh πŸš€

Dickson Neoh πŸš€ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @dicksonneoh7

Feb 14, 2023
Tired of training models that never see the light of day? Don't let your hard work go to waste!

In this 🧡, I'll show you how to pick from over 900+ models from TIMM by @wightmanr , train them with Fastai by @jeremyphoward , and deploy them on Android – all for free.
⚑ You will learn how to:

β–Ά Load a model from TIMM and train it with Fastai.
β–Ά Export the trained model with TorchScript for inference.
β–Ά Create a functional Android app and run the inference on your device.

πŸ”₯ Inference time is about 100-200ms on my Pixel 3 XL!
Here's the demo of the app πŸ‘‡
Read 20 tweets
May 20, 2022
Deploying GPT-like language models on a chatbot is tricky.

You might wonder
β€’ How to access the model?
β€’ Where to host the bot?

In this 🧡I walk you through how easily I deployed a GPT-J-6B model by #EleutherAI on a #Telegram bot with @huggingface and @Gradio.

For FREE πŸš€
By the end of this🧡, you’ll have your very own Telegram bot that can query the GPT-J model with any text you send it πŸ‘‡
πŸ€–Token From the BotFather

To create a bot, you must have a Telegram account.

Next, get a TOKEN from the BotFather. This TOKEN allows you to access the bot.

Keep this TOKEN private🀫. Anyone with this TOKEN can access your bot.

Read 19 tweets
May 11, 2022
Picking an object detection model is a PAIN.

Within the YOLO family there's YOLOv1 to YOLOv5, YOLOR, YOLOX, PPYOLO.. it's never ending 😡

How do you pick the right one for your application?

In this thread, I will show you how to squeze the best of YOLOX using @weights_biases
By the end of this thread you will learn how to:

πŸ’‘Install the Wandb client and log the YOLOX training metrics.

πŸ”­Compare training metrics on the Wandb dashboard.

🎯 Pick the best model with mAP and FPS values.

P/S: The best model scored > 100 FPS on a CPU 🀯
πŸ•Ή Wandb - Google Drive for Machine Learning

Life is short they say. So why waste it on monitoring your models training when you can automate them?

Wandb does this extremely well.

You can compare models, log metrics, and collaborate with teammates. It’s free to start.
Read 21 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(