Vision Transformer (ViT) (Semantic Segmentation) (Basic Tutorial) v1.5
Think Different
0:00 / 0:00
Vision Transformer (ViT) (Semantic Segmentation) (Basic Tutorial) v1.5
16 просмотров · 4 дн. назад
Think Different
67 подписчиков
16 просмотров · 4 дн. назад
For Deep Learning Enthusiasts & Nerds
I am continuing my journey into the world of deep learning! Don’t worry—my previous sequence-to-sequence Transformer v3 project remains fully up and available, but as I keep exploring, I wanted to see how attention mechanisms translate into Computer Vision. I created this hands-on Vision Transformer (ViT v1.5) tutorial for developers who want to learn how pixel-level image segmentation works under the hood. My goal was to build a complete, self-contained ViT model in PyTorch for educational purposes.
About This Project
A lightweight Vision Transformer (ViT v1.5) built from scratch in PyTorch, designed to perform semantic segmentation (labeling every pixel in a photo as person or background).
It cuts images into square patch vectors, processes them via learned positional encodings and multi-head attention, and projects the patch representations back to full image resolution to predict pixel-level labels.
What's New in Version 1.5:
🖼️ The Stem: Replaces v1's PatchEmbedding, which cut the picture into hard 8 x 8 squares. Three $3 \times 3$ convolutions (each with stride 2 and followed by BatchNorm and GELU) halve the picture three times to extract overlapping feature maps.
📍 2-D RoPE (Rotary Position Embedding): Replaces static learned position tables with the 2-D rotary positions of text v2.5. It turns query and key pairs depending on row and column coordinates, allowing attention scores to depend on relative spatial configuration rather than absolute canvas location.
*⚡ The Decoder:) Replaces the basic single-stride projection of patch scores with a cross-attention decoder and convolutional mapping. Spatial grid cells (4 x 4 pixels) query the encoder's patch memory, and the resulting 48 x 72 logits are interpolated to full image resolution with four times less stretching than v1.
Github: https://github.com/IvanVoznyi/Basic-T...
Site: https://ivanvoznyi.github.io/Basic-Tr...
P.S.
Don’t hit me too hard with the feedback!
#DeepLearning #AI #VisionTransformer #ViT #PyTorch #ComputerVision #MachineLearning #NLP