Image Segmentation
PyTorch
sam2
English
computer-vision
segmentation
few-shot-learning
zero-shot-learning
clip
Instructions to use ParallelLLC/Segmentation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sam2
How to use ParallelLLC/Segmentation with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained(ParallelLLC/Segmentation) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): predictor.set_image(<your_image>) masks, _, _ = predictor.predict(<input_prompts>)# Use SAM2 with videos import torch from sam2.sam2_video_predictor import SAM2VideoPredictor predictor = SAM2VideoPredictor.from_pretrained(ParallelLLC/Segmentation) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): state = predictor.init_state(<your_video>) # add new prompts and instantly get the output on the same frame frame_idx, object_ids, masks = predictor.add_new_points(state, <your_prompts>): # propagate the prompts to get masklets throughout the video for frame_idx, object_ids, masks in predictor.propagate_in_video(state): ... - Notebooks
- Google Colab
- Kaggle
File size: 2,334 Bytes
12fa055 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # SAM 2 Few-Shot/Zero-Shot Segmentation Research
This repository contains research on combining Segment Anything Model 2 (SAM 2) with minimal supervision for domain-specific segmentation tasks.
## Research Overview
The goal is to study how SAM 2 can be adapted to new object categories in specific domains (satellite imagery, fashion, robotics) using:
- **Few-shot learning**: 1-10 labeled examples per class
- **Zero-shot learning**: No labeled examples, using text prompts and visual similarity
## Key Research Areas
### 1. Domain Adaptation
- **Satellite Imagery**: Buildings, roads, vegetation, water bodies
- **Fashion**: Clothing items, accessories, patterns
- **Robotics**: Industrial objects, tools, safety equipment
### 2. Learning Paradigms
- **Prompt Engineering**: Optimizing text prompts for SAM 2
- **Visual Similarity**: Using CLIP embeddings for zero-shot transfer
- **Meta-learning**: Learning to adapt quickly to new domains
### 3. Evaluation Metrics
- IoU (Intersection over Union)
- Dice Coefficient
- Boundary Accuracy
- Domain-specific metrics
## Project Structure
```
βββ data/ # Dataset storage
βββ models/ # Model implementations
βββ experiments/ # Experiment configurations
βββ utils/ # Utility functions
βββ notebooks/ # Jupyter notebooks for analysis
βββ results/ # Experiment results and visualizations
βββ requirements.txt # Dependencies
```
## Quick Start
1. **Install dependencies**:
```bash
pip install -r requirements.txt
```
2. **Download SAM 2**:
```bash
python scripts/download_sam2.py
```
3. **Run few-shot experiment**:
```bash
python experiments/few_shot_satellite.py
```
4. **Run zero-shot experiment**:
```bash
python experiments/zero_shot_fashion.py
```
## Research Papers
This work builds upon:
- [SAM 2: Segment Anything Model 2](https://arxiv.org/abs/2311.15796)
- [CLIP: Learning Transferable Visual Representations](https://arxiv.org/abs/2103.00020)
- [Few-shot Learning for Semantic Segmentation](https://arxiv.org/abs/1709.03410)
## Contributing
Please read our contributing guidelines and code of conduct before submitting pull requests.
## License
MIT License - see LICENSE file for details. |