Machine Learning with Python
68.1K subscribers
1.37K photos
115 videos
181 files
1.06K links
Learn Machine Learning with hands-on Python tutorials, real-world code examples, and clear explanations for researchers and developers.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
𝐕𝐢𝐬𝐮𝐚𝐥 𝐛𝐥𝐨𝐠 on Vision Transformers is live.
https://vizuaranewsletter.com/p/vision-transformers?r=5b5pyd&utm_campaign=post&utm_medium=web

Learn how ViT works from the ground up, and fine-tune one on a real classification dataset.

CNNs process images through small sliding filters. Each filter only sees a tiny local region, and the model has to stack many layers before distant parts of an image can even talk to each other.

Vision Transformers threw that whole approach out.

ViT chops an image into patches, treats each patch like a token, and runs self-attention across the full sequence.
Every patch can attend to every other patch from the very first layer. No stacking required.

That global view from layer one is what made ViT surpass CNNs on large-scale benchmarks.

𝐖𝐡𝐚𝐭 𝐭𝐡𝐞 𝐛𝐥𝐨𝐠 𝐜𝐨𝐯𝐞𝐫𝐬:

- Introduction to Vision Transformers and comparison with CNNs
- Adapting transformers to images: patch embeddings and flattening
- Positional encodings in Vision Transformers
- Encoder-only structure for classification
- Benefits and drawbacks of ViT
- Real-world applications of Vision Transformers
- Hands-on: fine-tuning ViT for image classification

The Image below shows

Self-attention connects every pixel to every other pixel at once. Convolution only sees a small local window. That's why ViT captures things CNNs miss, like the optical illusion painting where distant patches form a hidden face.

The architecture is simple. Split image into patches, flatten them into embeddings (like words in a sentence), run them through a Transformer encoder, and the class token collects info from all patches for the final prediction. Patch in, class out.

Inside attention: each patch (query) compares itself to all other patches (keys), softmax gives attention weights, and the weighted sum of values produces a new representation aware of the full image, visualizes what the CLS token actually attends to through attention heatmaps.

The second half of the blog is hands-on code. I fine-tuned ViT-Base from google (86M params) on the Oxford-IIIT Pet dataset, 37 breeds, ~7,400 images.

𝐁𝐥𝐨𝐠 𝐋𝐢𝐧𝐤
https://vizuaranewsletter.com/p/vision-transformers?r=5b5pyd&utm_campaign=post&utm_medium=web


𝐒𝐨𝐦𝐞 𝐑𝐞𝐬𝐨𝐮𝐫𝐜𝐞𝐬
ViT paper dissection
https://youtube.com/watch?v=U_sdodhcBC4

Build ViT from Scratch
https://youtube.com/watch?v=ZRo74xnN2SI

Original Paper
https://arxiv.org/abs/2010.11929

https://t.iss.one/CodeProgrammer
5
Follow the Machine Learning with Python channel on WhatsApp: https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
3
📱 TorchCode — a PyTorch training tool for preparing for ML interviews

40 tasks for implementing operators and architectures that are actually asked in interviews. Automatic checking, hints, and reference solutions — all in the browser without installation.

If you're preparing for an ML interview, it's useful to go through at least half of them.

Link: https://github.com/duoan/TorchCode

tags: #useful #pytorch

https://t.iss.one/CodeProgrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
4
⚡️ Colorizing old black-and-white videos and "bringing faces to life" for FREE

SVFR — a full-fledged framework for restoring faces in videos.

It can:
💬 BFR — improve blurry faces.
💬 Colorization — colorize black-and-white videos.
💬 Inpainting — redraw damaged areas.
💬 and combine all of this in one pass.

Essentially, the model takes old or damaged videos and makes them "as if they were shot yesterday". And it's free and open-source.

⚙️ Installation locally:

1. Create an environment

conda create -n svfr python=3.9 -y
conda activate svfr


2. Install PyTorch (for your CUDA)

pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2


3. Install dependencies

pip install -r requirements.txt


4. Download models

conda install git-lfs
git lfs install
git clone https://huggingface.co/stabilityai/stable-video-diffusion-img2vid-xt models/stable-video-diffusion-img2vid-xt


5. Start processing videos

python infer.py \
--config config/infer.yaml \
--task_ids 0 \
--input_path input.mp4 \
--output_dir results/ \
--crop_face_region


Where task_ids:

* 0 — face enhancement
* 1 — colorization
* 2 — redrawing damage

An ideal tool if:
🟢you're restoring archival videos;
🟢you're creating historical content;
🟢you're working with neural networks and video effects;
🟢you want a wow result without paid services.

▶️ Demo on Hugging Face

♎️ GitHub/Instructions

#python #soft #github

https://t.iss.one/CodeProgrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
4