This repository contains two Jupyter notebooks (q1.ipynb and q2.ipynb) demonstrating deep learning models for image classification and image segmentation tasks.
Description: Implements a Vision Transformer (ViT) architecture to classify images from the CIFAR-10 dataset into 10 classes.
Key Features:
- Data loading and preprocessing using
torchvision.datasetsandtransforms. - ViT components:
PatchEmbeddingto split and embed image patches.- Multi-head
TransformerEncoderLayerfor sequence modeling. - Fully connected
MLPHeadfor final classification.
- Training loop with configurable hyperparameters (learning rate, epochs, batch size).
- Evaluation on validation set and accuracy plotting.
- GPU acceleration support via PyTorch.
Dependencies:
- Python 3.8+
- torch
- torchvision
- matplotlib
- numpy
Usage:
- Install dependencies:
pip install torch torchvision matplotlib numpy - Run all cells in
q1.ipynb. - Modify hyperparameters (learning rate, epochs, batch size) in the configuration cell as needed.
Description: Performs zero-shot, text-prompted object segmentation on a sample image using:
- GroundingDINO for region proposal based on text prompts.
- Segment Anything Model (SAM) v1/v2 for precise segmentation masks.
Key Features:
- Installs required libraries:
segment-anything,transformers,datasets,accelerate,opencv-python,Pillow,matplotlib. - Loads an image from a remote URL with
requestsandPillow. - Accepts a text prompt (e.g., "a dog") to specify the target object.
- Uses GroundingDINO to generate bounding box region seeds for the prompt.
- Feeds the region seeds to SAM predictor to produce a binary segmentation mask.
- Displays original image with overlayed segmentation mask.
Dependencies:
- Python 3.8+
- segment-anything
- transformers
- datasets
- accelerate
- opencv-python
- Pillow
- matplotlib
- torch
Usage:
- Install dependencies:
pip install segment-anything transformers datasets accelerate opencv-python pillow matplotlib torch
- Open
q2.ipynband run all cells in order. - Input a custom text prompt in the designated prompt cell.
- Review the generated segmentation mask overlay.