anonymization-in-time 1.1.1__tar.gz

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.
Files changed (54) hide show
  1. anonymization_in_time-1.1.1/.github/dependabot.yml +11 -0
  2. anonymization_in_time-1.1.1/.gitignore +48 -0
  3. anonymization_in_time-1.1.1/AiT_Annotator.spec +64 -0
  4. anonymization_in_time-1.1.1/LICENSE.txt +21 -0
  5. anonymization_in_time-1.1.1/MYRIADPRO-REGULAR.OTF +0 -0
  6. anonymization_in_time-1.1.1/PKG-INFO +265 -0
  7. anonymization_in_time-1.1.1/README.md +206 -0
  8. anonymization_in_time-1.1.1/ait/__init__.py +2 -0
  9. anonymization_in_time-1.1.1/ait/annotation_viewer.py +168 -0
  10. anonymization_in_time-1.1.1/ait/export_video.py +468 -0
  11. anonymization_in_time-1.1.1/ait/launcher.py +343 -0
  12. anonymization_in_time-1.1.1/ait/ocr/__init__.py +10 -0
  13. anonymization_in_time-1.1.1/ait/ocr/engine.py +243 -0
  14. anonymization_in_time-1.1.1/ait/ocr/format.py +70 -0
  15. anonymization_in_time-1.1.1/ait/ocr/name_matching.py +376 -0
  16. anonymization_in_time-1.1.1/ait/ocr/pipeline.py +383 -0
  17. anonymization_in_time-1.1.1/ait/ocr/stabilization.py +190 -0
  18. anonymization_in_time-1.1.1/ait/process_videos.py +460 -0
  19. anonymization_in_time-1.1.1/ait/segmentation/__init__.py +10 -0
  20. anonymization_in_time-1.1.1/ait/segmentation/circularize.py +278 -0
  21. anonymization_in_time-1.1.1/ait/segmentation/engine.py +106 -0
  22. anonymization_in_time-1.1.1/ait/segmentation/format.py +100 -0
  23. anonymization_in_time-1.1.1/ait/segmentation/mask_ops.py +293 -0
  24. anonymization_in_time-1.1.1/ait/segmentation/pipeline.py +413 -0
  25. anonymization_in_time-1.1.1/ait/segmentation/tracking.py +186 -0
  26. anonymization_in_time-1.1.1/ait/transition_detection.py +396 -0
  27. anonymization_in_time-1.1.1/ait/utils.py +698 -0
  28. anonymization_in_time-1.1.1/ait/video_processor_gui.py +427 -0
  29. anonymization_in_time-1.1.1/ait/viewer/__init__.py +3 -0
  30. anonymization_in_time-1.1.1/ait/viewer/main.py +47 -0
  31. anonymization_in_time-1.1.1/ait/viewer/models/__init__.py +4 -0
  32. anonymization_in_time-1.1.1/ait/viewer/models/annotation_manager.py +396 -0
  33. anonymization_in_time-1.1.1/ait/viewer/models/transition_manager.py +190 -0
  34. anonymization_in_time-1.1.1/ait/viewer/ui/__init__.py +5 -0
  35. anonymization_in_time-1.1.1/ait/viewer/ui/canvas_widget_tk.py +614 -0
  36. anonymization_in_time-1.1.1/ait/viewer/ui/main_window_tk.py +626 -0
  37. anonymization_in_time-1.1.1/ait/viewer/utils/__init__.py +20 -0
  38. anonymization_in_time-1.1.1/ait/viewer/utils/mask_utils.py +6 -0
  39. anonymization_in_time-1.1.1/ait/viewer/utils/pickle_loader.py +124 -0
  40. anonymization_in_time-1.1.1/docs/BATCH_PROCESSING_GUIDE.md +334 -0
  41. anonymization_in_time-1.1.1/docs/CLAUDE.md +112 -0
  42. anonymization_in_time-1.1.1/docs/QUICK_START.md +159 -0
  43. anonymization_in_time-1.1.1/docs/analysis_results.md +52 -0
  44. anonymization_in_time-1.1.1/docs/example/test.json +8 -0
  45. anonymization_in_time-1.1.1/docs/example/test.mp4 +0 -0
  46. anonymization_in_time-1.1.1/docs/example/test_anonymized.mp4 +0 -0
  47. anonymization_in_time-1.1.1/docs/screenshots/annotation_viewer.jpg +0 -0
  48. anonymization_in_time-1.1.1/docs/screenshots/launcher.png +0 -0
  49. anonymization_in_time-1.1.1/docs/screenshots/video_processor.jpg +0 -0
  50. anonymization_in_time-1.1.1/pyproject.toml +72 -0
  51. anonymization_in_time-1.1.1/requirements.txt +21 -0
  52. anonymization_in_time-1.1.1/start_ait.bat +26 -0
  53. anonymization_in_time-1.1.1/tools/inspect_ocr_pipeline.py +424 -0
  54. anonymization_in_time-1.1.1/tools/inspect_sam3_pipeline.py +441 -0
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "pip"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 5
8
+ labels:
9
+ - "dependencies"
10
+ commit-message:
11
+ prefix: "deps"
@@ -0,0 +1,48 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.so
5
+ .Python
6
+ build/
7
+ develop-eggs/
8
+ dist/
9
+ downloads/
10
+ eggs/
11
+ .eggs/
12
+ lib/
13
+ lib64/
14
+ parts/
15
+ sdist/
16
+ var/
17
+ wheels/
18
+ *.egg-info/
19
+ .installed.cfg
20
+ *.egg
21
+
22
+ # Virtual environments
23
+ venv/
24
+ env/
25
+ ENV/
26
+ .venv/
27
+
28
+ # IDE
29
+ .vscode/
30
+ .idea/
31
+ *.swp
32
+ *.swo
33
+
34
+ # Data files
35
+ data/
36
+
37
+ # OS
38
+ .DS_Store
39
+ Thumbs.db
40
+
41
+ # SAM3 model
42
+ sam3.pt
43
+
44
+ # Claude
45
+ .claude
46
+
47
+ # Test
48
+ other_src/
@@ -0,0 +1,64 @@
1
+ # -*- mode: python ; coding: utf-8 -*-
2
+ """
3
+ PyInstaller spec file for building AiT Annotation Viewer executable.
4
+
5
+ Usage:
6
+ pyinstaller AiT_Annotator.spec
7
+ """
8
+
9
+ block_cipher = None
10
+
11
+ a = Analysis(
12
+ ['ait/viewer/main.py'],
13
+ pathex=[],
14
+ binaries=[],
15
+ datas=[],
16
+ hiddenimports=[
17
+ 'PySide6.QtCore',
18
+ 'PySide6.QtGui',
19
+ 'PySide6.QtWidgets',
20
+ 'numpy',
21
+ 'PIL',
22
+ ],
23
+ hookspath=[],
24
+ hooksconfig={},
25
+ runtime_hooks=[],
26
+ excludes=[],
27
+ win_no_prefer_redirects=False,
28
+ win_private_assemblies=False,
29
+ cipher=block_cipher,
30
+ noarchive=False,
31
+ )
32
+
33
+ pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
34
+
35
+ exe = EXE(
36
+ pyz,
37
+ a.scripts,
38
+ a.binaries,
39
+ a.zipfiles,
40
+ a.datas,
41
+ [],
42
+ name='AiT_Annotator',
43
+ debug=False,
44
+ bootloader_ignore_signals=False,
45
+ strip=False,
46
+ upx=True,
47
+ upx_exclude=[],
48
+ runtime_tmpdir=None,
49
+ console=False, # Set to True for debugging
50
+ disable_windowed_traceback=False,
51
+ argv_emulation=False,
52
+ target_arch=None,
53
+ codesign_identity=None,
54
+ entitlements_file=None,
55
+ icon=None, # Add path to .ico file if you have one
56
+ )
57
+
58
+ # For macOS
59
+ app = BUNDLE(
60
+ exe,
61
+ name='AiT_Annotator.app',
62
+ icon=None, # Add path to .icns file if you have one
63
+ bundle_identifier='com.ait.annotator',
64
+ )
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 University of Bern, Data Science Lab, Matteo Boi
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,265 @@
1
+ Metadata-Version: 2.4
2
+ Name: anonymization-in-time
3
+ Version: 1.1.1
4
+ Summary: AiT (Anonymization in Time) - Video anonymization tool for chat recordings
5
+ Project-URL: Homepage, https://github.com/dsl-unibe-ch/Anonymization-in-Time
6
+ Project-URL: Repository, https://github.com/dsl-unibe-ch/Anonymization-in-Time
7
+ Project-URL: Issues, https://github.com/dsl-unibe-ch/Anonymization-in-Time/issues
8
+ Author: Matteo Boi, University of Bern, Data Science Lab
9
+ License: MIT License
10
+
11
+ Copyright (c) 2026 University of Bern, Data Science Lab, Matteo Boi
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE.txt
31
+ Keywords: anonymization,doctr,easyocr,ocr,privacy,sam3,segmentation,video
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Multimedia :: Video
41
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
42
+ Requires-Python: >=3.10
43
+ Requires-Dist: easyocr>=1.7.1
44
+ Requires-Dist: einops>=0.6.1
45
+ Requires-Dist: joblib>=1.3.0
46
+ Requires-Dist: numpy>=1.24
47
+ Requires-Dist: opencv-python>=4.8.0
48
+ Requires-Dist: pillow>=10.0.0
49
+ Requires-Dist: pycocotools>=2.0.6
50
+ Requires-Dist: python-doctr[torch]>=0.9.0
51
+ Requires-Dist: scikit-learn>=1.4.0
52
+ Requires-Dist: torch>=2.0
53
+ Requires-Dist: tqdm>=4.66.0
54
+ Requires-Dist: transformers>=4.46.0
55
+ Requires-Dist: ultralytics>=8.0.114
56
+ Provides-Extra: build
57
+ Requires-Dist: pyinstaller>=6.0.0; extra == 'build'
58
+ Description-Content-Type: text/markdown
59
+
60
+ # AiT — Anonymization in Time
61
+
62
+ Video anonymization tool for chat recordings. Detects names (OCR) and profile pictures (segmentation) in video frames, then lets you review and export anonymized videos with blurring applied.
63
+
64
+ ## Features
65
+
66
+ - **Processing pipeline**: Frame extraction, OCR text detection, SAM3 segmentation, scene transition detection
67
+ - **Annotation viewer**: Navigate frames, toggle annotation visibility, preview hidden annotations on hover
68
+ - **Video export**: Apply Gaussian blur to visible annotations for anonymization
69
+ - **Cross-platform**: Works on Windows, Mac, and Linux
70
+
71
+ ## Project Structure
72
+
73
+ ```
74
+ AiT_app/
75
+ ├── ait/ # Main Python package
76
+ │ ├── ocr/ # OCR text detection pipeline (EasyOCR)
77
+ │ ├── segmentation/ # Profile picture segmentation pipeline (SAM3)
78
+ │ ├── viewer/ # Tkinter annotation viewer app
79
+ │ ├── utils.py # Shared utilities (frame extraction, device management)
80
+ │ ├── process_videos.py # Pipeline orchestrator
81
+ │ ├── export_video.py # Anonymized video export
82
+ │ ├── launcher.py # GUI launcher
83
+ │ └── ...
84
+ ├── tools/ # Development/debug tools
85
+ │ ├── inspect_sam3_pipeline.py
86
+ │ └── inspect_ocr_pipeline.py
87
+ ├── pyproject.toml
88
+ ├── requirements.txt
89
+ └── sam3.pt # Model weights (download separately)
90
+ ```
91
+
92
+ ## Installation
93
+
94
+ ### 1. Install the package
95
+
96
+ ```bash
97
+ pip install -e .
98
+ ```
99
+
100
+ Or with requirements.txt:
101
+ ```bash
102
+ pip install -r requirements.txt
103
+ pip install -e .
104
+ ```
105
+
106
+ ### 2. PyTorch (for processing)
107
+
108
+ If you need GPU acceleration, install PyTorch with CUDA before the package:
109
+ ```bash
110
+ # CUDA 12.6
111
+ pip install torch==2.7.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
112
+
113
+ # CPU/MPS (default)
114
+ pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0
115
+ ```
116
+
117
+ ### 3. SAM3 model weights
118
+
119
+ > ⚠️ **SAM 3 Model Weights Required**
120
+ > Unlike other Ultralytics models, SAM 3 weights are not automatically downloaded. You must:
121
+ > 1. Request access on the [SAM 3 model page on Hugging Face](https://huggingface.co/facebook/sam3.1)
122
+ > 2. Once approved, download the `sam3.1_multiplex.pt` file
123
+ > 3. Rename it to `sam3.pt` and place it in the project root
124
+
125
+ The segmentation pipeline looks for `sam3.pt` in the working directory.
126
+
127
+ ### 4. ffmpeg
128
+
129
+ Required for frame extraction:
130
+ - **Windows**: Download from https://ffmpeg.org and add to PATH
131
+ - **macOS**: `brew install ffmpeg`
132
+ - **Linux**: `sudo apt install ffmpeg`
133
+
134
+ ## Usage
135
+
136
+ After installation, these CLI commands are available:
137
+
138
+ ```bash
139
+ ait # Launch the GUI (choose between processor and viewer)
140
+ ait-process # Run the video processing pipeline
141
+ ait-viewer # Open the annotation viewer
142
+ ait-export # Export anonymized video
143
+ ```
144
+
145
+ Or run directly with Python:
146
+ ```bash
147
+ python -m ait.launcher
148
+ python -m ait.process_videos --help
149
+ python -m ait.annotation_viewer
150
+ python -m ait.export_video --help
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Launcher
156
+
157
+ The `ait` command opens the AiT launcher — the central hub for the three tools.
158
+
159
+ <img src="docs/screenshots/launcher.png" height="400">
160
+
161
+ - **Video Processor** — runs the detection pipeline on your video files. Click **Launch Video Processor** to open it.
162
+ - **Annotation Viewer** — lets you review and refine detections before exporting. Select a processed video folder first, then click **Launch Annotation Viewer**.
163
+ - **Export Anonymized Video** — exports the final video with blur applied. Set the **Blur Strength** (Gaussian kernel size, odd number between 3 and 201 — higher means stronger blur, default 51), select a processed folder, and click **Export Video**.
164
+
165
+ ---
166
+
167
+ ## Video Processor
168
+
169
+ The Video Processor runs the full detection pipeline on your videos: frame extraction, OCR name detection, SAM3 profile picture segmentation, and scene transition detection.
170
+
171
+ <img src="docs/screenshots/video_processor.jpg" height="400">
172
+
173
+ ### Input (1)
174
+
175
+ | Field | Description |
176
+ |-------|-------------|
177
+ | **Videos** | Select individual video files or a folder containing videos. Supported formats: `.mp4`, `.avi`, `.mov`, `.mkv`, `.webm` |
178
+ | **Output Dir** | Where processed results are saved. Each video gets its own subfolder with extracted frames, `ocr.pkl`, and `sam3.pkl` |
179
+ | **Names Dict** | A JSON file mapping real names to pseudonyms (alteregos). Format: `{"Real Name": "Fake Name"}`. Names with an empty string `""` are detected and the text box blurred, but no alterego name is drawn on top |
180
+
181
+ ### Processing Parameters (2)
182
+
183
+ | Parameter | Description |
184
+ |-----------|-------------|
185
+ | **Frame Step** | Extract every Nth frame (default: `1` = all frames). Use higher values to speed up processing on long videos. Keep in mind that more frames skipped means less accuracy |
186
+ | **OCR Engine** | Choose between **docTR** and **EasyOCR**. **docTR** works best for phone/tablet UIs and documents with clean text rendering. **EasyOCR** is better for real-world videos with varied fonts and backgrounds, but requires specifying the language(s) |
187
+ | **OCR Languages** | Only used with EasyOCR. Space-separated language codes, e.g. `en de` for English and German |
188
+ | **SAM3 Device** | `auto` picks the best available accelerator (CUDA > MPS > CPU). You can force a specific device if needed |
189
+ | **SAM3 Prompt** | The text prompt that guides SAM3 segmentation. The default `"profile image, profile picture"` works well for chat recordings |
190
+
191
+ ### Processing Options (3)
192
+
193
+ | Option | Description |
194
+ |--------|-------------|
195
+ | **Skip OCR** | Skip the OCR detection stage (useful for re-running only segmentation) |
196
+ | **Skip SAM3** | Skip the segmentation stage |
197
+ | **Skip transitions** | Skip scene transition detection (enabled by default since it's usually only needed for specific use cases) |
198
+
199
+ Frame extraction is always automatic: if frames already exist in the output folder with the correct count, extraction is skipped.
200
+
201
+ ### Controls (4)
202
+
203
+ - **Start Processing** — begins the pipeline (enabled once Videos, Output Dir, and Names Dict are all set)
204
+ - **Stop** — stops processing **after the current step completes**
205
+ - **Clear Log** — clears the processing log
206
+ - The **progress bar** animates while processing is active
207
+
208
+ ### Processing Log (5)
209
+
210
+ Real-time output from the pipeline, showing progress for each stage.
211
+
212
+ ---
213
+
214
+ ## Annotation Viewer
215
+
216
+ The Annotation Viewer lets you review and refine the automated detections before exporting the anonymized video. You can toggle individual annotations on/off to control exactly what gets blurred.
217
+
218
+ <img src="docs/screenshots/annotation_viewer.jpg" height="400">
219
+
220
+ ### Canvas (1)
221
+
222
+ The main display area showing the current video frame with annotation overlays:
223
+ - **Green boxes** — visible OCR detections (will be blurred on export). The alterego name is displayed on top of the original text
224
+ - **Blue masks** — visible SAM3 segmentation masks (profile pictures)
225
+ - **Click** on any visible annotation to **hide** it — it will no longer be blurred on export (and viceversa)
226
+ - **Right-click** on a word to toggle the entire parent name (e.g. clicking on "Mark" toggles both "Mark" and "Jhonson")
227
+ - Enable **Hidden Preview** (H) to see hidden annotations as semi-transparent outlines — click them to make them visible (and blurred) again
228
+
229
+ ### Frame Navigation (2)
230
+
231
+ - **Slider** — drag to jump to any frame
232
+ - **Previous / Next buttons** — step one frame at a time
233
+ - **Mouse wheel** — scroll to navigate frames (one frame per tick)
234
+ - **Arrow keys**: Left/Right = 1 frame, Up/Down = 10 frames, Home/End = first/last frame
235
+
236
+ ### Frame Info (3)
237
+
238
+ Shows the current frame position, frame index, and annotation statistics (OCR count, SAM3 count, visible/hidden counts). If the current frame is inside a transition range, a `[TRANSITION]` indicator appears.
239
+
240
+ ### Transition Controls (4)
241
+
242
+ Transitions mark frame ranges where the video content changes (e.g. a window switch, a new chat being opened). During export, transition frames are fully blurred to prevent leaking content from the old/new view.
243
+
244
+ | Button | Shortcut | Description |
245
+ |--------|----------|-------------|
246
+ | **Mark Start** | `T` | Mark the current frame as the start of a transition |
247
+ | **Mark End** | `E` | Mark the current frame as the end — creates the transition range |
248
+ | **Remove** | `R` | Remove the transition range at the current frame |
249
+
250
+ Use the **Transitions** menu to list (4.1) all transitions or save them.
251
+
252
+ ### View Controls (5)
253
+
254
+ | Button | Shortcut | Description |
255
+ |--------|----------|-------------|
256
+ | **Toggle Hidden Preview** | `H` | Show hidden annotations as semi-transparent outlines, so you can find and re-enable them |
257
+ | **Preview Blur** | `B` | Preview what the exported video will look like with blur applied to all visible annotations |
258
+
259
+ ### Save & Export (6)
260
+
261
+ | Button | Shortcut | Description |
262
+ |--------|----------|-------------|
263
+ | **Save State** | `S` / `Ctrl+S` | Save visibility toggles and transition ranges so you can resume later |
264
+ | **Export Visibility** | — | Export the visibility state as a standalone pickle file |
265
+ | **Export Anonymized Video** | — | Available from the **File** menu (6.1). Exports the video with Gaussian blur applied to all visible annotations and full blur on transition frames |
@@ -0,0 +1,206 @@
1
+ # AiT — Anonymization in Time
2
+
3
+ Video anonymization tool for chat recordings. Detects names (OCR) and profile pictures (segmentation) in video frames, then lets you review and export anonymized videos with blurring applied.
4
+
5
+ ## Features
6
+
7
+ - **Processing pipeline**: Frame extraction, OCR text detection, SAM3 segmentation, scene transition detection
8
+ - **Annotation viewer**: Navigate frames, toggle annotation visibility, preview hidden annotations on hover
9
+ - **Video export**: Apply Gaussian blur to visible annotations for anonymization
10
+ - **Cross-platform**: Works on Windows, Mac, and Linux
11
+
12
+ ## Project Structure
13
+
14
+ ```
15
+ AiT_app/
16
+ ├── ait/ # Main Python package
17
+ │ ├── ocr/ # OCR text detection pipeline (EasyOCR)
18
+ │ ├── segmentation/ # Profile picture segmentation pipeline (SAM3)
19
+ │ ├── viewer/ # Tkinter annotation viewer app
20
+ │ ├── utils.py # Shared utilities (frame extraction, device management)
21
+ │ ├── process_videos.py # Pipeline orchestrator
22
+ │ ├── export_video.py # Anonymized video export
23
+ │ ├── launcher.py # GUI launcher
24
+ │ └── ...
25
+ ├── tools/ # Development/debug tools
26
+ │ ├── inspect_sam3_pipeline.py
27
+ │ └── inspect_ocr_pipeline.py
28
+ ├── pyproject.toml
29
+ ├── requirements.txt
30
+ └── sam3.pt # Model weights (download separately)
31
+ ```
32
+
33
+ ## Installation
34
+
35
+ ### 1. Install the package
36
+
37
+ ```bash
38
+ pip install -e .
39
+ ```
40
+
41
+ Or with requirements.txt:
42
+ ```bash
43
+ pip install -r requirements.txt
44
+ pip install -e .
45
+ ```
46
+
47
+ ### 2. PyTorch (for processing)
48
+
49
+ If you need GPU acceleration, install PyTorch with CUDA before the package:
50
+ ```bash
51
+ # CUDA 12.6
52
+ pip install torch==2.7.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
53
+
54
+ # CPU/MPS (default)
55
+ pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0
56
+ ```
57
+
58
+ ### 3. SAM3 model weights
59
+
60
+ > ⚠️ **SAM 3 Model Weights Required**
61
+ > Unlike other Ultralytics models, SAM 3 weights are not automatically downloaded. You must:
62
+ > 1. Request access on the [SAM 3 model page on Hugging Face](https://huggingface.co/facebook/sam3.1)
63
+ > 2. Once approved, download the `sam3.1_multiplex.pt` file
64
+ > 3. Rename it to `sam3.pt` and place it in the project root
65
+
66
+ The segmentation pipeline looks for `sam3.pt` in the working directory.
67
+
68
+ ### 4. ffmpeg
69
+
70
+ Required for frame extraction:
71
+ - **Windows**: Download from https://ffmpeg.org and add to PATH
72
+ - **macOS**: `brew install ffmpeg`
73
+ - **Linux**: `sudo apt install ffmpeg`
74
+
75
+ ## Usage
76
+
77
+ After installation, these CLI commands are available:
78
+
79
+ ```bash
80
+ ait # Launch the GUI (choose between processor and viewer)
81
+ ait-process # Run the video processing pipeline
82
+ ait-viewer # Open the annotation viewer
83
+ ait-export # Export anonymized video
84
+ ```
85
+
86
+ Or run directly with Python:
87
+ ```bash
88
+ python -m ait.launcher
89
+ python -m ait.process_videos --help
90
+ python -m ait.annotation_viewer
91
+ python -m ait.export_video --help
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Launcher
97
+
98
+ The `ait` command opens the AiT launcher — the central hub for the three tools.
99
+
100
+ <img src="docs/screenshots/launcher.png" height="400">
101
+
102
+ - **Video Processor** — runs the detection pipeline on your video files. Click **Launch Video Processor** to open it.
103
+ - **Annotation Viewer** — lets you review and refine detections before exporting. Select a processed video folder first, then click **Launch Annotation Viewer**.
104
+ - **Export Anonymized Video** — exports the final video with blur applied. Set the **Blur Strength** (Gaussian kernel size, odd number between 3 and 201 — higher means stronger blur, default 51), select a processed folder, and click **Export Video**.
105
+
106
+ ---
107
+
108
+ ## Video Processor
109
+
110
+ The Video Processor runs the full detection pipeline on your videos: frame extraction, OCR name detection, SAM3 profile picture segmentation, and scene transition detection.
111
+
112
+ <img src="docs/screenshots/video_processor.jpg" height="400">
113
+
114
+ ### Input (1)
115
+
116
+ | Field | Description |
117
+ |-------|-------------|
118
+ | **Videos** | Select individual video files or a folder containing videos. Supported formats: `.mp4`, `.avi`, `.mov`, `.mkv`, `.webm` |
119
+ | **Output Dir** | Where processed results are saved. Each video gets its own subfolder with extracted frames, `ocr.pkl`, and `sam3.pkl` |
120
+ | **Names Dict** | A JSON file mapping real names to pseudonyms (alteregos). Format: `{"Real Name": "Fake Name"}`. Names with an empty string `""` are detected and the text box blurred, but no alterego name is drawn on top |
121
+
122
+ ### Processing Parameters (2)
123
+
124
+ | Parameter | Description |
125
+ |-----------|-------------|
126
+ | **Frame Step** | Extract every Nth frame (default: `1` = all frames). Use higher values to speed up processing on long videos. Keep in mind that more frames skipped means less accuracy |
127
+ | **OCR Engine** | Choose between **docTR** and **EasyOCR**. **docTR** works best for phone/tablet UIs and documents with clean text rendering. **EasyOCR** is better for real-world videos with varied fonts and backgrounds, but requires specifying the language(s) |
128
+ | **OCR Languages** | Only used with EasyOCR. Space-separated language codes, e.g. `en de` for English and German |
129
+ | **SAM3 Device** | `auto` picks the best available accelerator (CUDA > MPS > CPU). You can force a specific device if needed |
130
+ | **SAM3 Prompt** | The text prompt that guides SAM3 segmentation. The default `"profile image, profile picture"` works well for chat recordings |
131
+
132
+ ### Processing Options (3)
133
+
134
+ | Option | Description |
135
+ |--------|-------------|
136
+ | **Skip OCR** | Skip the OCR detection stage (useful for re-running only segmentation) |
137
+ | **Skip SAM3** | Skip the segmentation stage |
138
+ | **Skip transitions** | Skip scene transition detection (enabled by default since it's usually only needed for specific use cases) |
139
+
140
+ Frame extraction is always automatic: if frames already exist in the output folder with the correct count, extraction is skipped.
141
+
142
+ ### Controls (4)
143
+
144
+ - **Start Processing** — begins the pipeline (enabled once Videos, Output Dir, and Names Dict are all set)
145
+ - **Stop** — stops processing **after the current step completes**
146
+ - **Clear Log** — clears the processing log
147
+ - The **progress bar** animates while processing is active
148
+
149
+ ### Processing Log (5)
150
+
151
+ Real-time output from the pipeline, showing progress for each stage.
152
+
153
+ ---
154
+
155
+ ## Annotation Viewer
156
+
157
+ The Annotation Viewer lets you review and refine the automated detections before exporting the anonymized video. You can toggle individual annotations on/off to control exactly what gets blurred.
158
+
159
+ <img src="docs/screenshots/annotation_viewer.jpg" height="400">
160
+
161
+ ### Canvas (1)
162
+
163
+ The main display area showing the current video frame with annotation overlays:
164
+ - **Green boxes** — visible OCR detections (will be blurred on export). The alterego name is displayed on top of the original text
165
+ - **Blue masks** — visible SAM3 segmentation masks (profile pictures)
166
+ - **Click** on any visible annotation to **hide** it — it will no longer be blurred on export (and viceversa)
167
+ - **Right-click** on a word to toggle the entire parent name (e.g. clicking on "Mark" toggles both "Mark" and "Jhonson")
168
+ - Enable **Hidden Preview** (H) to see hidden annotations as semi-transparent outlines — click them to make them visible (and blurred) again
169
+
170
+ ### Frame Navigation (2)
171
+
172
+ - **Slider** — drag to jump to any frame
173
+ - **Previous / Next buttons** — step one frame at a time
174
+ - **Mouse wheel** — scroll to navigate frames (one frame per tick)
175
+ - **Arrow keys**: Left/Right = 1 frame, Up/Down = 10 frames, Home/End = first/last frame
176
+
177
+ ### Frame Info (3)
178
+
179
+ Shows the current frame position, frame index, and annotation statistics (OCR count, SAM3 count, visible/hidden counts). If the current frame is inside a transition range, a `[TRANSITION]` indicator appears.
180
+
181
+ ### Transition Controls (4)
182
+
183
+ Transitions mark frame ranges where the video content changes (e.g. a window switch, a new chat being opened). During export, transition frames are fully blurred to prevent leaking content from the old/new view.
184
+
185
+ | Button | Shortcut | Description |
186
+ |--------|----------|-------------|
187
+ | **Mark Start** | `T` | Mark the current frame as the start of a transition |
188
+ | **Mark End** | `E` | Mark the current frame as the end — creates the transition range |
189
+ | **Remove** | `R` | Remove the transition range at the current frame |
190
+
191
+ Use the **Transitions** menu to list (4.1) all transitions or save them.
192
+
193
+ ### View Controls (5)
194
+
195
+ | Button | Shortcut | Description |
196
+ |--------|----------|-------------|
197
+ | **Toggle Hidden Preview** | `H` | Show hidden annotations as semi-transparent outlines, so you can find and re-enable them |
198
+ | **Preview Blur** | `B` | Preview what the exported video will look like with blur applied to all visible annotations |
199
+
200
+ ### Save & Export (6)
201
+
202
+ | Button | Shortcut | Description |
203
+ |--------|----------|-------------|
204
+ | **Save State** | `S` / `Ctrl+S` | Save visibility toggles and transition ranges so you can resume later |
205
+ | **Export Visibility** | — | Export the visibility state as a standalone pickle file |
206
+ | **Export Anonymized Video** | — | Available from the **File** menu (6.1). Exports the video with Gaussian blur applied to all visible annotations and full blur on transition frames |
@@ -0,0 +1,2 @@
1
+ """AiT (Anonymization in Time) - Video anonymization tool."""
2
+ __version__ = "1.1.1"