> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Computer Vision Models

> Overview of CNNs, Vision Transformers, and Diffusion Models explaining methods, applications, and Azure services for image analysis, generation, and multimodal vision tasks.

This lesson surveys the core model families that enable machines to understand, analyze, and create visual content. We'll cover Convolutional Neural Networks (CNNs), Vision Transformers (ViT), and Diffusion Models, with practical examples and links to relevant Azure services. Each section explains the core idea, how the model processes images, and where it's commonly used.

## Convolutional Neural Networks (CNNs)

Convolutional Neural Networks (CNNs) convert raw pixels into progressively richer visual features. Think of a CNN as a system that scans an image for local patterns (edges, textures, colors) and combines those patterns into higher-level concepts (shapes, object parts) that are useful for tasks like classification, detection, and segmentation.

How training works (high level)

* Collect labeled images (e.g., apples, oranges, bananas).
* Learn convolutional filters that detect informative local patterns.
* Stack layers so deeper layers build on earlier features.
* Use classification (dense) layers to map extracted features to class scores.

The core operation is convolution: a small filter (kernel) slides over the image and produces a feature map indicating where a pattern occurs. Early layers typically learn simple filters (edges, colors); later layers learn complex combinations useful for discrimination.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/ZdXEe7d3muXYDMl5/images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/cnn-infographic-training-filters-featurevector.jpg?fit=max&auto=format&n=ZdXEe7d3muXYDMl5&q=85&s=940b06c901cecd773a7543333cf421d6" alt="An infographic explaining Convolutional Neural Networks showing three steps: training images (apple, orange, banana), convolution filters represented as grid layers, and resulting stacked feature maps transformed into a feature vector." width="1920" height="1080" data-path="images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/cnn-infographic-training-filters-featurevector.jpg" />
</Frame>

After feature extraction, dense (fully connected) classification layers combine signals from feature maps to produce scores for each class. For example, a network might output scores like apple: 0.94, orange: 0.04, banana: 0.02, which are commonly normalized with softmax to provide relative confidences.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/ZdXEe7d3muXYDMl5/images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/cnn-dense-classification-apple-orange-banana.jpg?fit=max&auto=format&n=ZdXEe7d3muXYDMl5&q=85&s=e705081625186f963dc9ec918594e380" alt="An infographic about a Convolutional Neural Network showing dense classification layers on the left and class prediction scores on the right. The prediction bars list Apple 0.94, Orange 0.04, and Banana 0.02." width="1920" height="1080" data-path="images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/cnn-dense-classification-apple-orange-banana.jpg" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Model output scores indicate how strongly a model favors each class but are not guaranteed to be perfectly calibrated probabilities. Treat these scores as informative signals and apply calibration or uncertainty measures when required by your application.
</Callout>

Common CNN applications

* Photo organization and image search
* Object detection and instance segmentation
* Facial recognition and biometric analysis

## Vision Transformers (ViT)

Vision Transformers adapt transformer architectures from NLP to images by converting image patches into a sequence of token-like embeddings. Each patch becomes an embedding vector, and the transformer then models relationships among those patches using self-attention.

Why patching works

* Splitting an image into fixed-size patches turns spatial data into a sequence.
* Each patch becomes a visual token, analogous to a word embedding in language models.
* Transformers process the sequence and learn global relationships between patches.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/ZdXEe7d3muXYDMl5/images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/vision-transformer-16-patch-embeddings.jpg?fit=max&auto=format&n=ZdXEe7d3muXYDMl5&q=85&s=9d410f5bdd5f633b33b58f26b51a31b4" alt="A slide titled &#x22;Vision Transformer (ViT)&#x22; showing a small image split into 16 grid patches on the left, an arrow to a column of colored embedding vectors in the center, and text on the right explaining that each patch becomes an embedding vector." width="1920" height="1080" data-path="images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/vision-transformer-16-patch-embeddings.jpg" />
</Frame>

The power of ViT comes from self-attention: each patch embedding can attend to every other patch, enabling the model to learn long-range dependencies and contextual relationships. For instance, a patch containing a hand can leverage information from patches containing bike handlebars or wheels to form a coherent interpretation.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/ZdXEe7d3muXYDMl5/images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/vit-self-attention-image-patches.jpg?fit=max&auto=format&n=ZdXEe7d3muXYDMl5&q=85&s=90f68da65a57dda42aded19a5d16af1e" alt="A presentation slide titled &#x22;Vision Transformer (ViT) — Self-attention&#x22; showing five image patches (p1–p5) with many interconnecting lines to illustrate that each patch attends to every other patch. The right side notes that self-attention learns relationships between image regions to capture global context." width="1920" height="1080" data-path="images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/vit-self-attention-image-patches.jpg" />
</Frame>

Use cases and multimodal integration

