samannot 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of samannot might be problematic. Click here for more details.
- samannot/__init__.py +20 -0
- samannot/__main__.py +4 -0
- samannot/annotator.py +1019 -0
- samannot/functional_widget_utils.py +63 -0
- samannot/keycodes_linux.json +55 -0
- samannot/keycodes_windows.json +55 -0
- samannot/label.py +83 -0
- samannot/main.py +12 -0
- samannot/main_window.py +1809 -0
- samannot/model_downloader.py +378 -0
- samannot/sam2_configs/__init__.py +5 -0
- samannot/sam2_configs/sam2.1_hiera_l.yaml +120 -0
- samannot/sam2_configs/sam2_hiera_b+.yaml +113 -0
- samannot/sam2_configs/sam2_hiera_b+_old.yaml +113 -0
- samannot/sam2_configs/sam2_hiera_l.yaml +117 -0
- samannot/sam2_configs/sam2_hiera_l_old.yaml +117 -0
- samannot/sam2_configs/sam2_hiera_s.yaml +116 -0
- samannot/sam2_configs/sam2_hiera_s_old.yaml +116 -0
- samannot/sam2_configs/sam2_hiera_t.yaml +118 -0
- samannot/sam2_configs/sam2_hiera_t_old.yaml +118 -0
- samannot/sam_annotator.py +246 -0
- samannot/system_monitor.py +71 -0
- samannot/user_guide.py +216 -0
- samannot/visual_widget_utils.py +61 -0
- samannot-0.6.0.dist-info/METADATA +111 -0
- samannot-0.6.0.dist-info/RECORD +30 -0
- samannot-0.6.0.dist-info/WHEEL +5 -0
- samannot-0.6.0.dist-info/entry_points.txt +2 -0
- samannot-0.6.0.dist-info/licenses/LICENSE +21 -0
- samannot-0.6.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import tkinter as tk
|
|
2
|
+
class CircularProgress(tk.Canvas):
|
|
3
|
+
def __init__(self, parent, size=200, thickness=15,bg_color="#f5f5f5", track_color="#d0d4dc",progress_color_low="#6e5bff", progress_color_high="#ff4b7d", text_color="#222222",font=("Segoe UI", 11, "bold"), *args, **kwargs):
|
|
4
|
+
super().__init__(parent, width=size, height=size,bg=bg_color, highlightthickness=0, *args, **kwargs)
|
|
5
|
+
self.colors = self.color_gradient(progress_color_low,progress_color_high, 101)
|
|
6
|
+
pad = thickness // 2 + 4
|
|
7
|
+
self.radius_box = (pad, pad, size - pad, size - pad)
|
|
8
|
+
self.bg_arc_id = self.create_arc(self.radius_box,start=0, extent=359.9,outline=track_color,width=thickness,style=tk.ARC)
|
|
9
|
+
self.arc_id = self.create_arc(self.radius_box,start=90, extent=0,outline=progress_color_low,width=thickness,style=tk.ARC)
|
|
10
|
+
self.text_id = self.create_text(size//2, size//2,text="0%",fill=text_color,font=font)
|
|
11
|
+
def hex_to_rgb(self,hex_color):
|
|
12
|
+
hex_color = hex_color.lstrip("#")
|
|
13
|
+
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
|
14
|
+
def rgb_to_hex(self,rgb):
|
|
15
|
+
return "#{:02x}{:02x}{:02x}".format(*rgb)
|
|
16
|
+
def color_gradient(self,start_hex, end_hex, steps):
|
|
17
|
+
start_rgb = self.hex_to_rgb(start_hex)
|
|
18
|
+
end_rgb = self.hex_to_rgb(end_hex)
|
|
19
|
+
gradient = []
|
|
20
|
+
for i in range(steps):
|
|
21
|
+
t = i / (steps - 1) if steps > 1 else 1
|
|
22
|
+
rgb = tuple(int(start_rgb[j] + (end_rgb[j] - start_rgb[j]) * t) for j in range(3))
|
|
23
|
+
gradient.append(self.rgb_to_hex(rgb))
|
|
24
|
+
return gradient
|
|
25
|
+
def set_value(self, value: float, text = None):
|
|
26
|
+
value = max(0, min(100, float(value)))
|
|
27
|
+
angle = (value / 100) * 360
|
|
28
|
+
self.itemconfig(self.arc_id, extent=-angle)
|
|
29
|
+
self.itemconfig(self.arc_id, outline=self.colors[int(value)])
|
|
30
|
+
if text is None:
|
|
31
|
+
self.itemconfig(self.text_id, text=str(int(value))+"%")
|
|
32
|
+
else:
|
|
33
|
+
self.itemconfig(self.text_id, text=text)
|
|
34
|
+
|
|
35
|
+
class ToolTip:
|
|
36
|
+
def __init__(self, widget, text):
|
|
37
|
+
self.widget = widget
|
|
38
|
+
self.text = text
|
|
39
|
+
self.tip_window = None
|
|
40
|
+
widget.bind("<Enter>", self.show_tip)
|
|
41
|
+
widget.bind("<Leave>", self.hide_tip)
|
|
42
|
+
def show_tip(self, event=None):
|
|
43
|
+
if self.tip_window or not self.text:
|
|
44
|
+
return
|
|
45
|
+
self.tip_window = tk.Toplevel(self.widget)
|
|
46
|
+
self.tip_window.wm_overrideredirect(True)
|
|
47
|
+
label = tk.Label(self.tip_window,text=self.text,background="#ffffff",relief="solid",borderwidth=1,padx=5,pady=3)
|
|
48
|
+
label.pack()
|
|
49
|
+
self.tip_window.update_idletasks()
|
|
50
|
+
widget_x = self.widget.winfo_rootx()
|
|
51
|
+
widget_y = self.widget.winfo_rooty()
|
|
52
|
+
widget_w = self.widget.winfo_width()
|
|
53
|
+
tip_w = self.tip_window.winfo_width()
|
|
54
|
+
tip_h = self.tip_window.winfo_height()
|
|
55
|
+
x = widget_x + (widget_w // 2) - (tip_w // 2)
|
|
56
|
+
y = widget_y - tip_h - 5
|
|
57
|
+
self.tip_window.wm_geometry(f"{tip_w}x{tip_h}+{x}+{y}")
|
|
58
|
+
def hide_tip(self, event=None):
|
|
59
|
+
if self.tip_window:
|
|
60
|
+
self.tip_window.destroy()
|
|
61
|
+
self.tip_window = None
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: samannot
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: A memory-efficient, local interactive video instance segmentation annotation tool based on SAM 2
|
|
5
|
+
Author: Gergely Dinya
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: numpy>=1.22.0
|
|
14
|
+
Requires-Dist: pillow>=9.0.0
|
|
15
|
+
Requires-Dist: opencv-python>=4.7.0
|
|
16
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
17
|
+
Requires-Dist: torch>=2.0.0
|
|
18
|
+
Requires-Dist: torchvision>=0.15.0
|
|
19
|
+
Requires-Dist: timm>=0.6.12
|
|
20
|
+
Requires-Dist: omegaconf>=2.3.0
|
|
21
|
+
Requires-Dist: supervision>=0.13.0
|
|
22
|
+
Requires-Dist: pycocotools>=2.0.6
|
|
23
|
+
Requires-Dist: ttkthemes
|
|
24
|
+
Requires-Dist: hydra-core
|
|
25
|
+
Requires-Dist: openpyxl
|
|
26
|
+
Requires-Dist: psutil
|
|
27
|
+
Requires-Dist: nvidia-ml-py
|
|
28
|
+
Requires-Dist: scikit-image
|
|
29
|
+
Requires-Dist: sam2
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
<a href="https://arxiv.org/abs/2601.11301"><img src="https://img.shields.io/badge/arXiv-2503.11651-b31b1b" alt="arXiv"></a>
|
|
33
|
+
<a href="https://samannot.github.io/"> <img src="https://img.shields.io/badge/Project_Page-green" alt="Project Page"></a>
|
|
34
|
+
<a href="https://www.youtube.com/watch?v=j5TVcVeuVZM"> <img src="https://img.shields.io/badge/demo_video-youtube-red" alt="Demo video"></a>
|
|
35
|
+
<a href="https://www.youtube.com/watch?v=X8AkZTCYWQo"> <img src="https://img.shields.io/badge/installation_video-youtube-red" alt="Install video"></a>
|
|
36
|
+
|
|
37
|
+
# SAMannot
|
|
38
|
+
|
|
39
|
+
SAMannot is a versatile video annotation tool built on top of Meta's Segment Anything Model (SAM2). It helps you create high-quality segmentation masks across video frames with minimal user interaction.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Installation Guide
|
|
43
|
+
|
|
44
|
+
This guide explains how to set up the environment, download required checkpoints, and launch the app
|
|
45
|
+
|
|
46
|
+
### Prerequisites
|
|
47
|
+
|
|
48
|
+
- **Conda** (Anaconda or Miniconda)
|
|
49
|
+
- **Git** (optional, if you clone this repo)
|
|
50
|
+
- **Python 3.10** (the Conda env will install this)
|
|
51
|
+
- **CUDA-enabled GPU** and the correct drivers for faster inference
|
|
52
|
+
- **nvidia-cuda-toolkit** installed (optional, recommended)
|
|
53
|
+
|
|
54
|
+
### 1) Clone repository
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/gergelydinya/SAMannot.git
|
|
57
|
+
cd SAMannot
|
|
58
|
+
```
|
|
59
|
+
### 2) Create and activate the Conda environment
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# From the project root
|
|
63
|
+
conda create -n samannot python=3.10 -y
|
|
64
|
+
conda activate samannot
|
|
65
|
+
pip install -r requirements.txt
|
|
66
|
+
cd sam2
|
|
67
|
+
pip install -e .
|
|
68
|
+
cd ..
|
|
69
|
+
# Match to your CUDA version 12.8 ~ cu128
|
|
70
|
+
pip install --index-url https://download.pytorch.org/whl/cu128 torch torchvision torchaudio
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 3) Download checkpoints
|
|
74
|
+
```bash
|
|
75
|
+
cd checkpoints
|
|
76
|
+
bash download_chckpts.sh
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 4) Run the software
|
|
80
|
+
```bash
|
|
81
|
+
conda activate samannot
|
|
82
|
+
python main.py
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Evaluation
|
|
86
|
+
```bash
|
|
87
|
+
cd eval
|
|
88
|
+
python eval_fast.py --gt <ground truth folder> --pred <prediction folder>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Best practices and practical tips
|
|
92
|
+
The typical workflow the software is designed for is that the user proceeds block by block and moves forward without going back.
|
|
93
|
+
It is also possible to load an earlier block, but in that case you should expect some time overhead, as the software needs to load the frames starting from the beginning of the video.
|
|
94
|
+
|
|
95
|
+
Choose your block size based on your computer’s resources and the complexity of the data.
|
|
96
|
+
As a starting point, for an average video, we recommend a block size of 100--150 frames.
|
|
97
|
+
|
|
98
|
+
## Citation
|
|
99
|
+
|
|
100
|
+
If you use **SAMannot**, please cite our paper:
|
|
101
|
+
|
|
102
|
+
```bibtex
|
|
103
|
+
@misc{samannot,
|
|
104
|
+
title={SAMannot: A Memory-Efficient, Local, Open-source Framework for Interactive Video Instance Segmentation based on SAM2},
|
|
105
|
+
author={Gergely Dinya and Andr{\'a}s Gelencs{\'e}r and Krisztina Kup{\'a}n and Clemens K{\"u}pper and Krist{\'o}f Karacs and Anna Gelencs{\'e}r-Horv{\'a}th},
|
|
106
|
+
year={2026},
|
|
107
|
+
eprint={2601.11301},
|
|
108
|
+
archivePrefix={arXiv},
|
|
109
|
+
primaryClass={cs.CV},
|
|
110
|
+
url={https://arxiv.org/abs/2601.11301},
|
|
111
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
samannot/__init__.py,sha256=a4kXzhQQzVLzhXXz5NkOtyw9IqMN6DLNiTfvGHtoHXg,510
|
|
2
|
+
samannot/__main__.py,sha256=c_LoA7GKcrSxw-3t6Av41NMt_thIJRGgtJGISp1sXWo,70
|
|
3
|
+
samannot/annotator.py,sha256=5hg-0ODbl7n1WFi1iVM_CiflFqSuvlSO2wolXAhuTqY,47169
|
|
4
|
+
samannot/functional_widget_utils.py,sha256=E-BkyNgzahWS9a7kA4BIUGmJeM2cZwSJkOf6gGXX3xc,2458
|
|
5
|
+
samannot/keycodes_linux.json,sha256=chqXVIT4gjrVxXf3xUR6cKevLNg6aTXtRWE1AnOahYc,694
|
|
6
|
+
samannot/keycodes_windows.json,sha256=ZZ42fpszYx84JyD1wQ1v8pSpQA_IHpn-P0YnD7b_6bo,683
|
|
7
|
+
samannot/label.py,sha256=DbcTol4fiN2Zoq-aXyd_cockVv1AA2ezU-qnYeAccUg,3287
|
|
8
|
+
samannot/main.py,sha256=QlCwdpj4DQhFUkL1vCiMGBaB8kY4aejri-AMdCMnS8E,201
|
|
9
|
+
samannot/main_window.py,sha256=gw84JXebmpuMsKOIlskq_fTyuk13fbwYTnxPjo7oH70,98962
|
|
10
|
+
samannot/model_downloader.py,sha256=-JjM1WMTdgjJn_WWL4uxebcFhzokGV9f7JkhhMo20Rs,13389
|
|
11
|
+
samannot/sam_annotator.py,sha256=rwAQxV8YQHMp2UBNgN0tMkfR_F5xvCkSc8BE_P-Ff6w,12605
|
|
12
|
+
samannot/system_monitor.py,sha256=ICcL3h-_Hk-a_wlgvN6l2JZ0jTnWi318H4Wscb-4SfQ,3316
|
|
13
|
+
samannot/user_guide.py,sha256=kRi_Zkw9l750a_n8NK35cNm0-HOw-D0jSOktkeAfO0Y,9102
|
|
14
|
+
samannot/visual_widget_utils.py,sha256=taE81iOh-aYhaStsL8uVHoNroZb5gu6dZdlhzdjQXM0,3193
|
|
15
|
+
samannot/sam2_configs/__init__.py,sha256=nywzbVIRHvUbrltJWdiUGWjp4mY4xoHeU4jFjTCAYk0,202
|
|
16
|
+
samannot/sam2_configs/sam2.1_hiera_l.yaml,sha256=NemoeM89TNBYPKpKpDGCtFTbk5Ssz6stDzeQ6tKCjLo,3916
|
|
17
|
+
samannot/sam2_configs/sam2_hiera_b+.yaml,sha256=WK5VOUZuHaS4VjRkJ6KajzZ1oMETLsC4G8ORHuF3XOk,3661
|
|
18
|
+
samannot/sam2_configs/sam2_hiera_b+_old.yaml,sha256=MqvJZEus-UQSF588mqaE0r7hzURxB9QQbI0xiYRf2dg,3661
|
|
19
|
+
samannot/sam2_configs/sam2_hiera_l.yaml,sha256=Mte_B75ONxeYX3YFL3QLkOTPr0VYhiGyht4kliwtL9M,3813
|
|
20
|
+
samannot/sam2_configs/sam2_hiera_l_old.yaml,sha256=4qpCOJtYFfG1zixSgvKrVH0nm7CyhhgJKQy9uJ_6tvA,3813
|
|
21
|
+
samannot/sam2_configs/sam2_hiera_s.yaml,sha256=A9EqSsIfgusenVw8gxmDmGsFgSyGG1iToCvDvdnsrE4,3775
|
|
22
|
+
samannot/sam2_configs/sam2_hiera_s_old.yaml,sha256=AmP5d-8THyOg-MD4nAjnRMijPB7cQt1SgpAVOrSLDyI,3775
|
|
23
|
+
samannot/sam2_configs/sam2_hiera_t.yaml,sha256=gpcGp2jWQfqGROGU0daTIq9dg3sJnocxrxR2In98VpE,3871
|
|
24
|
+
samannot/sam2_configs/sam2_hiera_t_old.yaml,sha256=9JCWQxBTZ8W81Xt3s8wJOkk2VSxR-xlqbP9rOMwdb8c,3871
|
|
25
|
+
samannot-0.6.0.dist-info/licenses/LICENSE,sha256=4rIRx3QvttU0CSxj5eI7bFFmLpQLL_7-9H67l06dUwI,1120
|
|
26
|
+
samannot-0.6.0.dist-info/METADATA,sha256=yLOwHszQmCmGBbL9Zp9_Pfbrd7FwVRrn0nNQwQJmhUs,3994
|
|
27
|
+
samannot-0.6.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
28
|
+
samannot-0.6.0.dist-info/entry_points.txt,sha256=tws1xlgJE0hMAXYG4Cpo5ielBo8Er9pkYDI93-xw6l0,48
|
|
29
|
+
samannot-0.6.0.dist-info/top_level.txt,sha256=NazS22YiAZ3PH8zzWP1HDv71ex73PBFxindTKuMczJA,9
|
|
30
|
+
samannot-0.6.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gergely Dinya and Anna Gelencsér-Horváth
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
samannot
|