https://github.com/autodistill/autodistill-seggpt
SegGPT module for use with Autodistill
https://github.com/autodistill/autodistill-seggpt
autodistill computer-vision seggpt
Last synced: 2 months ago
JSON representation
SegGPT module for use with Autodistill
- Host: GitHub
- URL: https://github.com/autodistill/autodistill-seggpt
- Owner: autodistill
- Created: 2023-08-01T01:23:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-06T11:08:22.000Z (over 1 year ago)
- Last Synced: 2025-03-28T01:23:19.138Z (3 months ago)
- Topics: autodistill, computer-vision, seggpt
- Language: Jupyter Notebook
- Homepage: https://docs.autodistill.com
- Size: 4.5 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Autodistill SegGPT Module
This repository contains the code supporting the SegGPT base model for use with [Autodistill](https://github.com/autodistill/autodistill).
[SegGPT](https://github.com/baaivision/Painter/tree/main/SegGPT) is a transformer-based, few-shot semantic segmentation model developed by [BAAI Vision](https://github.com/baaivision).
This model performs well on task-specific segmentation tasks when given a few labeled images from which to learn features about the objects you want to identify.
Read the full [Autodistill documentation](https://autodistill.github.io/autodistill/).
Read the [SegGPT Autodistill documentation](https://autodistill.github.io/autodistill/base_models/seggpt/).
## Installation
To use SegGPT with Autodistill, you need to install the following dependency:
```bash
pip3 install autodistill-seggpt
```## About SegGPT
SegGPT performs "in-context" segmentation. This means it requires a handful of pre-labelled "context" images.
You will need some labeled images to use SegGPT. Don't have any labeled images? Check out [Roboflow Annotate](https://roboflow.com/annotate), a feature-rich annotation tool from which you can export data for use with Autodistill.
## Quickstart
```python
from autodistill_seggpt import SegGPT, FewShotOntologybase_model = SegGPT(
ontology=FewShotOntology(supervision_dataset)
)base_model.label("./unlabelled-photos", extension=".jpg")
```## How to load data from Roboflow
Labelling and importing images is easy!
You can use [Roboflow Annotate](https://roboflow.com/annotate) to label a few images (1-3 should work fine). For your Project Type, make sure to pick Instance Segmentation, as you will be labelling with polygons.
Once you have labelled your images, you can press Generate > Generate New Version. You can use all the default options--no Augmentations are necessary.
Once your dataset version is generated, you can press Export > Continue.
Then you will get some download code to copy. It should look something like this:
```python
!pip install roboflowfrom roboflow import Roboflow
rf = Roboflow(api_key="ABCDEFG")
project = rf.workspace("lorem-ipsum").project("dolor-sit-amet")
dataset = project.version(1).download("yolov8")
```Note: if you are not using a notebook environment, you should remove `!pip install roboflow` from your code, and run `pip install roboflow` in your terminal instead.
To import your dataset into Autodistill, run the following:
```py
import supervision as svsupervision_dataset = sv.DetectionDataset.from_yolo(
images_directory_path=f"{dataset.location}/train/images",
annotations_directory_path=f"{dataset.location}/train/labels",
data_yaml_path=f"{dataset.location}/data.yaml",
force_masks=True
)
```## License
The code in this repository is licensed under an [MIT license](LICENSE).
See the SegGPT repository for more information on the [SegGPT license](https://github.com/baaivision/Painter/tree/main).
## 🏆 Contributing
We love your input! Please see the core Autodistill [contributing guide](https://github.com/autodistill/autodistill/blob/main/CONTRIBUTING.md) to get started. Thank you 🙏 to all our contributors!