Skip to content

Commit 49e8929

Browse files
makseqcaitlinwheelessmicaelakaplan
authored
docs: Add labeling config to SAM2 for images (#619)
Co-authored-by: Caitlin Wheeless <[email protected]> Co-authored-by: micaelakaplan <[email protected]>
1 parent de8549c commit 49e8929

File tree

1 file changed

+87
-2
lines changed
  • label_studio_ml/examples/segment_anything_2_image

1 file changed

+87
-2
lines changed

label_studio_ml/examples/segment_anything_2_image/README.md

+87-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,96 @@ SAM 2 for better image labeling with label studio.
2525
Click on the image below to watch our ML Evangelist Micaela Kaplan explain how to link SAM 2 to your Label Studio Project.
2626
You'll need to follow the instructions below to stand up an instance of SAM2 before you can link your model!
2727

28-
2928
[![Connecting SAM2 Model to Label Studio for Image Annotation ](https://img.youtube.com/vi/FTg8P8z4RgY/0.jpg)](https://www.youtube.com/watch?v=FTg8P8z4RgY)
3029

3130
Note that as of 8/1/2024, SAM2 only runs on GPU.
3231

32+
## Labeling configuration
33+
34+
The current implementation of the Label Studio SAM2 ML backend works using Interactive mode. The user-guided inputs are:
35+
- `KeypointLabels`
36+
- `RectangleLabels`
37+
38+
And then SAM2 outputs `BrushLabels` as a result.
39+
40+
This means all three control tags should be represented in your labeling configuration:
41+
42+
```xml
43+
<View>
44+
<Style>
45+
.main {
46+
font-family: Arial, sans-serif;
47+
background-color: #f5f5f5;
48+
margin: 0;
49+
padding: 20px;
50+
}
51+
.container {
52+
display: flex;
53+
justify-content: space-between;
54+
margin-bottom: 20px;
55+
}
56+
.column {
57+
flex: 1;
58+
padding: 10px;
59+
background-color: #fff;
60+
border-radius: 5px;
61+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
62+
text-align: center;
63+
}
64+
.column .title {
65+
margin: 0;
66+
color: #333;
67+
}
68+
.column .label {
69+
margin-top: 10px;
70+
padding: 10px;
71+
background-color: #f9f9f9;
72+
border-radius: 3px;
73+
}
74+
.image-container {
75+
width: 100%;
76+
height: 300px;
77+
background-color: #ddd;
78+
border-radius: 5px;
79+
}
80+
</Style>
81+
<View className="main">
82+
<View className="container">
83+
<View className="column">
84+
<View className="title">Choose Label</View>
85+
<View className="label">
86+
<BrushLabels name="tag" toName="image">
87+
88+
89+
<Label value="defect" background="#FFA39E"/></BrushLabels>
90+
</View>
91+
</View>
92+
<View className="column">
93+
<View className="title">Use Keypoint</View>
94+
<View className="label">
95+
<KeyPointLabels name="tag2" toName="image" smart="true">
96+
97+
98+
<Label value="defect" background="#250dd3"/></KeyPointLabels>
99+
</View>
100+
</View>
101+
<View className="column">
102+
<View className="title">Use Rectangle</View>
103+
<View className="label">
104+
<RectangleLabels name="tag3" toName="image" smart="true">
105+
106+
107+
<Label value="defect" background="#FFC069"/></RectangleLabels>
108+
</View>
109+
</View>
110+
</View>
111+
<View className="image-container">
112+
<Image name="image" value="$image" zoom="true" zoomControl="true"/>
113+
</View>
114+
</View>
115+
</View>
116+
```
117+
33118
## Running from source
34119

35120
1. To run the ML backend without Docker, you have to clone the repository and install all dependencies using pip:
@@ -88,4 +173,4 @@ The following common parameters are available:
88173

89174
## Customization
90175

91-
The ML backend can be customized by adding your own models and logic inside the `./segment_anything_2` directory.
176+
The ML backend can be customized by adding your own models and logic inside the `./segment_anything_2` directory.

0 commit comments

Comments
 (0)