* ViT variants are excellent for tasks needing global reasoning, such as document layout analysis or complex scene understanding.
* Vision embeddings integrate well with text embeddings in multimodal systems (image + text), enabling tasks like image captioning and visual question answering.

<Callout icon="lightbulb" color="#1CB2FE">
  Multimodal models combine visual and textual embeddings to answer questions about images or generate captions. For example, an assistant might analyze a photo of your fridge and respond: “You have spinach and tomatoes,” by aligning visual features with your language query.
</Callout>

Azure multimodal services

* Azure AI Vision: image analysis, OCR, and structured extraction — [https://learn.microsoft.com/azure/ai-services/vision/](https://learn.microsoft.com/azure/ai-services/vision/)
* Azure OpenAI: multimodal models that accept images and return text responses — [https://learn.microsoft.com/azure/ai-services/openai/](https://learn.microsoft.com/azure/ai-services/openai/)

## Diffusion Models (Generative Models)

Diffusion models are generative models trained to reverse a noise-adding process. During training, images are progressively corrupted by noise; the model learns to predict and remove that noise. During generation, the model starts from random noise and iteratively denoises it into a final image, often guided by a text prompt.

High-level generation pipeline

* Start from random noise.
* Apply a sequence of learned denoising steps.
* Optionally use prompts (text or image guidance) to steer denoising.
* After many iterations, output the synthesized image (or video).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/ZdXEe7d3muXYDMl5/images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/diffusion-models-image-video-infographic.jpg?fit=max&auto=format&n=ZdXEe7d3muXYDMl5&q=85&s=0838d62883197780e7a74de7bbfd513b" alt="An infographic titled &#x22;Image and Video Generation: Diffusion Models&#x22; explaining the process of learning to remove noise and generate images. It shows four numbered steps—Training, Generation, Prompt Guidance, and Output—with brief notes on adding/removing noise, using text embeddings, and producing the final image or video." width="1920" height="1080" data-path="images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/diffusion-models-image-video-infographic.jpg" />
</Frame>

A typical denoising timeline shows the image gradually emerging: early steps reveal broad structure and composition; middle steps add shapes and colors; later steps refine texture and fine details. The number and granularity of steps vary by model and quality/performance trade-offs.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/ZdXEe7d3muXYDMl5/images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/diffusion-denoising-steps-sunrise-hills.jpg?fit=max&auto=format&n=ZdXEe7d3muXYDMl5&q=85&s=4a7ae2636450a97f908c227bbbc500a9" alt="An infographic showing the steps of a diffusion model denoising process, with five panels labeled Step 0 to Step 50 transitioning from pure noise to a final image. The finished image is a simple sunrise scene with two blue triangular hills and a yellow sun, guided by the prompt &#x22;A hiker on a hill at sunrise.&#x22;" width="1920" height="1080" data-path="images/AI-901-Microsoft-Azure-AI-Fundamentals/Getting-Started-With-Computer-Vision/Computer-Vision-Models/diffusion-denoising-steps-sunrise-hills.jpg" />
</Frame>

Practical notes

* Diffusion models excel at generating high-fidelity images and supporting flexible guidance (text prompts, image-conditioned generation).
* Generation is iterative and computationally heavier than single-shot methods, but it often produces superior detail and diversity.

## Quick Comparison

| Model family | Primary purpose | Strengths | Typical applications |
| - | - | -: | - |
| CNNs | Feature extraction and supervised vision tasks | Efficient local pattern learning, well-optimized for many tasks | Image classification, object detection, face recognition |
| Vision Transformers (ViT) | Global context modeling via self-attention | Long-range dependency modeling, flexible for multimodal fusion | Document layout analysis, multimodal models, large-scale vision tasks |
| Diffusion Models | Generative image (and video) synthesis | High-quality, prompt-guided image generation with controllable detail | Creative image synthesis, inpainting, text-to-image generation |

## Final takeaway

CNNs, Vision Transformers, and Diffusion Models form a complementary toolkit for modern computer vision:

* Use CNNs for efficient hierarchical feature extraction and classical vision tasks.
* Use ViT when global relationships and multimodal fusion matter.
* Use Diffusion Models for high-quality, prompt-driven image generation.

These techniques power real-world applications from content organization and accessibility to creative image synthesis and multimodal assistants.

## Links and References

* Azure AI Vision — [https://learn.microsoft.com/azure/ai-services/vision/](https://learn.microsoft.com/azure/ai-services/vision/)
* Azure OpenAI Service — [https://learn.microsoft.com/azure/ai-services/openai/](https://learn.microsoft.com/azure/ai-services/openai/)
* For deeper reading on transformers in vision: "An Image is Worth 16x16 Words" (Dosovitskiy et al.)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/ai-901-microsoft-azure-ai-fundamentals/module/25a7a861-a7b5-47cc-8366-d30367c8d4c8/lesson/4db63cd2-fc05-4103-9efc-262d013a60d8" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.