duyle2408 commited on
Commit
33c93f7
·
verified ·
1 Parent(s): eba418d

Upload milk10k code

Browse files
.gitignore ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ .pytest_cache/
5
+ .venv/
6
+
7
+ # Local agent/tool state
8
+ .agents/
9
+ .codex/
10
+ .understand-anything/
11
+
12
+ # Data, caches, and learned weights
13
+ data/
14
+ feature_cache/
15
+ checkpoints/
16
+ *.pt
17
+ *.pth
18
+ *.ckpt
19
+
20
+ # Generated analysis and competition outputs
21
+ eda_output/
22
+ diagnostics_*.csv
23
+ diagnostics_*.png
24
+ submission*.csv
25
+ *.zip
26
+
27
+ # Editor/OS files
28
+ .DS_Store
29
+ .idea/
30
+ .vscode/
31
+
.pytest_cache/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Created by pytest automatically.
2
+ *
.pytest_cache/CACHEDIR.TAG ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Signature: 8a477f597d28d172789f06886806bc55
2
+ # This file is a cache directory tag created by pytest.
3
+ # For information about cache directory tags, see:
4
+ # https://bford.info/cachedir/spec.html
.pytest_cache/README.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # pytest cache directory #
2
+
3
+ This directory contains data from the pytest's cache plugin,
4
+ which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
+
6
+ **Do not** commit this to version control.
7
+
8
+ See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
.pytest_cache/v/cache/lastfailed ADDED
@@ -0,0 +1 @@
 
 
1
+ {}
.pytest_cache/v/cache/nodeids ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ [
2
+ "tests/test_ssl_retrieval.py::test_degradation_ranking_and_metrics",
3
+ "tests/test_ssl_retrieval.py::test_manifest_and_pseudo_split",
4
+ "tests/test_ssl_retrieval.py::test_models_losses_and_checkpoint"
5
+ ]
.understand-anything/.understandignore ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # .understandignore — patterns for files/dirs to exclude from analysis
2
+ # Syntax: same as .gitignore (globs, # comments, ! negation, trailing / for dirs)
3
+ # Lines below are suggestions — uncomment to activate.
4
+ # Use ! prefix to force-include something excluded by defaults.
5
+ #
6
+ # Built-in defaults (always excluded unless negated):
7
+ # node_modules/, .git/, dist/, build/, obj/, *.lock, *.min.js, etc.
8
+ #
9
+
10
+ # --- Test file patterns (uncomment to exclude) ---
11
+
12
+ # JS / TS
13
+ # *.test.*
14
+ # *.spec.*
15
+ # *.snap
16
+ # C# / .NET
17
+ # **/*Tests.cs
18
+ # **/*Test.cs
19
+ # **/*Fixture.cs
20
+ # **/*.Tests.csproj
21
+ # Java / Kotlin
22
+ # **/src/test/**
23
+ # **/*Test.java
24
+ # **/*IT.java
25
+ # **/*Spec.kt
26
+ # Go
27
+ # **/*_test.go
28
+ # C++
29
+ # **/*_test.cc
30
+ # **/*_test.cpp
31
+ # **/*_test.cxx
32
+ # **/*Test.cc
33
+ # **/*Test.cpp
34
+ # **/*_unittest.cc
35
+ # **/*_unittest.cpp
36
+ # **/*_browsertest.cc
37
+ # **/*_benchmark.cc
38
+ # **/*Benchmark.cpp
39
+
40
+ # Generated datasets, model caches, and analysis outputs
41
+ data/
42
+ feature_cache/
43
+ eda_output/
44
+ best_submission_analysis/
45
+ *.csv
46
+ *.zip
47
+ __pycache__/
.understand-anything/config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "outputLanguage": "vi"
3
+ }
.understand-anything/intermediate/assembled-graph.json ADDED
@@ -0,0 +1,1223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nodes": [
3
+ {
4
+ "id": "file:.understand-anything/.understandignore",
5
+ "type": "file",
6
+ "name": ".understandignore",
7
+ "filePath": ".understand-anything/.understandignore",
8
+ "summary": "Danh sách quy tắc loại trừ dùng khi quét project để knowledge graph bỏ qua dữ liệu, artifact sinh ra, cache và các file không cần phân tích.",
9
+ "tags": [
10
+ "configuration",
11
+ "ignore-rules",
12
+ "knowledge-graph"
13
+ ],
14
+ "complexity": "simple"
15
+ },
16
+ {
17
+ "id": "config:.understand-anything/config.json",
18
+ "type": "config",
19
+ "name": "config.json",
20
+ "filePath": ".understand-anything/config.json",
21
+ "summary": "Cấu hình Understand Anything chọn tiếng Việt làm ngôn ngữ đầu ra cho nội dung knowledge graph.",
22
+ "tags": [
23
+ "configuration",
24
+ "localization",
25
+ "knowledge-graph"
26
+ ],
27
+ "complexity": "simple"
28
+ },
29
+ {
30
+ "id": "file:baseline_dinov3.py",
31
+ "type": "file",
32
+ "name": "baseline_dinov3.py",
33
+ "filePath": "baseline_dinov3.py",
34
+ "summary": "Pipeline baseline dạng notebook-script dùng DINOv3/ConvNeXt để trích xuất embedding, tìm kiếm cosine, thử TTA và tạo submission cho image-to-image retrieval không nhãn. File còn cung cấp kiểm tra định dạng submission và trực quan hóa kết quả.",
35
+ "tags": [
36
+ "retrieval",
37
+ "feature-extraction",
38
+ "dinov3",
39
+ "entry-point"
40
+ ],
41
+ "complexity": "complex",
42
+ "languageNotes": "Python cell markers `# %%` cho phép chạy tuần tự như notebook; inference dùng PyTorch autocast và embedding chuẩn hóa L2."
43
+ },
44
+ {
45
+ "id": "document:de_bai_image_to_image_retrieval.md",
46
+ "type": "document",
47
+ "name": "de_bai_image_to_image_retrieval.md",
48
+ "filePath": "de_bai_image_to_image_retrieval.md",
49
+ "summary": "Đặc tả bài thi Olympic AI về instance retrieval không nhãn, gồm dữ liệu train/public/private test, định dạng top-10 submission, chỉ số mAP@10 và các ràng buộc chống suy diễn nhãn.",
50
+ "tags": [
51
+ "documentation",
52
+ "problem-specification",
53
+ "retrieval",
54
+ "evaluation"
55
+ ],
56
+ "complexity": "moderate"
57
+ },
58
+ {
59
+ "id": "file:eda.py",
60
+ "type": "file",
61
+ "name": "eda.py",
62
+ "filePath": "eda.py",
63
+ "summary": "CLI EDA tái lập được cho dataset retrieval không nhãn: kiểm tra manifest và tính toàn vẹn ảnh, đo thống kê suy giảm/chuyển dịch phân phối, rồi xuất CSV, báo cáo Markdown và các grid/histogram.",
64
+ "tags": [
65
+ "entry-point",
66
+ "eda",
67
+ "data-validation",
68
+ "visualization"
69
+ ],
70
+ "complexity": "complex",
71
+ "languageNotes": "Tách backend Matplotlib `Agg` để chạy headless và dùng SHA-256 phát hiện ảnh trùng chính xác giữa các split."
72
+ },
73
+ {
74
+ "id": "file:notebook324f4a11f8_upgraded.ipynb",
75
+ "type": "file",
76
+ "name": "notebook324f4a11f8_upgraded.ipynb",
77
+ "filePath": "notebook324f4a11f8_upgraded.ipynb",
78
+ "summary": "Notebook thử nghiệm nâng cấp pipeline image retrieval, lưu cả code cell, metadata và output thực thi để nghiên cứu các biến thể feature extraction, ranking và chẩn đoán.",
79
+ "tags": [
80
+ "notebook",
81
+ "retrieval",
82
+ "experimentation",
83
+ "data-science"
84
+ ],
85
+ "complexity": "complex",
86
+ "languageNotes": "Định dạng Jupyter Notebook JSON gói code, kết quả và metadata trong một artifact lớn."
87
+ },
88
+ {
89
+ "id": "file:retrieval_advanced.py",
90
+ "type": "file",
91
+ "name": "retrieval_advanced.py",
92
+ "filePath": "retrieval_advanced.py",
93
+ "summary": "Pipeline retrieval nâng cao kết hợp max-over-D4 global similarity, dense symmetric-Chamfer reranking và SIFT/RANSAC geometric reranking. Feature được cache theo model, manifest và view; pipeline xuất submission cùng diagnostics không cần nhãn.",
94
+ "tags": [
95
+ "retrieval",
96
+ "reranking",
97
+ "feature-cache",
98
+ "dinov3",
99
+ "entry-point"
100
+ ],
101
+ "complexity": "complex",
102
+ "languageNotes": "Script dùng `# %%` như notebook, hỗ trợ cả tensor feature map của ConvNeXt và patch-token sequence của ViT/EVA."
103
+ },
104
+ {
105
+ "id": "function:baseline_dinov3.py:load_manifest",
106
+ "type": "function",
107
+ "name": "load_manifest",
108
+ "filePath": "baseline_dinov3.py",
109
+ "lineRange": [
110
+ 43,
111
+ 51
112
+ ],
113
+ "summary": "Đọc JSON manifest và xác thực từng bản ghi có `image_id` cùng `image_path`.",
114
+ "tags": [
115
+ "validation",
116
+ "utility",
117
+ "retrieval"
118
+ ],
119
+ "complexity": "simple"
120
+ },
121
+ {
122
+ "id": "function:baseline_dinov3.py:resolve_image_path",
123
+ "type": "function",
124
+ "name": "resolve_image_path",
125
+ "filePath": "baseline_dinov3.py",
126
+ "lineRange": [
127
+ 54,
128
+ 65
129
+ ],
130
+ "summary": "Thử các gốc đường dẫn hợp lệ để ánh xạ đường dẫn ảnh trong manifest tới file thực.",
131
+ "tags": [
132
+ "path-resolution",
133
+ "utility",
134
+ "retrieval"
135
+ ],
136
+ "complexity": "moderate"
137
+ },
138
+ {
139
+ "id": "class:baseline_dinov3.py:RetrievalDataset",
140
+ "type": "class",
141
+ "name": "RetrievalDataset",
142
+ "filePath": "baseline_dinov3.py",
143
+ "lineRange": [
144
+ 68,
145
+ 91
146
+ ],
147
+ "summary": "Dataset PyTorch nạp ảnh RGB, áp dụng view transform tùy chọn rồi preprocessing cho backbone retrieval.",
148
+ "tags": [
149
+ "data-model",
150
+ "dataset",
151
+ "retrieval"
152
+ ],
153
+ "complexity": "moderate"
154
+ },
155
+ {
156
+ "id": "function:baseline_dinov3.py:extract_features",
157
+ "type": "function",
158
+ "name": "extract_features",
159
+ "filePath": "baseline_dinov3.py",
160
+ "lineRange": [
161
+ 133,
162
+ 150
163
+ ],
164
+ "summary": "Chạy inference theo batch, gom ID và trả embedding đã chuẩn hóa L2 sau global pooling khi cần.",
165
+ "tags": [
166
+ "feature-extraction",
167
+ "utility",
168
+ "retrieval"
169
+ ],
170
+ "complexity": "moderate"
171
+ },
172
+ {
173
+ "id": "function:baseline_dinov3.py:validate_submission",
174
+ "type": "function",
175
+ "name": "validate_submission",
176
+ "filePath": "baseline_dinov3.py",
177
+ "lineRange": [
178
+ 183,
179
+ 198
180
+ ],
181
+ "summary": "Kiểm tra tập query, số lượng và tính duy nhất của top-k gallery ID trong submission.",
182
+ "tags": [
183
+ "validation",
184
+ "utility",
185
+ "retrieval"
186
+ ],
187
+ "complexity": "moderate"
188
+ },
189
+ {
190
+ "id": "function:baseline_dinov3.py:extract_view",
191
+ "type": "function",
192
+ "name": "extract_view",
193
+ "filePath": "baseline_dinov3.py",
194
+ "lineRange": [
195
+ 252,
196
+ 255
197
+ ],
198
+ "summary": "Tạo dataset/loader cho một TTA view và chuyển tiếp sang bước trích xuất feature.",
199
+ "tags": [
200
+ "feature-extraction",
201
+ "utility",
202
+ "retrieval"
203
+ ],
204
+ "complexity": "simple"
205
+ },
206
+ {
207
+ "id": "function:baseline_dinov3.py:show_changed_top1",
208
+ "type": "function",
209
+ "name": "show_changed_top1",
210
+ "filePath": "baseline_dinov3.py",
211
+ "lineRange": [
212
+ 333,
213
+ 366
214
+ ],
215
+ "summary": "Trực quan hóa các query mà lựa chọn top-1 thay đổi giữa baseline và TTA, ưu tiên trường hợp score đổi mạnh.",
216
+ "tags": [
217
+ "visualization",
218
+ "utility",
219
+ "retrieval"
220
+ ],
221
+ "complexity": "complex"
222
+ },
223
+ {
224
+ "id": "function:baseline_dinov3.py:show_retrievals",
225
+ "type": "function",
226
+ "name": "show_retrievals",
227
+ "filePath": "baseline_dinov3.py",
228
+ "lineRange": [
229
+ 373,
230
+ 394
231
+ ],
232
+ "summary": "Vẽ query cùng các gallery candidate xếp hạng cao và score tương ứng để kiểm tra định tính.",
233
+ "tags": [
234
+ "visualization",
235
+ "utility",
236
+ "retrieval"
237
+ ],
238
+ "complexity": "moderate"
239
+ },
240
+ {
241
+ "id": "function:eda.py:parse_args",
242
+ "type": "function",
243
+ "name": "parse_args",
244
+ "filePath": "eda.py",
245
+ "lineRange": [
246
+ 43,
247
+ 49
248
+ ],
249
+ "summary": "Khai báo tham số CLI cho thư mục dữ liệu, thư mục output, seed và kích thước grid.",
250
+ "tags": [
251
+ "cli",
252
+ "utility",
253
+ "retrieval"
254
+ ],
255
+ "complexity": "simple"
256
+ },
257
+ {
258
+ "id": "function:eda.py:load_manifest",
259
+ "type": "function",
260
+ "name": "load_manifest",
261
+ "filePath": "eda.py",
262
+ "lineRange": [
263
+ 52,
264
+ 60
265
+ ],
266
+ "summary": "Đọc manifest JSON và xác thực mỗi hàng chứa chuỗi `image_id` cùng `image_path`.",
267
+ "tags": [
268
+ "validation",
269
+ "utility",
270
+ "retrieval"
271
+ ],
272
+ "complexity": "simple"
273
+ },
274
+ {
275
+ "id": "function:eda.py:resolve_image",
276
+ "type": "function",
277
+ "name": "resolve_image",
278
+ "filePath": "eda.py",
279
+ "lineRange": [
280
+ 63,
281
+ 73
282
+ ],
283
+ "summary": "Giải đường dẫn ảnh tương đối qua các vị trí khả dĩ quanh data root và manifest.",
284
+ "tags": [
285
+ "path-resolution",
286
+ "utility",
287
+ "retrieval"
288
+ ],
289
+ "complexity": "moderate"
290
+ },
291
+ {
292
+ "id": "function:eda.py:sha256",
293
+ "type": "function",
294
+ "name": "sha256",
295
+ "filePath": "eda.py",
296
+ "lineRange": [
297
+ 76,
298
+ 81
299
+ ],
300
+ "summary": "Tính SHA-256 theo chunk để nhận diện file ảnh trùng mà không nạp toàn bộ file vào RAM.",
301
+ "tags": [
302
+ "integrity-check",
303
+ "utility",
304
+ "retrieval"
305
+ ],
306
+ "complexity": "simple"
307
+ },
308
+ {
309
+ "id": "function:eda.py:image_metrics",
310
+ "type": "function",
311
+ "name": "image_metrics",
312
+ "filePath": "eda.py",
313
+ "lineRange": [
314
+ 84,
315
+ 104
316
+ ],
317
+ "summary": "Tính các chỉ số ảnh về độ sáng, màu, blur, entropy, high-frequency energy, vùng đen và mật độ cạnh.",
318
+ "tags": [
319
+ "image-analysis",
320
+ "utility",
321
+ "retrieval"
322
+ ],
323
+ "complexity": "moderate"
324
+ },
325
+ {
326
+ "id": "function:eda.py:inspect_dataset",
327
+ "type": "function",
328
+ "name": "inspect_dataset",
329
+ "filePath": "eda.py",
330
+ "lineRange": [
331
+ 107,
332
+ 168
333
+ ],
334
+ "summary": "Duyệt mọi split, xác thực ID/path/file ảnh, phát hiện bản sao SHA-256 và thu thập metric thành DataFrame.",
335
+ "tags": [
336
+ "data-validation",
337
+ "utility",
338
+ "retrieval"
339
+ ],
340
+ "complexity": "complex"
341
+ },
342
+ {
343
+ "id": "function:eda.py:create_summary",
344
+ "type": "function",
345
+ "name": "create_summary",
346
+ "filePath": "eda.py",
347
+ "lineRange": [
348
+ 171,
349
+ 176
350
+ ],
351
+ "summary": "Tổng hợp count và thống kê mô tả của các metric số theo từng split.",
352
+ "tags": [
353
+ "aggregation",
354
+ "utility",
355
+ "retrieval"
356
+ ],
357
+ "complexity": "simple"
358
+ },
359
+ {
360
+ "id": "function:eda.py:thumbnail",
361
+ "type": "function",
362
+ "name": "thumbnail",
363
+ "filePath": "eda.py",
364
+ "lineRange": [
365
+ 179,
366
+ 181
367
+ ],
368
+ "summary": "Tạo thumbnail RGB vuông bằng phép fit Lanczos từ một ảnh nguồn.",
369
+ "tags": [
370
+ "image-processing",
371
+ "utility",
372
+ "retrieval"
373
+ ],
374
+ "complexity": "simple"
375
+ },
376
+ {
377
+ "id": "function:eda.py:save_grid",
378
+ "type": "function",
379
+ "name": "save_grid",
380
+ "filePath": "eda.py",
381
+ "lineRange": [
382
+ 184,
383
+ 200
384
+ ],
385
+ "summary": "Ghép các thumbnail cùng nhãn ID/split thành một ảnh grid để kiểm tra trực quan.",
386
+ "tags": [
387
+ "visualization",
388
+ "utility",
389
+ "retrieval"
390
+ ],
391
+ "complexity": "moderate"
392
+ },
393
+ {
394
+ "id": "function:eda.py:save_grids",
395
+ "type": "function",
396
+ "name": "save_grids",
397
+ "filePath": "eda.py",
398
+ "lineRange": [
399
+ 203,
400
+ 218
401
+ ],
402
+ "summary": "Sinh grid mẫu ngẫu nhiên theo split và grid các trường hợp cực trị về blur, noise hay độ sáng.",
403
+ "tags": [
404
+ "visualization",
405
+ "utility",
406
+ "retrieval"
407
+ ],
408
+ "complexity": "moderate"
409
+ },
410
+ {
411
+ "id": "function:eda.py:save_distributions",
412
+ "type": "function",
413
+ "name": "save_distributions",
414
+ "filePath": "eda.py",
415
+ "lineRange": [
416
+ 221,
417
+ 237
418
+ ],
419
+ "summary": "Vẽ histogram mật độ của các metric suy giảm cho train, gallery và query.",
420
+ "tags": [
421
+ "visualization",
422
+ "utility",
423
+ "retrieval"
424
+ ],
425
+ "complexity": "moderate"
426
+ },
427
+ {
428
+ "id": "function:eda.py:write_integrity_report",
429
+ "type": "function",
430
+ "name": "write_integrity_report",
431
+ "filePath": "eda.py",
432
+ "lineRange": [
433
+ 240,
434
+ 262
435
+ ],
436
+ "summary": "Ghi báo cáo text về số dòng, trùng ID/path, file thiếu/hỏng và nhóm ảnh trùng hash.",
437
+ "tags": [
438
+ "reporting",
439
+ "utility",
440
+ "retrieval"
441
+ ],
442
+ "complexity": "moderate"
443
+ },
444
+ {
445
+ "id": "function:eda.py:write_markdown_report",
446
+ "type": "function",
447
+ "name": "write_markdown_report",
448
+ "filePath": "eda.py",
449
+ "lineRange": [
450
+ 265,
451
+ 303
452
+ ],
453
+ "summary": "Ghi báo cáo Markdown tóm tắt dataset, median metric, distribution shift và hàm ý retrieval.",
454
+ "tags": [
455
+ "reporting",
456
+ "utility",
457
+ "retrieval"
458
+ ],
459
+ "complexity": "complex"
460
+ },
461
+ {
462
+ "id": "function:eda.py:main",
463
+ "type": "function",
464
+ "name": "main",
465
+ "filePath": "eda.py",
466
+ "lineRange": [
467
+ 306,
468
+ 337
469
+ ],
470
+ "summary": "Điều phối CLI EDA, kiểm tra input, tạo artifact và trả exit code phản ánh lỗi dữ liệu.",
471
+ "tags": [
472
+ "entry-point",
473
+ "utility",
474
+ "retrieval"
475
+ ],
476
+ "complexity": "complex"
477
+ },
478
+ {
479
+ "id": "function:retrieval_advanced.py:load_manifest",
480
+ "type": "function",
481
+ "name": "load_manifest",
482
+ "filePath": "retrieval_advanced.py",
483
+ "lineRange": [
484
+ 50,
485
+ 58
486
+ ],
487
+ "summary": "Đọc và xác thực manifest ảnh dưới dạng danh sách các bản ghi ID/path.",
488
+ "tags": [
489
+ "validation",
490
+ "utility",
491
+ "retrieval"
492
+ ],
493
+ "complexity": "simple"
494
+ },
495
+ {
496
+ "id": "function:retrieval_advanced.py:resolve_image_path",
497
+ "type": "function",
498
+ "name": "resolve_image_path",
499
+ "filePath": "retrieval_advanced.py",
500
+ "lineRange": [
501
+ 61,
502
+ 67
503
+ ],
504
+ "summary": "Giải đường dẫn ảnh tương đối từ data root hoặc các thư mục cha của manifest.",
505
+ "tags": [
506
+ "path-resolution",
507
+ "utility",
508
+ "retrieval"
509
+ ],
510
+ "complexity": "simple"
511
+ },
512
+ {
513
+ "id": "function:retrieval_advanced.py:apply_d4",
514
+ "type": "function",
515
+ "name": "apply_d4",
516
+ "filePath": "retrieval_advanced.py",
517
+ "lineRange": [
518
+ 80,
519
+ 93
520
+ ],
521
+ "summary": "Áp dụng một trong tám phép biến đổi nhóm D4 gồm quay và lật ảnh.",
522
+ "tags": [
523
+ "augmentation",
524
+ "utility",
525
+ "retrieval"
526
+ ],
527
+ "complexity": "moderate"
528
+ },
529
+ {
530
+ "id": "class:retrieval_advanced.py:ImageDataset",
531
+ "type": "class",
532
+ "name": "ImageDataset",
533
+ "filePath": "retrieval_advanced.py",
534
+ "lineRange": [
535
+ 96,
536
+ 110
537
+ ],
538
+ "summary": "Dataset PyTorch nạp ảnh RGB, bảo toàn kích thước qua D4 view rồi áp dụng transform của model.",
539
+ "tags": [
540
+ "data-model",
541
+ "dataset",
542
+ "retrieval"
543
+ ],
544
+ "complexity": "moderate"
545
+ },
546
+ {
547
+ "id": "function:retrieval_advanced.py:cache_key",
548
+ "type": "function",
549
+ "name": "cache_key",
550
+ "filePath": "retrieval_advanced.py",
551
+ "lineRange": [
552
+ 114,
553
+ 118
554
+ ],
555
+ "summary": "Băm nội dung manifest cùng model, split, view và phiên bản dense feature để định danh cache.",
556
+ "tags": [
557
+ "feature-cache",
558
+ "utility",
559
+ "retrieval"
560
+ ],
561
+ "complexity": "simple"
562
+ },
563
+ {
564
+ "id": "function:retrieval_advanced.py:cache_path",
565
+ "type": "function",
566
+ "name": "cache_path",
567
+ "filePath": "retrieval_advanced.py",
568
+ "lineRange": [
569
+ 121,
570
+ 123
571
+ ],
572
+ "summary": "Tạo đường dẫn cache feature an toàn từ tên model và cache key.",
573
+ "tags": [
574
+ "feature-cache",
575
+ "utility",
576
+ "retrieval"
577
+ ],
578
+ "complexity": "simple"
579
+ },
580
+ {
581
+ "id": "function:retrieval_advanced.py:split_global_dense",
582
+ "type": "function",
583
+ "name": "split_global_dense",
584
+ "filePath": "retrieval_advanced.py",
585
+ "lineRange": [
586
+ 126,
587
+ 146
588
+ ],
589
+ "summary": "Chuyển output backbone thành global embedding và dense spatial descriptors chuẩn hóa, hỗ trợ ConvNeXt lẫn ViT/EVA.",
590
+ "tags": [
591
+ "feature-extraction",
592
+ "utility",
593
+ "retrieval"
594
+ ],
595
+ "complexity": "moderate"
596
+ },
597
+ {
598
+ "id": "function:retrieval_advanced.py:extract_and_cache",
599
+ "type": "function",
600
+ "name": "extract_and_cache",
601
+ "filePath": "retrieval_advanced.py",
602
+ "lineRange": [
603
+ 150,
604
+ 186
605
+ ],
606
+ "summary": "Tái sử dụng cache hợp lệ hoặc chạy batched inference để lưu global và dense feature theo D4 view.",
607
+ "tags": [
608
+ "feature-cache",
609
+ "utility",
610
+ "retrieval"
611
+ ],
612
+ "complexity": "complex"
613
+ },
614
+ {
615
+ "id": "function:retrieval_advanced.py:make_submission",
616
+ "type": "function",
617
+ "name": "make_submission",
618
+ "filePath": "retrieval_advanced.py",
619
+ "lineRange": [
620
+ 247,
621
+ 258
622
+ ],
623
+ "summary": "Chuyển ranking tensor thành CSV top-10, đồng thời xác thực query và gallery ID không trùng.",
624
+ "tags": [
625
+ "serialization",
626
+ "utility",
627
+ "retrieval"
628
+ ],
629
+ "complexity": "moderate"
630
+ },
631
+ {
632
+ "id": "function:retrieval_advanced.py:row_minmax",
633
+ "type": "function",
634
+ "name": "row_minmax",
635
+ "filePath": "retrieval_advanced.py",
636
+ "lineRange": [
637
+ 266,
638
+ 268
639
+ ],
640
+ "summary": "Chuẩn hóa từng hàng score về khoảng min-max với mẫu số được chặn để tránh chia cho zero.",
641
+ "tags": [
642
+ "normalization",
643
+ "utility",
644
+ "retrieval"
645
+ ],
646
+ "complexity": "simple"
647
+ },
648
+ {
649
+ "id": "function:retrieval_advanced.py:local_features",
650
+ "type": "function",
651
+ "name": "local_features",
652
+ "filePath": "retrieval_advanced.py",
653
+ "lineRange": [
654
+ 297,
655
+ 304
656
+ ],
657
+ "summary": "Phóng to ảnh xám, tăng tương phản CLAHE và trích xuất SIFT keypoint/descriptor.",
658
+ "tags": [
659
+ "feature-extraction",
660
+ "utility",
661
+ "retrieval"
662
+ ],
663
+ "complexity": "simple"
664
+ },
665
+ {
666
+ "id": "function:retrieval_advanced.py:geometric_score",
667
+ "type": "function",
668
+ "name": "geometric_score",
669
+ "filePath": "retrieval_advanced.py",
670
+ "lineRange": [
671
+ 307,
672
+ 322
673
+ ],
674
+ "summary": "Ghép SIFT bằng ratio test, ước lượng homography RANSAC và tạo score từ số lượng cùng tỷ lệ inlier.",
675
+ "tags": [
676
+ "geometric-verification",
677
+ "utility",
678
+ "retrieval"
679
+ ],
680
+ "complexity": "moderate"
681
+ },
682
+ {
683
+ "id": "function:retrieval_advanced.py:overlap",
684
+ "type": "function",
685
+ "name": "overlap",
686
+ "filePath": "retrieval_advanced.py",
687
+ "lineRange": [
688
+ 349,
689
+ 350
690
+ ],
691
+ "summary": "Tính overlap trung bình giữa hai tập top-k ranking cho mọi query.",
692
+ "tags": [
693
+ "evaluation",
694
+ "utility",
695
+ "retrieval"
696
+ ],
697
+ "complexity": "simple"
698
+ },
699
+ {
700
+ "id": "function:retrieval_advanced.py:show_top1_comparison",
701
+ "type": "function",
702
+ "name": "show_top1_comparison",
703
+ "filePath": "retrieval_advanced.py",
704
+ "lineRange": [
705
+ 379,
706
+ 396
707
+ ],
708
+ "summary": "Vẽ top-1 của global, dense và geometry cạnh query để so sánh định tính.",
709
+ "tags": [
710
+ "visualization",
711
+ "utility",
712
+ "retrieval"
713
+ ],
714
+ "complexity": "moderate"
715
+ }
716
+ ],
717
+ "edges": [
718
+ {
719
+ "source": "file:baseline_dinov3.py",
720
+ "target": "function:baseline_dinov3.py:load_manifest",
721
+ "type": "contains",
722
+ "direction": "forward",
723
+ "weight": 1
724
+ },
725
+ {
726
+ "source": "file:baseline_dinov3.py",
727
+ "target": "function:baseline_dinov3.py:load_manifest",
728
+ "type": "exports",
729
+ "direction": "forward",
730
+ "weight": 0.8
731
+ },
732
+ {
733
+ "source": "file:baseline_dinov3.py",
734
+ "target": "function:baseline_dinov3.py:resolve_image_path",
735
+ "type": "contains",
736
+ "direction": "forward",
737
+ "weight": 1
738
+ },
739
+ {
740
+ "source": "file:baseline_dinov3.py",
741
+ "target": "function:baseline_dinov3.py:resolve_image_path",
742
+ "type": "exports",
743
+ "direction": "forward",
744
+ "weight": 0.8
745
+ },
746
+ {
747
+ "source": "file:baseline_dinov3.py",
748
+ "target": "class:baseline_dinov3.py:RetrievalDataset",
749
+ "type": "contains",
750
+ "direction": "forward",
751
+ "weight": 1
752
+ },
753
+ {
754
+ "source": "file:baseline_dinov3.py",
755
+ "target": "class:baseline_dinov3.py:RetrievalDataset",
756
+ "type": "exports",
757
+ "direction": "forward",
758
+ "weight": 0.8
759
+ },
760
+ {
761
+ "source": "file:baseline_dinov3.py",
762
+ "target": "function:baseline_dinov3.py:extract_features",
763
+ "type": "contains",
764
+ "direction": "forward",
765
+ "weight": 1
766
+ },
767
+ {
768
+ "source": "file:baseline_dinov3.py",
769
+ "target": "function:baseline_dinov3.py:extract_features",
770
+ "type": "exports",
771
+ "direction": "forward",
772
+ "weight": 0.8
773
+ },
774
+ {
775
+ "source": "file:baseline_dinov3.py",
776
+ "target": "function:baseline_dinov3.py:validate_submission",
777
+ "type": "contains",
778
+ "direction": "forward",
779
+ "weight": 1
780
+ },
781
+ {
782
+ "source": "file:baseline_dinov3.py",
783
+ "target": "function:baseline_dinov3.py:validate_submission",
784
+ "type": "exports",
785
+ "direction": "forward",
786
+ "weight": 0.8
787
+ },
788
+ {
789
+ "source": "file:baseline_dinov3.py",
790
+ "target": "function:baseline_dinov3.py:extract_view",
791
+ "type": "contains",
792
+ "direction": "forward",
793
+ "weight": 1
794
+ },
795
+ {
796
+ "source": "file:baseline_dinov3.py",
797
+ "target": "function:baseline_dinov3.py:extract_view",
798
+ "type": "exports",
799
+ "direction": "forward",
800
+ "weight": 0.8
801
+ },
802
+ {
803
+ "source": "file:baseline_dinov3.py",
804
+ "target": "function:baseline_dinov3.py:show_changed_top1",
805
+ "type": "contains",
806
+ "direction": "forward",
807
+ "weight": 1
808
+ },
809
+ {
810
+ "source": "file:baseline_dinov3.py",
811
+ "target": "function:baseline_dinov3.py:show_changed_top1",
812
+ "type": "exports",
813
+ "direction": "forward",
814
+ "weight": 0.8
815
+ },
816
+ {
817
+ "source": "file:baseline_dinov3.py",
818
+ "target": "function:baseline_dinov3.py:show_retrievals",
819
+ "type": "contains",
820
+ "direction": "forward",
821
+ "weight": 1
822
+ },
823
+ {
824
+ "source": "file:baseline_dinov3.py",
825
+ "target": "function:baseline_dinov3.py:show_retrievals",
826
+ "type": "exports",
827
+ "direction": "forward",
828
+ "weight": 0.8
829
+ },
830
+ {
831
+ "source": "file:eda.py",
832
+ "target": "function:eda.py:parse_args",
833
+ "type": "contains",
834
+ "direction": "forward",
835
+ "weight": 1
836
+ },
837
+ {
838
+ "source": "file:eda.py",
839
+ "target": "function:eda.py:parse_args",
840
+ "type": "exports",
841
+ "direction": "forward",
842
+ "weight": 0.8
843
+ },
844
+ {
845
+ "source": "file:eda.py",
846
+ "target": "function:eda.py:load_manifest",
847
+ "type": "contains",
848
+ "direction": "forward",
849
+ "weight": 1
850
+ },
851
+ {
852
+ "source": "file:eda.py",
853
+ "target": "function:eda.py:load_manifest",
854
+ "type": "exports",
855
+ "direction": "forward",
856
+ "weight": 0.8
857
+ },
858
+ {
859
+ "source": "file:eda.py",
860
+ "target": "function:eda.py:resolve_image",
861
+ "type": "contains",
862
+ "direction": "forward",
863
+ "weight": 1
864
+ },
865
+ {
866
+ "source": "file:eda.py",
867
+ "target": "function:eda.py:resolve_image",
868
+ "type": "exports",
869
+ "direction": "forward",
870
+ "weight": 0.8
871
+ },
872
+ {
873
+ "source": "file:eda.py",
874
+ "target": "function:eda.py:sha256",
875
+ "type": "contains",
876
+ "direction": "forward",
877
+ "weight": 1
878
+ },
879
+ {
880
+ "source": "file:eda.py",
881
+ "target": "function:eda.py:sha256",
882
+ "type": "exports",
883
+ "direction": "forward",
884
+ "weight": 0.8
885
+ },
886
+ {
887
+ "source": "file:eda.py",
888
+ "target": "function:eda.py:image_metrics",
889
+ "type": "contains",
890
+ "direction": "forward",
891
+ "weight": 1
892
+ },
893
+ {
894
+ "source": "file:eda.py",
895
+ "target": "function:eda.py:image_metrics",
896
+ "type": "exports",
897
+ "direction": "forward",
898
+ "weight": 0.8
899
+ },
900
+ {
901
+ "source": "file:eda.py",
902
+ "target": "function:eda.py:inspect_dataset",
903
+ "type": "contains",
904
+ "direction": "forward",
905
+ "weight": 1
906
+ },
907
+ {
908
+ "source": "file:eda.py",
909
+ "target": "function:eda.py:inspect_dataset",
910
+ "type": "exports",
911
+ "direction": "forward",
912
+ "weight": 0.8
913
+ },
914
+ {
915
+ "source": "file:eda.py",
916
+ "target": "function:eda.py:create_summary",
917
+ "type": "contains",
918
+ "direction": "forward",
919
+ "weight": 1
920
+ },
921
+ {
922
+ "source": "file:eda.py",
923
+ "target": "function:eda.py:create_summary",
924
+ "type": "exports",
925
+ "direction": "forward",
926
+ "weight": 0.8
927
+ },
928
+ {
929
+ "source": "file:eda.py",
930
+ "target": "function:eda.py:thumbnail",
931
+ "type": "contains",
932
+ "direction": "forward",
933
+ "weight": 1
934
+ },
935
+ {
936
+ "source": "file:eda.py",
937
+ "target": "function:eda.py:thumbnail",
938
+ "type": "exports",
939
+ "direction": "forward",
940
+ "weight": 0.8
941
+ },
942
+ {
943
+ "source": "file:eda.py",
944
+ "target": "function:eda.py:save_grid",
945
+ "type": "contains",
946
+ "direction": "forward",
947
+ "weight": 1
948
+ },
949
+ {
950
+ "source": "file:eda.py",
951
+ "target": "function:eda.py:save_grid",
952
+ "type": "exports",
953
+ "direction": "forward",
954
+ "weight": 0.8
955
+ },
956
+ {
957
+ "source": "file:eda.py",
958
+ "target": "function:eda.py:save_grids",
959
+ "type": "contains",
960
+ "direction": "forward",
961
+ "weight": 1
962
+ },
963
+ {
964
+ "source": "file:eda.py",
965
+ "target": "function:eda.py:save_grids",
966
+ "type": "exports",
967
+ "direction": "forward",
968
+ "weight": 0.8
969
+ },
970
+ {
971
+ "source": "file:eda.py",
972
+ "target": "function:eda.py:save_distributions",
973
+ "type": "contains",
974
+ "direction": "forward",
975
+ "weight": 1
976
+ },
977
+ {
978
+ "source": "file:eda.py",
979
+ "target": "function:eda.py:save_distributions",
980
+ "type": "exports",
981
+ "direction": "forward",
982
+ "weight": 0.8
983
+ },
984
+ {
985
+ "source": "file:eda.py",
986
+ "target": "function:eda.py:write_integrity_report",
987
+ "type": "contains",
988
+ "direction": "forward",
989
+ "weight": 1
990
+ },
991
+ {
992
+ "source": "file:eda.py",
993
+ "target": "function:eda.py:write_integrity_report",
994
+ "type": "exports",
995
+ "direction": "forward",
996
+ "weight": 0.8
997
+ },
998
+ {
999
+ "source": "file:eda.py",
1000
+ "target": "function:eda.py:write_markdown_report",
1001
+ "type": "contains",
1002
+ "direction": "forward",
1003
+ "weight": 1
1004
+ },
1005
+ {
1006
+ "source": "file:eda.py",
1007
+ "target": "function:eda.py:write_markdown_report",
1008
+ "type": "exports",
1009
+ "direction": "forward",
1010
+ "weight": 0.8
1011
+ },
1012
+ {
1013
+ "source": "file:eda.py",
1014
+ "target": "function:eda.py:main",
1015
+ "type": "contains",
1016
+ "direction": "forward",
1017
+ "weight": 1
1018
+ },
1019
+ {
1020
+ "source": "file:eda.py",
1021
+ "target": "function:eda.py:main",
1022
+ "type": "exports",
1023
+ "direction": "forward",
1024
+ "weight": 0.8
1025
+ },
1026
+ {
1027
+ "source": "file:retrieval_advanced.py",
1028
+ "target": "function:retrieval_advanced.py:load_manifest",
1029
+ "type": "contains",
1030
+ "direction": "forward",
1031
+ "weight": 1
1032
+ },
1033
+ {
1034
+ "source": "file:retrieval_advanced.py",
1035
+ "target": "function:retrieval_advanced.py:load_manifest",
1036
+ "type": "exports",
1037
+ "direction": "forward",
1038
+ "weight": 0.8
1039
+ },
1040
+ {
1041
+ "source": "file:retrieval_advanced.py",
1042
+ "target": "function:retrieval_advanced.py:resolve_image_path",
1043
+ "type": "contains",
1044
+ "direction": "forward",
1045
+ "weight": 1
1046
+ },
1047
+ {
1048
+ "source": "file:retrieval_advanced.py",
1049
+ "target": "function:retrieval_advanced.py:resolve_image_path",
1050
+ "type": "exports",
1051
+ "direction": "forward",
1052
+ "weight": 0.8
1053
+ },
1054
+ {
1055
+ "source": "file:retrieval_advanced.py",
1056
+ "target": "function:retrieval_advanced.py:apply_d4",
1057
+ "type": "contains",
1058
+ "direction": "forward",
1059
+ "weight": 1
1060
+ },
1061
+ {
1062
+ "source": "file:retrieval_advanced.py",
1063
+ "target": "function:retrieval_advanced.py:apply_d4",
1064
+ "type": "exports",
1065
+ "direction": "forward",
1066
+ "weight": 0.8
1067
+ },
1068
+ {
1069
+ "source": "file:retrieval_advanced.py",
1070
+ "target": "class:retrieval_advanced.py:ImageDataset",
1071
+ "type": "contains",
1072
+ "direction": "forward",
1073
+ "weight": 1
1074
+ },
1075
+ {
1076
+ "source": "file:retrieval_advanced.py",
1077
+ "target": "class:retrieval_advanced.py:ImageDataset",
1078
+ "type": "exports",
1079
+ "direction": "forward",
1080
+ "weight": 0.8
1081
+ },
1082
+ {
1083
+ "source": "file:retrieval_advanced.py",
1084
+ "target": "function:retrieval_advanced.py:cache_key",
1085
+ "type": "contains",
1086
+ "direction": "forward",
1087
+ "weight": 1
1088
+ },
1089
+ {
1090
+ "source": "file:retrieval_advanced.py",
1091
+ "target": "function:retrieval_advanced.py:cache_key",
1092
+ "type": "exports",
1093
+ "direction": "forward",
1094
+ "weight": 0.8
1095
+ },
1096
+ {
1097
+ "source": "file:retrieval_advanced.py",
1098
+ "target": "function:retrieval_advanced.py:cache_path",
1099
+ "type": "contains",
1100
+ "direction": "forward",
1101
+ "weight": 1
1102
+ },
1103
+ {
1104
+ "source": "file:retrieval_advanced.py",
1105
+ "target": "function:retrieval_advanced.py:cache_path",
1106
+ "type": "exports",
1107
+ "direction": "forward",
1108
+ "weight": 0.8
1109
+ },
1110
+ {
1111
+ "source": "file:retrieval_advanced.py",
1112
+ "target": "function:retrieval_advanced.py:split_global_dense",
1113
+ "type": "contains",
1114
+ "direction": "forward",
1115
+ "weight": 1
1116
+ },
1117
+ {
1118
+ "source": "file:retrieval_advanced.py",
1119
+ "target": "function:retrieval_advanced.py:split_global_dense",
1120
+ "type": "exports",
1121
+ "direction": "forward",
1122
+ "weight": 0.8
1123
+ },
1124
+ {
1125
+ "source": "file:retrieval_advanced.py",
1126
+ "target": "function:retrieval_advanced.py:extract_and_cache",
1127
+ "type": "contains",
1128
+ "direction": "forward",
1129
+ "weight": 1
1130
+ },
1131
+ {
1132
+ "source": "file:retrieval_advanced.py",
1133
+ "target": "function:retrieval_advanced.py:extract_and_cache",
1134
+ "type": "exports",
1135
+ "direction": "forward",
1136
+ "weight": 0.8
1137
+ },
1138
+ {
1139
+ "source": "file:retrieval_advanced.py",
1140
+ "target": "function:retrieval_advanced.py:make_submission",
1141
+ "type": "contains",
1142
+ "direction": "forward",
1143
+ "weight": 1
1144
+ },
1145
+ {
1146
+ "source": "file:retrieval_advanced.py",
1147
+ "target": "function:retrieval_advanced.py:make_submission",
1148
+ "type": "exports",
1149
+ "direction": "forward",
1150
+ "weight": 0.8
1151
+ },
1152
+ {
1153
+ "source": "file:retrieval_advanced.py",
1154
+ "target": "function:retrieval_advanced.py:row_minmax",
1155
+ "type": "contains",
1156
+ "direction": "forward",
1157
+ "weight": 1
1158
+ },
1159
+ {
1160
+ "source": "file:retrieval_advanced.py",
1161
+ "target": "function:retrieval_advanced.py:row_minmax",
1162
+ "type": "exports",
1163
+ "direction": "forward",
1164
+ "weight": 0.8
1165
+ },
1166
+ {
1167
+ "source": "file:retrieval_advanced.py",
1168
+ "target": "function:retrieval_advanced.py:local_features",
1169
+ "type": "contains",
1170
+ "direction": "forward",
1171
+ "weight": 1
1172
+ },
1173
+ {
1174
+ "source": "file:retrieval_advanced.py",
1175
+ "target": "function:retrieval_advanced.py:local_features",
1176
+ "type": "exports",
1177
+ "direction": "forward",
1178
+ "weight": 0.8
1179
+ },
1180
+ {
1181
+ "source": "file:retrieval_advanced.py",
1182
+ "target": "function:retrieval_advanced.py:geometric_score",
1183
+ "type": "contains",
1184
+ "direction": "forward",
1185
+ "weight": 1
1186
+ },
1187
+ {
1188
+ "source": "file:retrieval_advanced.py",
1189
+ "target": "function:retrieval_advanced.py:geometric_score",
1190
+ "type": "exports",
1191
+ "direction": "forward",
1192
+ "weight": 0.8
1193
+ },
1194
+ {
1195
+ "source": "file:retrieval_advanced.py",
1196
+ "target": "function:retrieval_advanced.py:overlap",
1197
+ "type": "contains",
1198
+ "direction": "forward",
1199
+ "weight": 1
1200
+ },
1201
+ {
1202
+ "source": "file:retrieval_advanced.py",
1203
+ "target": "function:retrieval_advanced.py:overlap",
1204
+ "type": "exports",
1205
+ "direction": "forward",
1206
+ "weight": 0.8
1207
+ },
1208
+ {
1209
+ "source": "file:retrieval_advanced.py",
1210
+ "target": "function:retrieval_advanced.py:show_top1_comparison",
1211
+ "type": "contains",
1212
+ "direction": "forward",
1213
+ "weight": 1
1214
+ },
1215
+ {
1216
+ "source": "file:retrieval_advanced.py",
1217
+ "target": "function:retrieval_advanced.py:show_top1_comparison",
1218
+ "type": "exports",
1219
+ "direction": "forward",
1220
+ "weight": 0.8
1221
+ }
1222
+ ]
1223
+ }
.understand-anything/intermediate/batch-1.json ADDED
@@ -0,0 +1,1224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nodes": [
3
+ {
4
+ "id": "file:.understand-anything/.understandignore",
5
+ "type": "file",
6
+ "name": ".understandignore",
7
+ "filePath": ".understand-anything/.understandignore",
8
+ "summary": "Danh sách quy tắc loại trừ dùng khi quét project để knowledge graph bỏ qua dữ liệu, artifact sinh ra, cache và các file không cần phân tích.",
9
+ "tags": [
10
+ "configuration",
11
+ "ignore-rules",
12
+ "knowledge-graph"
13
+ ],
14
+ "complexity": "simple"
15
+ },
16
+ {
17
+ "id": "config:.understand-anything/config.json",
18
+ "type": "config",
19
+ "name": "config.json",
20
+ "filePath": ".understand-anything/config.json",
21
+ "summary": "Cấu hình Understand Anything chọn tiếng Việt làm ngôn ngữ đầu ra cho nội dung knowledge graph.",
22
+ "tags": [
23
+ "configuration",
24
+ "localization",
25
+ "knowledge-graph"
26
+ ],
27
+ "complexity": "simple"
28
+ },
29
+ {
30
+ "id": "file:baseline_dinov3.py",
31
+ "type": "file",
32
+ "name": "baseline_dinov3.py",
33
+ "filePath": "baseline_dinov3.py",
34
+ "summary": "Pipeline baseline dạng notebook-script dùng DINOv3/ConvNeXt để trích xuất embedding, tìm kiếm cosine, thử TTA và tạo submission cho image-to-image retrieval không nhãn. File còn cung cấp kiểm tra định dạng submission và trực quan hóa kết quả.",
35
+ "tags": [
36
+ "retrieval",
37
+ "feature-extraction",
38
+ "dinov3",
39
+ "entry-point"
40
+ ],
41
+ "complexity": "complex",
42
+ "languageNotes": "Python cell markers `# %%` cho phép chạy tuần tự như notebook; inference dùng PyTorch autocast và embedding chuẩn hóa L2."
43
+ },
44
+ {
45
+ "id": "document:de_bai_image_to_image_retrieval.md",
46
+ "type": "document",
47
+ "name": "de_bai_image_to_image_retrieval.md",
48
+ "filePath": "de_bai_image_to_image_retrieval.md",
49
+ "summary": "Đặc tả bài thi Olympic AI về instance retrieval không nhãn, gồm dữ liệu train/public/private test, định dạng top-10 submission, chỉ số mAP@10 và các ràng buộc chống suy diễn nhãn.",
50
+ "tags": [
51
+ "documentation",
52
+ "problem-specification",
53
+ "retrieval",
54
+ "evaluation"
55
+ ],
56
+ "complexity": "moderate"
57
+ },
58
+ {
59
+ "id": "file:eda.py",
60
+ "type": "file",
61
+ "name": "eda.py",
62
+ "filePath": "eda.py",
63
+ "summary": "CLI EDA tái lập được cho dataset retrieval không nhãn: kiểm tra manifest và tính toàn vẹn ảnh, đo thống kê suy giảm/chuyển dịch phân phối, rồi xuất CSV, báo cáo Markdown và các grid/histogram.",
64
+ "tags": [
65
+ "entry-point",
66
+ "eda",
67
+ "data-validation",
68
+ "visualization"
69
+ ],
70
+ "complexity": "complex",
71
+ "languageNotes": "Tách backend Matplotlib `Agg` để chạy headless và dùng SHA-256 phát hiện ảnh trùng chính xác giữa các split."
72
+ },
73
+ {
74
+ "id": "file:notebook324f4a11f8_upgraded.ipynb",
75
+ "type": "file",
76
+ "name": "notebook324f4a11f8_upgraded.ipynb",
77
+ "filePath": "notebook324f4a11f8_upgraded.ipynb",
78
+ "summary": "Notebook thử nghiệm nâng cấp pipeline image retrieval, lưu cả code cell, metadata và output thực thi để nghiên cứu các biến thể feature extraction, ranking và chẩn đoán.",
79
+ "tags": [
80
+ "notebook",
81
+ "retrieval",
82
+ "experimentation",
83
+ "data-science"
84
+ ],
85
+ "complexity": "complex",
86
+ "languageNotes": "Định dạng Jupyter Notebook JSON gói code, kết quả và metadata trong một artifact lớn."
87
+ },
88
+ {
89
+ "id": "file:retrieval_advanced.py",
90
+ "type": "file",
91
+ "name": "retrieval_advanced.py",
92
+ "filePath": "retrieval_advanced.py",
93
+ "summary": "Pipeline retrieval nâng cao kết hợp max-over-D4 global similarity, dense symmetric-Chamfer reranking và SIFT/RANSAC geometric reranking. Feature được cache theo model, manifest và view; pipeline xuất submission cùng diagnostics không cần nhãn.",
94
+ "tags": [
95
+ "retrieval",
96
+ "reranking",
97
+ "feature-cache",
98
+ "dinov3",
99
+ "entry-point"
100
+ ],
101
+ "complexity": "complex",
102
+ "languageNotes": "Script dùng `# %%` như notebook, hỗ trợ cả tensor feature map của ConvNeXt và patch-token sequence của ViT/EVA."
103
+ },
104
+ {
105
+ "id": "function:baseline_dinov3.py:load_manifest",
106
+ "type": "function",
107
+ "name": "load_manifest",
108
+ "filePath": "baseline_dinov3.py",
109
+ "lineRange": [
110
+ 43,
111
+ 51
112
+ ],
113
+ "summary": "Đọc JSON manifest và xác thực từng bản ghi có `image_id` cùng `image_path`.",
114
+ "tags": [
115
+ "validation",
116
+ "utility",
117
+ "retrieval"
118
+ ],
119
+ "complexity": "simple"
120
+ },
121
+ {
122
+ "id": "function:baseline_dinov3.py:resolve_image_path",
123
+ "type": "function",
124
+ "name": "resolve_image_path",
125
+ "filePath": "baseline_dinov3.py",
126
+ "lineRange": [
127
+ 54,
128
+ 65
129
+ ],
130
+ "summary": "Thử các gốc đường dẫn hợp lệ để ánh xạ đường dẫn ảnh trong manifest tới file thực.",
131
+ "tags": [
132
+ "path-resolution",
133
+ "utility",
134
+ "retrieval"
135
+ ],
136
+ "complexity": "moderate"
137
+ },
138
+ {
139
+ "id": "class:baseline_dinov3.py:RetrievalDataset",
140
+ "type": "class",
141
+ "name": "RetrievalDataset",
142
+ "filePath": "baseline_dinov3.py",
143
+ "lineRange": [
144
+ 68,
145
+ 91
146
+ ],
147
+ "summary": "Dataset PyTorch nạp ảnh RGB, áp dụng view transform tùy chọn rồi preprocessing cho backbone retrieval.",
148
+ "tags": [
149
+ "data-model",
150
+ "dataset",
151
+ "retrieval"
152
+ ],
153
+ "complexity": "moderate"
154
+ },
155
+ {
156
+ "id": "function:baseline_dinov3.py:extract_features",
157
+ "type": "function",
158
+ "name": "extract_features",
159
+ "filePath": "baseline_dinov3.py",
160
+ "lineRange": [
161
+ 133,
162
+ 150
163
+ ],
164
+ "summary": "Chạy inference theo batch, gom ID và trả embedding đã chuẩn hóa L2 sau global pooling khi cần.",
165
+ "tags": [
166
+ "feature-extraction",
167
+ "utility",
168
+ "retrieval"
169
+ ],
170
+ "complexity": "moderate"
171
+ },
172
+ {
173
+ "id": "function:baseline_dinov3.py:validate_submission",
174
+ "type": "function",
175
+ "name": "validate_submission",
176
+ "filePath": "baseline_dinov3.py",
177
+ "lineRange": [
178
+ 183,
179
+ 198
180
+ ],
181
+ "summary": "Kiểm tra tập query, số lượng và tính duy nhất của top-k gallery ID trong submission.",
182
+ "tags": [
183
+ "validation",
184
+ "utility",
185
+ "retrieval"
186
+ ],
187
+ "complexity": "moderate"
188
+ },
189
+ {
190
+ "id": "function:baseline_dinov3.py:extract_view",
191
+ "type": "function",
192
+ "name": "extract_view",
193
+ "filePath": "baseline_dinov3.py",
194
+ "lineRange": [
195
+ 252,
196
+ 255
197
+ ],
198
+ "summary": "Tạo dataset/loader cho một TTA view và chuyển tiếp sang bước trích xuất feature.",
199
+ "tags": [
200
+ "feature-extraction",
201
+ "utility",
202
+ "retrieval"
203
+ ],
204
+ "complexity": "simple"
205
+ },
206
+ {
207
+ "id": "function:baseline_dinov3.py:show_changed_top1",
208
+ "type": "function",
209
+ "name": "show_changed_top1",
210
+ "filePath": "baseline_dinov3.py",
211
+ "lineRange": [
212
+ 333,
213
+ 366
214
+ ],
215
+ "summary": "Trực quan hóa các query mà lựa chọn top-1 thay đổi giữa baseline và TTA, ưu tiên trường hợp score đổi mạnh.",
216
+ "tags": [
217
+ "visualization",
218
+ "utility",
219
+ "retrieval"
220
+ ],
221
+ "complexity": "complex"
222
+ },
223
+ {
224
+ "id": "function:baseline_dinov3.py:show_retrievals",
225
+ "type": "function",
226
+ "name": "show_retrievals",
227
+ "filePath": "baseline_dinov3.py",
228
+ "lineRange": [
229
+ 373,
230
+ 394
231
+ ],
232
+ "summary": "Vẽ query cùng các gallery candidate xếp hạng cao và score tương ứng để kiểm tra định tính.",
233
+ "tags": [
234
+ "visualization",
235
+ "utility",
236
+ "retrieval"
237
+ ],
238
+ "complexity": "moderate"
239
+ },
240
+ {
241
+ "id": "function:eda.py:parse_args",
242
+ "type": "function",
243
+ "name": "parse_args",
244
+ "filePath": "eda.py",
245
+ "lineRange": [
246
+ 43,
247
+ 49
248
+ ],
249
+ "summary": "Khai báo tham số CLI cho thư mục dữ liệu, thư mục output, seed và kích thước grid.",
250
+ "tags": [
251
+ "cli",
252
+ "utility",
253
+ "retrieval"
254
+ ],
255
+ "complexity": "simple"
256
+ },
257
+ {
258
+ "id": "function:eda.py:load_manifest",
259
+ "type": "function",
260
+ "name": "load_manifest",
261
+ "filePath": "eda.py",
262
+ "lineRange": [
263
+ 52,
264
+ 60
265
+ ],
266
+ "summary": "Đọc manifest JSON và xác thực mỗi hàng chứa chuỗi `image_id` cùng `image_path`.",
267
+ "tags": [
268
+ "validation",
269
+ "utility",
270
+ "retrieval"
271
+ ],
272
+ "complexity": "simple"
273
+ },
274
+ {
275
+ "id": "function:eda.py:resolve_image",
276
+ "type": "function",
277
+ "name": "resolve_image",
278
+ "filePath": "eda.py",
279
+ "lineRange": [
280
+ 63,
281
+ 73
282
+ ],
283
+ "summary": "Giải đường dẫn ảnh tương đối qua các vị trí khả dĩ quanh data root và manifest.",
284
+ "tags": [
285
+ "path-resolution",
286
+ "utility",
287
+ "retrieval"
288
+ ],
289
+ "complexity": "moderate"
290
+ },
291
+ {
292
+ "id": "function:eda.py:sha256",
293
+ "type": "function",
294
+ "name": "sha256",
295
+ "filePath": "eda.py",
296
+ "lineRange": [
297
+ 76,
298
+ 81
299
+ ],
300
+ "summary": "Tính SHA-256 theo chunk để nhận diện file ảnh trùng mà không nạp toàn bộ file vào RAM.",
301
+ "tags": [
302
+ "integrity-check",
303
+ "utility",
304
+ "retrieval"
305
+ ],
306
+ "complexity": "simple"
307
+ },
308
+ {
309
+ "id": "function:eda.py:image_metrics",
310
+ "type": "function",
311
+ "name": "image_metrics",
312
+ "filePath": "eda.py",
313
+ "lineRange": [
314
+ 84,
315
+ 104
316
+ ],
317
+ "summary": "Tính các chỉ số ảnh về độ sáng, màu, blur, entropy, high-frequency energy, vùng đen và mật độ cạnh.",
318
+ "tags": [
319
+ "image-analysis",
320
+ "utility",
321
+ "retrieval"
322
+ ],
323
+ "complexity": "moderate"
324
+ },
325
+ {
326
+ "id": "function:eda.py:inspect_dataset",
327
+ "type": "function",
328
+ "name": "inspect_dataset",
329
+ "filePath": "eda.py",
330
+ "lineRange": [
331
+ 107,
332
+ 168
333
+ ],
334
+ "summary": "Duyệt mọi split, xác thực ID/path/file ảnh, phát hiện bản sao SHA-256 và thu thập metric thành DataFrame.",
335
+ "tags": [
336
+ "data-validation",
337
+ "utility",
338
+ "retrieval"
339
+ ],
340
+ "complexity": "complex"
341
+ },
342
+ {
343
+ "id": "function:eda.py:create_summary",
344
+ "type": "function",
345
+ "name": "create_summary",
346
+ "filePath": "eda.py",
347
+ "lineRange": [
348
+ 171,
349
+ 176
350
+ ],
351
+ "summary": "Tổng hợp count và thống kê mô tả của các metric số theo từng split.",
352
+ "tags": [
353
+ "aggregation",
354
+ "utility",
355
+ "retrieval"
356
+ ],
357
+ "complexity": "simple"
358
+ },
359
+ {
360
+ "id": "function:eda.py:thumbnail",
361
+ "type": "function",
362
+ "name": "thumbnail",
363
+ "filePath": "eda.py",
364
+ "lineRange": [
365
+ 179,
366
+ 181
367
+ ],
368
+ "summary": "Tạo thumbnail RGB vuông bằng phép fit Lanczos từ một ảnh nguồn.",
369
+ "tags": [
370
+ "image-processing",
371
+ "utility",
372
+ "retrieval"
373
+ ],
374
+ "complexity": "simple"
375
+ },
376
+ {
377
+ "id": "function:eda.py:save_grid",
378
+ "type": "function",
379
+ "name": "save_grid",
380
+ "filePath": "eda.py",
381
+ "lineRange": [
382
+ 184,
383
+ 200
384
+ ],
385
+ "summary": "Ghép các thumbnail cùng nhãn ID/split thành một ảnh grid để kiểm tra trực quan.",
386
+ "tags": [
387
+ "visualization",
388
+ "utility",
389
+ "retrieval"
390
+ ],
391
+ "complexity": "moderate"
392
+ },
393
+ {
394
+ "id": "function:eda.py:save_grids",
395
+ "type": "function",
396
+ "name": "save_grids",
397
+ "filePath": "eda.py",
398
+ "lineRange": [
399
+ 203,
400
+ 218
401
+ ],
402
+ "summary": "Sinh grid mẫu ngẫu nhiên theo split và grid các trường hợp cực trị về blur, noise hay độ sáng.",
403
+ "tags": [
404
+ "visualization",
405
+ "utility",
406
+ "retrieval"
407
+ ],
408
+ "complexity": "moderate"
409
+ },
410
+ {
411
+ "id": "function:eda.py:save_distributions",
412
+ "type": "function",
413
+ "name": "save_distributions",
414
+ "filePath": "eda.py",
415
+ "lineRange": [
416
+ 221,
417
+ 237
418
+ ],
419
+ "summary": "Vẽ histogram mật độ của các metric suy giảm cho train, gallery và query.",
420
+ "tags": [
421
+ "visualization",
422
+ "utility",
423
+ "retrieval"
424
+ ],
425
+ "complexity": "moderate"
426
+ },
427
+ {
428
+ "id": "function:eda.py:write_integrity_report",
429
+ "type": "function",
430
+ "name": "write_integrity_report",
431
+ "filePath": "eda.py",
432
+ "lineRange": [
433
+ 240,
434
+ 262
435
+ ],
436
+ "summary": "Ghi báo cáo text về số dòng, trùng ID/path, file thiếu/hỏng và nhóm ảnh trùng hash.",
437
+ "tags": [
438
+ "reporting",
439
+ "utility",
440
+ "retrieval"
441
+ ],
442
+ "complexity": "moderate"
443
+ },
444
+ {
445
+ "id": "function:eda.py:write_markdown_report",
446
+ "type": "function",
447
+ "name": "write_markdown_report",
448
+ "filePath": "eda.py",
449
+ "lineRange": [
450
+ 265,
451
+ 303
452
+ ],
453
+ "summary": "Ghi báo cáo Markdown tóm tắt dataset, median metric, distribution shift và hàm ý retrieval.",
454
+ "tags": [
455
+ "reporting",
456
+ "utility",
457
+ "retrieval"
458
+ ],
459
+ "complexity": "complex"
460
+ },
461
+ {
462
+ "id": "function:eda.py:main",
463
+ "type": "function",
464
+ "name": "main",
465
+ "filePath": "eda.py",
466
+ "lineRange": [
467
+ 306,
468
+ 337
469
+ ],
470
+ "summary": "Điều phối CLI EDA, kiểm tra input, tạo artifact và trả exit code phản ánh lỗi dữ liệu.",
471
+ "tags": [
472
+ "entry-point",
473
+ "utility",
474
+ "retrieval"
475
+ ],
476
+ "complexity": "complex"
477
+ },
478
+ {
479
+ "id": "function:retrieval_advanced.py:load_manifest",
480
+ "type": "function",
481
+ "name": "load_manifest",
482
+ "filePath": "retrieval_advanced.py",
483
+ "lineRange": [
484
+ 50,
485
+ 58
486
+ ],
487
+ "summary": "Đọc và xác thực manifest ảnh dưới dạng danh sách các bản ghi ID/path.",
488
+ "tags": [
489
+ "validation",
490
+ "utility",
491
+ "retrieval"
492
+ ],
493
+ "complexity": "simple"
494
+ },
495
+ {
496
+ "id": "function:retrieval_advanced.py:resolve_image_path",
497
+ "type": "function",
498
+ "name": "resolve_image_path",
499
+ "filePath": "retrieval_advanced.py",
500
+ "lineRange": [
501
+ 61,
502
+ 67
503
+ ],
504
+ "summary": "Giải đường dẫn ảnh tương đối từ data root hoặc các thư mục cha của manifest.",
505
+ "tags": [
506
+ "path-resolution",
507
+ "utility",
508
+ "retrieval"
509
+ ],
510
+ "complexity": "simple"
511
+ },
512
+ {
513
+ "id": "function:retrieval_advanced.py:apply_d4",
514
+ "type": "function",
515
+ "name": "apply_d4",
516
+ "filePath": "retrieval_advanced.py",
517
+ "lineRange": [
518
+ 80,
519
+ 93
520
+ ],
521
+ "summary": "Áp dụng một trong tám phép biến đổi nhóm D4 gồm quay và lật ảnh.",
522
+ "tags": [
523
+ "augmentation",
524
+ "utility",
525
+ "retrieval"
526
+ ],
527
+ "complexity": "moderate"
528
+ },
529
+ {
530
+ "id": "class:retrieval_advanced.py:ImageDataset",
531
+ "type": "class",
532
+ "name": "ImageDataset",
533
+ "filePath": "retrieval_advanced.py",
534
+ "lineRange": [
535
+ 96,
536
+ 110
537
+ ],
538
+ "summary": "Dataset PyTorch nạp ảnh RGB, bảo toàn kích thước qua D4 view rồi áp dụng transform của model.",
539
+ "tags": [
540
+ "data-model",
541
+ "dataset",
542
+ "retrieval"
543
+ ],
544
+ "complexity": "moderate"
545
+ },
546
+ {
547
+ "id": "function:retrieval_advanced.py:cache_key",
548
+ "type": "function",
549
+ "name": "cache_key",
550
+ "filePath": "retrieval_advanced.py",
551
+ "lineRange": [
552
+ 114,
553
+ 118
554
+ ],
555
+ "summary": "Băm nội dung manifest cùng model, split, view và phiên bản dense feature để định danh cache.",
556
+ "tags": [
557
+ "feature-cache",
558
+ "utility",
559
+ "retrieval"
560
+ ],
561
+ "complexity": "simple"
562
+ },
563
+ {
564
+ "id": "function:retrieval_advanced.py:cache_path",
565
+ "type": "function",
566
+ "name": "cache_path",
567
+ "filePath": "retrieval_advanced.py",
568
+ "lineRange": [
569
+ 121,
570
+ 123
571
+ ],
572
+ "summary": "Tạo đường dẫn cache feature an toàn từ tên model và cache key.",
573
+ "tags": [
574
+ "feature-cache",
575
+ "utility",
576
+ "retrieval"
577
+ ],
578
+ "complexity": "simple"
579
+ },
580
+ {
581
+ "id": "function:retrieval_advanced.py:split_global_dense",
582
+ "type": "function",
583
+ "name": "split_global_dense",
584
+ "filePath": "retrieval_advanced.py",
585
+ "lineRange": [
586
+ 126,
587
+ 146
588
+ ],
589
+ "summary": "Chuyển output backbone thành global embedding và dense spatial descriptors chuẩn hóa, hỗ trợ ConvNeXt lẫn ViT/EVA.",
590
+ "tags": [
591
+ "feature-extraction",
592
+ "utility",
593
+ "retrieval"
594
+ ],
595
+ "complexity": "moderate"
596
+ },
597
+ {
598
+ "id": "function:retrieval_advanced.py:extract_and_cache",
599
+ "type": "function",
600
+ "name": "extract_and_cache",
601
+ "filePath": "retrieval_advanced.py",
602
+ "lineRange": [
603
+ 150,
604
+ 186
605
+ ],
606
+ "summary": "Tái sử dụng cache hợp lệ hoặc chạy batched inference để lưu global và dense feature theo D4 view.",
607
+ "tags": [
608
+ "feature-cache",
609
+ "utility",
610
+ "retrieval"
611
+ ],
612
+ "complexity": "complex"
613
+ },
614
+ {
615
+ "id": "function:retrieval_advanced.py:make_submission",
616
+ "type": "function",
617
+ "name": "make_submission",
618
+ "filePath": "retrieval_advanced.py",
619
+ "lineRange": [
620
+ 247,
621
+ 258
622
+ ],
623
+ "summary": "Chuyển ranking tensor thành CSV top-10, đồng thời xác thực query và gallery ID không trùng.",
624
+ "tags": [
625
+ "serialization",
626
+ "utility",
627
+ "retrieval"
628
+ ],
629
+ "complexity": "moderate"
630
+ },
631
+ {
632
+ "id": "function:retrieval_advanced.py:row_minmax",
633
+ "type": "function",
634
+ "name": "row_minmax",
635
+ "filePath": "retrieval_advanced.py",
636
+ "lineRange": [
637
+ 266,
638
+ 268
639
+ ],
640
+ "summary": "Chuẩn hóa từng hàng score về khoảng min-max với mẫu số được chặn để tránh chia cho zero.",
641
+ "tags": [
642
+ "normalization",
643
+ "utility",
644
+ "retrieval"
645
+ ],
646
+ "complexity": "simple"
647
+ },
648
+ {
649
+ "id": "function:retrieval_advanced.py:local_features",
650
+ "type": "function",
651
+ "name": "local_features",
652
+ "filePath": "retrieval_advanced.py",
653
+ "lineRange": [
654
+ 297,
655
+ 304
656
+ ],
657
+ "summary": "Phóng to ảnh xám, tăng tương phản CLAHE và trích xuất SIFT keypoint/descriptor.",
658
+ "tags": [
659
+ "feature-extraction",
660
+ "utility",
661
+ "retrieval"
662
+ ],
663
+ "complexity": "simple"
664
+ },
665
+ {
666
+ "id": "function:retrieval_advanced.py:geometric_score",
667
+ "type": "function",
668
+ "name": "geometric_score",
669
+ "filePath": "retrieval_advanced.py",
670
+ "lineRange": [
671
+ 307,
672
+ 322
673
+ ],
674
+ "summary": "Ghép SIFT bằng ratio test, ước lượng homography RANSAC và tạo score từ số lượng cùng tỷ lệ inlier.",
675
+ "tags": [
676
+ "geometric-verification",
677
+ "utility",
678
+ "retrieval"
679
+ ],
680
+ "complexity": "moderate"
681
+ },
682
+ {
683
+ "id": "function:retrieval_advanced.py:overlap",
684
+ "type": "function",
685
+ "name": "overlap",
686
+ "filePath": "retrieval_advanced.py",
687
+ "lineRange": [
688
+ 349,
689
+ 350
690
+ ],
691
+ "summary": "Tính overlap trung bình giữa hai tập top-k ranking cho mọi query.",
692
+ "tags": [
693
+ "evaluation",
694
+ "utility",
695
+ "retrieval"
696
+ ],
697
+ "complexity": "simple"
698
+ },
699
+ {
700
+ "id": "function:retrieval_advanced.py:show_top1_comparison",
701
+ "type": "function",
702
+ "name": "show_top1_comparison",
703
+ "filePath": "retrieval_advanced.py",
704
+ "lineRange": [
705
+ 379,
706
+ 396
707
+ ],
708
+ "summary": "Vẽ top-1 của global, dense và geometry cạnh query để so sánh định tính.",
709
+ "tags": [
710
+ "visualization",
711
+ "utility",
712
+ "retrieval"
713
+ ],
714
+ "complexity": "moderate"
715
+ }
716
+ ],
717
+ "edges": [
718
+ {
719
+ "source": "file:baseline_dinov3.py",
720
+ "target": "function:baseline_dinov3.py:load_manifest",
721
+ "type": "contains",
722
+ "direction": "forward",
723
+ "weight": 1
724
+ },
725
+ {
726
+ "source": "file:baseline_dinov3.py",
727
+ "target": "function:baseline_dinov3.py:load_manifest",
728
+ "type": "exports",
729
+ "direction": "forward",
730
+ "weight": 0.8
731
+ },
732
+ {
733
+ "source": "file:baseline_dinov3.py",
734
+ "target": "function:baseline_dinov3.py:resolve_image_path",
735
+ "type": "contains",
736
+ "direction": "forward",
737
+ "weight": 1
738
+ },
739
+ {
740
+ "source": "file:baseline_dinov3.py",
741
+ "target": "function:baseline_dinov3.py:resolve_image_path",
742
+ "type": "exports",
743
+ "direction": "forward",
744
+ "weight": 0.8
745
+ },
746
+ {
747
+ "source": "file:baseline_dinov3.py",
748
+ "target": "class:baseline_dinov3.py:RetrievalDataset",
749
+ "type": "contains",
750
+ "direction": "forward",
751
+ "weight": 1
752
+ },
753
+ {
754
+ "source": "file:baseline_dinov3.py",
755
+ "target": "class:baseline_dinov3.py:RetrievalDataset",
756
+ "type": "exports",
757
+ "direction": "forward",
758
+ "weight": 0.8
759
+ },
760
+ {
761
+ "source": "file:baseline_dinov3.py",
762
+ "target": "function:baseline_dinov3.py:extract_features",
763
+ "type": "contains",
764
+ "direction": "forward",
765
+ "weight": 1
766
+ },
767
+ {
768
+ "source": "file:baseline_dinov3.py",
769
+ "target": "function:baseline_dinov3.py:extract_features",
770
+ "type": "exports",
771
+ "direction": "forward",
772
+ "weight": 0.8
773
+ },
774
+ {
775
+ "source": "file:baseline_dinov3.py",
776
+ "target": "function:baseline_dinov3.py:validate_submission",
777
+ "type": "contains",
778
+ "direction": "forward",
779
+ "weight": 1
780
+ },
781
+ {
782
+ "source": "file:baseline_dinov3.py",
783
+ "target": "function:baseline_dinov3.py:validate_submission",
784
+ "type": "exports",
785
+ "direction": "forward",
786
+ "weight": 0.8
787
+ },
788
+ {
789
+ "source": "file:baseline_dinov3.py",
790
+ "target": "function:baseline_dinov3.py:extract_view",
791
+ "type": "contains",
792
+ "direction": "forward",
793
+ "weight": 1
794
+ },
795
+ {
796
+ "source": "file:baseline_dinov3.py",
797
+ "target": "function:baseline_dinov3.py:extract_view",
798
+ "type": "exports",
799
+ "direction": "forward",
800
+ "weight": 0.8
801
+ },
802
+ {
803
+ "source": "file:baseline_dinov3.py",
804
+ "target": "function:baseline_dinov3.py:show_changed_top1",
805
+ "type": "contains",
806
+ "direction": "forward",
807
+ "weight": 1
808
+ },
809
+ {
810
+ "source": "file:baseline_dinov3.py",
811
+ "target": "function:baseline_dinov3.py:show_changed_top1",
812
+ "type": "exports",
813
+ "direction": "forward",
814
+ "weight": 0.8
815
+ },
816
+ {
817
+ "source": "file:baseline_dinov3.py",
818
+ "target": "function:baseline_dinov3.py:show_retrievals",
819
+ "type": "contains",
820
+ "direction": "forward",
821
+ "weight": 1
822
+ },
823
+ {
824
+ "source": "file:baseline_dinov3.py",
825
+ "target": "function:baseline_dinov3.py:show_retrievals",
826
+ "type": "exports",
827
+ "direction": "forward",
828
+ "weight": 0.8
829
+ },
830
+ {
831
+ "source": "file:eda.py",
832
+ "target": "function:eda.py:parse_args",
833
+ "type": "contains",
834
+ "direction": "forward",
835
+ "weight": 1
836
+ },
837
+ {
838
+ "source": "file:eda.py",
839
+ "target": "function:eda.py:parse_args",
840
+ "type": "exports",
841
+ "direction": "forward",
842
+ "weight": 0.8
843
+ },
844
+ {
845
+ "source": "file:eda.py",
846
+ "target": "function:eda.py:load_manifest",
847
+ "type": "contains",
848
+ "direction": "forward",
849
+ "weight": 1
850
+ },
851
+ {
852
+ "source": "file:eda.py",
853
+ "target": "function:eda.py:load_manifest",
854
+ "type": "exports",
855
+ "direction": "forward",
856
+ "weight": 0.8
857
+ },
858
+ {
859
+ "source": "file:eda.py",
860
+ "target": "function:eda.py:resolve_image",
861
+ "type": "contains",
862
+ "direction": "forward",
863
+ "weight": 1
864
+ },
865
+ {
866
+ "source": "file:eda.py",
867
+ "target": "function:eda.py:resolve_image",
868
+ "type": "exports",
869
+ "direction": "forward",
870
+ "weight": 0.8
871
+ },
872
+ {
873
+ "source": "file:eda.py",
874
+ "target": "function:eda.py:sha256",
875
+ "type": "contains",
876
+ "direction": "forward",
877
+ "weight": 1
878
+ },
879
+ {
880
+ "source": "file:eda.py",
881
+ "target": "function:eda.py:sha256",
882
+ "type": "exports",
883
+ "direction": "forward",
884
+ "weight": 0.8
885
+ },
886
+ {
887
+ "source": "file:eda.py",
888
+ "target": "function:eda.py:image_metrics",
889
+ "type": "contains",
890
+ "direction": "forward",
891
+ "weight": 1
892
+ },
893
+ {
894
+ "source": "file:eda.py",
895
+ "target": "function:eda.py:image_metrics",
896
+ "type": "exports",
897
+ "direction": "forward",
898
+ "weight": 0.8
899
+ },
900
+ {
901
+ "source": "file:eda.py",
902
+ "target": "function:eda.py:inspect_dataset",
903
+ "type": "contains",
904
+ "direction": "forward",
905
+ "weight": 1
906
+ },
907
+ {
908
+ "source": "file:eda.py",
909
+ "target": "function:eda.py:inspect_dataset",
910
+ "type": "exports",
911
+ "direction": "forward",
912
+ "weight": 0.8
913
+ },
914
+ {
915
+ "source": "file:eda.py",
916
+ "target": "function:eda.py:create_summary",
917
+ "type": "contains",
918
+ "direction": "forward",
919
+ "weight": 1
920
+ },
921
+ {
922
+ "source": "file:eda.py",
923
+ "target": "function:eda.py:create_summary",
924
+ "type": "exports",
925
+ "direction": "forward",
926
+ "weight": 0.8
927
+ },
928
+ {
929
+ "source": "file:eda.py",
930
+ "target": "function:eda.py:thumbnail",
931
+ "type": "contains",
932
+ "direction": "forward",
933
+ "weight": 1
934
+ },
935
+ {
936
+ "source": "file:eda.py",
937
+ "target": "function:eda.py:thumbnail",
938
+ "type": "exports",
939
+ "direction": "forward",
940
+ "weight": 0.8
941
+ },
942
+ {
943
+ "source": "file:eda.py",
944
+ "target": "function:eda.py:save_grid",
945
+ "type": "contains",
946
+ "direction": "forward",
947
+ "weight": 1
948
+ },
949
+ {
950
+ "source": "file:eda.py",
951
+ "target": "function:eda.py:save_grid",
952
+ "type": "exports",
953
+ "direction": "forward",
954
+ "weight": 0.8
955
+ },
956
+ {
957
+ "source": "file:eda.py",
958
+ "target": "function:eda.py:save_grids",
959
+ "type": "contains",
960
+ "direction": "forward",
961
+ "weight": 1
962
+ },
963
+ {
964
+ "source": "file:eda.py",
965
+ "target": "function:eda.py:save_grids",
966
+ "type": "exports",
967
+ "direction": "forward",
968
+ "weight": 0.8
969
+ },
970
+ {
971
+ "source": "file:eda.py",
972
+ "target": "function:eda.py:save_distributions",
973
+ "type": "contains",
974
+ "direction": "forward",
975
+ "weight": 1
976
+ },
977
+ {
978
+ "source": "file:eda.py",
979
+ "target": "function:eda.py:save_distributions",
980
+ "type": "exports",
981
+ "direction": "forward",
982
+ "weight": 0.8
983
+ },
984
+ {
985
+ "source": "file:eda.py",
986
+ "target": "function:eda.py:write_integrity_report",
987
+ "type": "contains",
988
+ "direction": "forward",
989
+ "weight": 1
990
+ },
991
+ {
992
+ "source": "file:eda.py",
993
+ "target": "function:eda.py:write_integrity_report",
994
+ "type": "exports",
995
+ "direction": "forward",
996
+ "weight": 0.8
997
+ },
998
+ {
999
+ "source": "file:eda.py",
1000
+ "target": "function:eda.py:write_markdown_report",
1001
+ "type": "contains",
1002
+ "direction": "forward",
1003
+ "weight": 1
1004
+ },
1005
+ {
1006
+ "source": "file:eda.py",
1007
+ "target": "function:eda.py:write_markdown_report",
1008
+ "type": "exports",
1009
+ "direction": "forward",
1010
+ "weight": 0.8
1011
+ },
1012
+ {
1013
+ "source": "file:eda.py",
1014
+ "target": "function:eda.py:main",
1015
+ "type": "contains",
1016
+ "direction": "forward",
1017
+ "weight": 1
1018
+ },
1019
+ {
1020
+ "source": "file:eda.py",
1021
+ "target": "function:eda.py:main",
1022
+ "type": "exports",
1023
+ "direction": "forward",
1024
+ "weight": 0.8
1025
+ },
1026
+ {
1027
+ "source": "file:retrieval_advanced.py",
1028
+ "target": "function:retrieval_advanced.py:load_manifest",
1029
+ "type": "contains",
1030
+ "direction": "forward",
1031
+ "weight": 1
1032
+ },
1033
+ {
1034
+ "source": "file:retrieval_advanced.py",
1035
+ "target": "function:retrieval_advanced.py:load_manifest",
1036
+ "type": "exports",
1037
+ "direction": "forward",
1038
+ "weight": 0.8
1039
+ },
1040
+ {
1041
+ "source": "file:retrieval_advanced.py",
1042
+ "target": "function:retrieval_advanced.py:resolve_image_path",
1043
+ "type": "contains",
1044
+ "direction": "forward",
1045
+ "weight": 1
1046
+ },
1047
+ {
1048
+ "source": "file:retrieval_advanced.py",
1049
+ "target": "function:retrieval_advanced.py:resolve_image_path",
1050
+ "type": "exports",
1051
+ "direction": "forward",
1052
+ "weight": 0.8
1053
+ },
1054
+ {
1055
+ "source": "file:retrieval_advanced.py",
1056
+ "target": "function:retrieval_advanced.py:apply_d4",
1057
+ "type": "contains",
1058
+ "direction": "forward",
1059
+ "weight": 1
1060
+ },
1061
+ {
1062
+ "source": "file:retrieval_advanced.py",
1063
+ "target": "function:retrieval_advanced.py:apply_d4",
1064
+ "type": "exports",
1065
+ "direction": "forward",
1066
+ "weight": 0.8
1067
+ },
1068
+ {
1069
+ "source": "file:retrieval_advanced.py",
1070
+ "target": "class:retrieval_advanced.py:ImageDataset",
1071
+ "type": "contains",
1072
+ "direction": "forward",
1073
+ "weight": 1
1074
+ },
1075
+ {
1076
+ "source": "file:retrieval_advanced.py",
1077
+ "target": "class:retrieval_advanced.py:ImageDataset",
1078
+ "type": "exports",
1079
+ "direction": "forward",
1080
+ "weight": 0.8
1081
+ },
1082
+ {
1083
+ "source": "file:retrieval_advanced.py",
1084
+ "target": "function:retrieval_advanced.py:cache_key",
1085
+ "type": "contains",
1086
+ "direction": "forward",
1087
+ "weight": 1
1088
+ },
1089
+ {
1090
+ "source": "file:retrieval_advanced.py",
1091
+ "target": "function:retrieval_advanced.py:cache_key",
1092
+ "type": "exports",
1093
+ "direction": "forward",
1094
+ "weight": 0.8
1095
+ },
1096
+ {
1097
+ "source": "file:retrieval_advanced.py",
1098
+ "target": "function:retrieval_advanced.py:cache_path",
1099
+ "type": "contains",
1100
+ "direction": "forward",
1101
+ "weight": 1
1102
+ },
1103
+ {
1104
+ "source": "file:retrieval_advanced.py",
1105
+ "target": "function:retrieval_advanced.py:cache_path",
1106
+ "type": "exports",
1107
+ "direction": "forward",
1108
+ "weight": 0.8
1109
+ },
1110
+ {
1111
+ "source": "file:retrieval_advanced.py",
1112
+ "target": "function:retrieval_advanced.py:split_global_dense",
1113
+ "type": "contains",
1114
+ "direction": "forward",
1115
+ "weight": 1
1116
+ },
1117
+ {
1118
+ "source": "file:retrieval_advanced.py",
1119
+ "target": "function:retrieval_advanced.py:split_global_dense",
1120
+ "type": "exports",
1121
+ "direction": "forward",
1122
+ "weight": 0.8
1123
+ },
1124
+ {
1125
+ "source": "file:retrieval_advanced.py",
1126
+ "target": "function:retrieval_advanced.py:extract_and_cache",
1127
+ "type": "contains",
1128
+ "direction": "forward",
1129
+ "weight": 1
1130
+ },
1131
+ {
1132
+ "source": "file:retrieval_advanced.py",
1133
+ "target": "function:retrieval_advanced.py:extract_and_cache",
1134
+ "type": "exports",
1135
+ "direction": "forward",
1136
+ "weight": 0.8
1137
+ },
1138
+ {
1139
+ "source": "file:retrieval_advanced.py",
1140
+ "target": "function:retrieval_advanced.py:make_submission",
1141
+ "type": "contains",
1142
+ "direction": "forward",
1143
+ "weight": 1
1144
+ },
1145
+ {
1146
+ "source": "file:retrieval_advanced.py",
1147
+ "target": "function:retrieval_advanced.py:make_submission",
1148
+ "type": "exports",
1149
+ "direction": "forward",
1150
+ "weight": 0.8
1151
+ },
1152
+ {
1153
+ "source": "file:retrieval_advanced.py",
1154
+ "target": "function:retrieval_advanced.py:row_minmax",
1155
+ "type": "contains",
1156
+ "direction": "forward",
1157
+ "weight": 1
1158
+ },
1159
+ {
1160
+ "source": "file:retrieval_advanced.py",
1161
+ "target": "function:retrieval_advanced.py:row_minmax",
1162
+ "type": "exports",
1163
+ "direction": "forward",
1164
+ "weight": 0.8
1165
+ },
1166
+ {
1167
+ "source": "file:retrieval_advanced.py",
1168
+ "target": "function:retrieval_advanced.py:local_features",
1169
+ "type": "contains",
1170
+ "direction": "forward",
1171
+ "weight": 1
1172
+ },
1173
+ {
1174
+ "source": "file:retrieval_advanced.py",
1175
+ "target": "function:retrieval_advanced.py:local_features",
1176
+ "type": "exports",
1177
+ "direction": "forward",
1178
+ "weight": 0.8
1179
+ },
1180
+ {
1181
+ "source": "file:retrieval_advanced.py",
1182
+ "target": "function:retrieval_advanced.py:geometric_score",
1183
+ "type": "contains",
1184
+ "direction": "forward",
1185
+ "weight": 1
1186
+ },
1187
+ {
1188
+ "source": "file:retrieval_advanced.py",
1189
+ "target": "function:retrieval_advanced.py:geometric_score",
1190
+ "type": "exports",
1191
+ "direction": "forward",
1192
+ "weight": 0.8
1193
+ },
1194
+ {
1195
+ "source": "file:retrieval_advanced.py",
1196
+ "target": "function:retrieval_advanced.py:overlap",
1197
+ "type": "contains",
1198
+ "direction": "forward",
1199
+ "weight": 1
1200
+ },
1201
+ {
1202
+ "source": "file:retrieval_advanced.py",
1203
+ "target": "function:retrieval_advanced.py:overlap",
1204
+ "type": "exports",
1205
+ "direction": "forward",
1206
+ "weight": 0.8
1207
+ },
1208
+ {
1209
+ "source": "file:retrieval_advanced.py",
1210
+ "target": "function:retrieval_advanced.py:show_top1_comparison",
1211
+ "type": "contains",
1212
+ "direction": "forward",
1213
+ "weight": 1
1214
+ },
1215
+ {
1216
+ "source": "file:retrieval_advanced.py",
1217
+ "target": "function:retrieval_advanced.py:show_top1_comparison",
1218
+ "type": "exports",
1219
+ "direction": "forward",
1220
+ "weight": 0.8
1221
+ }
1222
+ ]
1223
+ }
1224
+
.understand-anything/intermediate/batches.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schemaVersion": 1,
3
+ "algorithm": "louvain",
4
+ "totalFiles": 7,
5
+ "totalBatches": 1,
6
+ "exportsByPath": {
7
+ ".understand-anything/.understandignore": [],
8
+ "baseline_dinov3.py": [
9
+ "load_manifest",
10
+ "resolve_image_path",
11
+ "RetrievalDataset",
12
+ "extract_features",
13
+ "validate_submission",
14
+ "extract_view",
15
+ "show_changed_top1",
16
+ "show_retrievals"
17
+ ],
18
+ "eda.py": [
19
+ "parse_args",
20
+ "load_manifest",
21
+ "resolve_image",
22
+ "sha256",
23
+ "image_metrics",
24
+ "inspect_dataset",
25
+ "create_summary",
26
+ "thumbnail",
27
+ "save_grid",
28
+ "save_grids",
29
+ "save_distributions",
30
+ "write_integrity_report",
31
+ "write_markdown_report",
32
+ "main"
33
+ ],
34
+ "notebook324f4a11f8_upgraded.ipynb": [],
35
+ "retrieval_advanced.py": [
36
+ "load_manifest",
37
+ "resolve_image_path",
38
+ "apply_d4",
39
+ "ImageDataset",
40
+ "cache_key",
41
+ "cache_path",
42
+ "split_global_dense",
43
+ "extract_and_cache",
44
+ "make_submission",
45
+ "row_minmax",
46
+ "local_features",
47
+ "geometric_score",
48
+ "overlap",
49
+ "show_top1_comparison"
50
+ ]
51
+ },
52
+ "batches": [
53
+ {
54
+ "batchIndex": 1,
55
+ "files": [
56
+ {
57
+ "path": ".understand-anything/.understandignore",
58
+ "language": "unknown",
59
+ "sizeLines": 47,
60
+ "fileCategory": "code"
61
+ },
62
+ {
63
+ "path": ".understand-anything/config.json",
64
+ "language": "json",
65
+ "sizeLines": 3,
66
+ "fileCategory": "config"
67
+ },
68
+ {
69
+ "path": "baseline_dinov3.py",
70
+ "language": "python",
71
+ "sizeLines": 397,
72
+ "fileCategory": "code"
73
+ },
74
+ {
75
+ "path": "de_bai_image_to_image_retrieval.md",
76
+ "language": "markdown",
77
+ "sizeLines": 66,
78
+ "fileCategory": "docs"
79
+ },
80
+ {
81
+ "path": "eda.py",
82
+ "language": "python",
83
+ "sizeLines": 341,
84
+ "fileCategory": "code"
85
+ },
86
+ {
87
+ "path": "notebook324f4a11f8_upgraded.ipynb",
88
+ "language": "ipynb",
89
+ "sizeLines": 3255,
90
+ "fileCategory": "code"
91
+ },
92
+ {
93
+ "path": "retrieval_advanced.py",
94
+ "language": "python",
95
+ "sizeLines": 399,
96
+ "fileCategory": "code"
97
+ }
98
+ ],
99
+ "batchImportData": {
100
+ ".understand-anything/.understandignore": [],
101
+ ".understand-anything/config.json": [],
102
+ "baseline_dinov3.py": [],
103
+ "de_bai_image_to_image_retrieval.md": [],
104
+ "eda.py": [],
105
+ "notebook324f4a11f8_upgraded.ipynb": [],
106
+ "retrieval_advanced.py": []
107
+ },
108
+ "neighborMap": {}
109
+ }
110
+ ]
111
+ }
.understand-anything/intermediate/scan-result.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "openai_cv",
3
+ "description": "Không có mô tả.",
4
+ "languages": [
5
+ "ipynb",
6
+ "json",
7
+ "markdown",
8
+ "python",
9
+ "unknown"
10
+ ],
11
+ "frameworks": [],
12
+ "files": [
13
+ {
14
+ "path": ".understand-anything/.understandignore",
15
+ "language": "unknown",
16
+ "sizeLines": 47,
17
+ "fileCategory": "code"
18
+ },
19
+ {
20
+ "path": ".understand-anything/config.json",
21
+ "language": "json",
22
+ "sizeLines": 3,
23
+ "fileCategory": "config"
24
+ },
25
+ {
26
+ "path": "baseline_dinov3.py",
27
+ "language": "python",
28
+ "sizeLines": 397,
29
+ "fileCategory": "code"
30
+ },
31
+ {
32
+ "path": "de_bai_image_to_image_retrieval.md",
33
+ "language": "markdown",
34
+ "sizeLines": 66,
35
+ "fileCategory": "docs"
36
+ },
37
+ {
38
+ "path": "eda.py",
39
+ "language": "python",
40
+ "sizeLines": 341,
41
+ "fileCategory": "code"
42
+ },
43
+ {
44
+ "path": "notebook324f4a11f8_upgraded.ipynb",
45
+ "language": "ipynb",
46
+ "sizeLines": 3255,
47
+ "fileCategory": "code"
48
+ },
49
+ {
50
+ "path": "retrieval_advanced.py",
51
+ "language": "python",
52
+ "sizeLines": 399,
53
+ "fileCategory": "code"
54
+ }
55
+ ],
56
+ "totalFiles": 7,
57
+ "filteredByIgnore": 32,
58
+ "estimatedComplexity": "small",
59
+ "importMap": {
60
+ ".understand-anything/.understandignore": [],
61
+ ".understand-anything/config.json": [],
62
+ "baseline_dinov3.py": [],
63
+ "de_bai_image_to_image_retrieval.md": [],
64
+ "eda.py": [],
65
+ "notebook324f4a11f8_upgraded.ipynb": [],
66
+ "retrieval_advanced.py": []
67
+ }
68
+ }
.understand-anything/tmp/ua-file-analyzer-input-1.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "projectRoot": "/mnt/data/openai_cv",
3
+ "batchFiles": [
4
+ {"path": ".understand-anything/.understandignore", "language": "unknown", "sizeLines": 47, "fileCategory": "code"},
5
+ {"path": ".understand-anything/config.json", "language": "json", "sizeLines": 3, "fileCategory": "config"},
6
+ {"path": "baseline_dinov3.py", "language": "python", "sizeLines": 397, "fileCategory": "code"},
7
+ {"path": "de_bai_image_to_image_retrieval.md", "language": "markdown", "sizeLines": 66, "fileCategory": "docs"},
8
+ {"path": "eda.py", "language": "python", "sizeLines": 341, "fileCategory": "code"},
9
+ {"path": "notebook324f4a11f8_upgraded.ipynb", "language": "ipynb", "sizeLines": 3255, "fileCategory": "code"},
10
+ {"path": "retrieval_advanced.py", "language": "python", "sizeLines": 399, "fileCategory": "code"}
11
+ ],
12
+ "batchImportData": {
13
+ ".understand-anything/.understandignore": [],
14
+ ".understand-anything/config.json": [],
15
+ "baseline_dinov3.py": [],
16
+ "de_bai_image_to_image_retrieval.md": [],
17
+ "eda.py": [],
18
+ "notebook324f4a11f8_upgraded.ipynb": [],
19
+ "retrieval_advanced.py": []
20
+ }
21
+ }
.understand-anything/tmp/ua-file-extract-results-1.json ADDED
@@ -0,0 +1,2834 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "scriptCompleted": true,
3
+ "filesAnalyzed": 7,
4
+ "filesSkipped": [],
5
+ "results": [
6
+ {
7
+ "path": ".understand-anything/.understandignore",
8
+ "language": "unknown",
9
+ "fileCategory": "code",
10
+ "totalLines": 47,
11
+ "nonEmptyLines": 44,
12
+ "metrics": {}
13
+ },
14
+ {
15
+ "path": ".understand-anything/config.json",
16
+ "language": "json",
17
+ "fileCategory": "config",
18
+ "totalLines": 3,
19
+ "nonEmptyLines": 3,
20
+ "sections": [
21
+ {
22
+ "heading": "outputLanguage",
23
+ "level": 1,
24
+ "line": 2
25
+ }
26
+ ],
27
+ "metrics": {
28
+ "importCount": 0,
29
+ "exportCount": 0,
30
+ "functionCount": 0,
31
+ "classCount": 0,
32
+ "sectionCount": 1
33
+ }
34
+ },
35
+ {
36
+ "path": "baseline_dinov3.py",
37
+ "language": "python",
38
+ "fileCategory": "code",
39
+ "totalLines": 397,
40
+ "nonEmptyLines": 328,
41
+ "functions": [
42
+ {
43
+ "name": "load_manifest",
44
+ "startLine": 43,
45
+ "endLine": 51,
46
+ "params": [
47
+ "path"
48
+ ]
49
+ },
50
+ {
51
+ "name": "resolve_image_path",
52
+ "startLine": 54,
53
+ "endLine": 65,
54
+ "params": [
55
+ "data_root",
56
+ "manifest_path",
57
+ "image_path"
58
+ ]
59
+ },
60
+ {
61
+ "name": "extract_features",
62
+ "startLine": 133,
63
+ "endLine": 150,
64
+ "params": [
65
+ "loader"
66
+ ]
67
+ },
68
+ {
69
+ "name": "validate_submission",
70
+ "startLine": 183,
71
+ "endLine": 198,
72
+ "params": [
73
+ "frame",
74
+ "expected_query_ids",
75
+ "valid_gallery_ids",
76
+ "k"
77
+ ]
78
+ },
79
+ {
80
+ "name": "extract_view",
81
+ "startLine": 252,
82
+ "endLine": 255,
83
+ "params": [
84
+ "manifest",
85
+ "view_transform"
86
+ ]
87
+ },
88
+ {
89
+ "name": "show_changed_top1",
90
+ "startLine": 333,
91
+ "endLine": 366,
92
+ "params": [
93
+ "limit"
94
+ ]
95
+ },
96
+ {
97
+ "name": "show_retrievals",
98
+ "startLine": 373,
99
+ "endLine": 394,
100
+ "params": [
101
+ "query_indices",
102
+ "candidates"
103
+ ]
104
+ }
105
+ ],
106
+ "classes": [
107
+ {
108
+ "name": "RetrievalDataset",
109
+ "startLine": 68,
110
+ "endLine": 91,
111
+ "methods": [
112
+ "__init__",
113
+ "__len__",
114
+ "__getitem__"
115
+ ],
116
+ "properties": []
117
+ }
118
+ ],
119
+ "exports": [
120
+ {
121
+ "name": "load_manifest",
122
+ "line": 43,
123
+ "isDefault": false
124
+ },
125
+ {
126
+ "name": "resolve_image_path",
127
+ "line": 54,
128
+ "isDefault": false
129
+ },
130
+ {
131
+ "name": "RetrievalDataset",
132
+ "line": 68,
133
+ "isDefault": false
134
+ },
135
+ {
136
+ "name": "extract_features",
137
+ "line": 132,
138
+ "isDefault": false
139
+ },
140
+ {
141
+ "name": "validate_submission",
142
+ "line": 183,
143
+ "isDefault": false
144
+ },
145
+ {
146
+ "name": "extract_view",
147
+ "line": 252,
148
+ "isDefault": false
149
+ },
150
+ {
151
+ "name": "show_changed_top1",
152
+ "line": 333,
153
+ "isDefault": false
154
+ },
155
+ {
156
+ "name": "show_retrievals",
157
+ "line": 373,
158
+ "isDefault": false
159
+ }
160
+ ],
161
+ "callGraph": [
162
+ {
163
+ "caller": "load_manifest",
164
+ "callee": "path.open",
165
+ "lineNumber": 44
166
+ },
167
+ {
168
+ "caller": "load_manifest",
169
+ "callee": "json.load",
170
+ "lineNumber": 45
171
+ },
172
+ {
173
+ "caller": "load_manifest",
174
+ "callee": "isinstance",
175
+ "lineNumber": 46
176
+ },
177
+ {
178
+ "caller": "load_manifest",
179
+ "callee": "ValueError",
180
+ "lineNumber": 47
181
+ },
182
+ {
183
+ "caller": "load_manifest",
184
+ "callee": "enumerate",
185
+ "lineNumber": 48
186
+ },
187
+ {
188
+ "caller": "load_manifest",
189
+ "callee": "isinstance",
190
+ "lineNumber": 49
191
+ },
192
+ {
193
+ "caller": "load_manifest",
194
+ "callee": "row.keys",
195
+ "lineNumber": 49
196
+ },
197
+ {
198
+ "caller": "load_manifest",
199
+ "callee": "ValueError",
200
+ "lineNumber": 50
201
+ },
202
+ {
203
+ "caller": "resolve_image_path",
204
+ "callee": "Path",
205
+ "lineNumber": 56
206
+ },
207
+ {
208
+ "caller": "resolve_image_path",
209
+ "callee": "candidate.is_file",
210
+ "lineNumber": 63
211
+ },
212
+ {
213
+ "caller": "resolve_image_path",
214
+ "callee": "FileNotFoundError",
215
+ "lineNumber": 65
216
+ },
217
+ {
218
+ "caller": "__init__",
219
+ "callee": "load_manifest",
220
+ "lineNumber": 71
221
+ },
222
+ {
223
+ "caller": "__init__",
224
+ "callee": "resolve_image_path",
225
+ "lineNumber": 75
226
+ },
227
+ {
228
+ "caller": "__len__",
229
+ "callee": "len",
230
+ "lineNumber": 80
231
+ },
232
+ {
233
+ "caller": "__getitem__",
234
+ "callee": "Image.open",
235
+ "lineNumber": 84
236
+ },
237
+ {
238
+ "caller": "__getitem__",
239
+ "callee": "image.convert",
240
+ "lineNumber": 85
241
+ },
242
+ {
243
+ "caller": "__getitem__",
244
+ "callee": "self.view_transform",
245
+ "lineNumber": 88
246
+ },
247
+ {
248
+ "caller": "__getitem__",
249
+ "callee": "self.transform",
250
+ "lineNumber": 90
251
+ },
252
+ {
253
+ "caller": "extract_features",
254
+ "callee": "images.to",
255
+ "lineNumber": 137
256
+ },
257
+ {
258
+ "caller": "extract_features",
259
+ "callee": "torch.autocast",
260
+ "lineNumber": 138
261
+ },
262
+ {
263
+ "caller": "extract_features",
264
+ "callee": "nullcontext",
265
+ "lineNumber": 138
266
+ },
267
+ {
268
+ "caller": "extract_features",
269
+ "callee": "model",
270
+ "lineNumber": 140
271
+ },
272
+ {
273
+ "caller": "extract_features",
274
+ "callee": "features.flatten(2).mean",
275
+ "lineNumber": 142
276
+ },
277
+ {
278
+ "caller": "extract_features",
279
+ "callee": "features.flatten",
280
+ "lineNumber": 142
281
+ },
282
+ {
283
+ "caller": "extract_features",
284
+ "callee": "F.normalize",
285
+ "lineNumber": 143
286
+ },
287
+ {
288
+ "caller": "extract_features",
289
+ "callee": "features.float",
290
+ "lineNumber": 143
291
+ },
292
+ {
293
+ "caller": "extract_features",
294
+ "callee": "all_ids.extend",
295
+ "lineNumber": 144
296
+ },
297
+ {
298
+ "caller": "extract_features",
299
+ "callee": "all_features.append",
300
+ "lineNumber": 145
301
+ },
302
+ {
303
+ "caller": "extract_features",
304
+ "callee": "features.cpu",
305
+ "lineNumber": 145
306
+ },
307
+ {
308
+ "caller": "extract_features",
309
+ "callee": "torch.cat",
310
+ "lineNumber": 147
311
+ },
312
+ {
313
+ "caller": "extract_features",
314
+ "callee": "len",
315
+ "lineNumber": 148
316
+ },
317
+ {
318
+ "caller": "extract_features",
319
+ "callee": "torch.isfinite(embeddings).all",
320
+ "lineNumber": 149
321
+ },
322
+ {
323
+ "caller": "extract_features",
324
+ "callee": "torch.isfinite",
325
+ "lineNumber": 149
326
+ },
327
+ {
328
+ "caller": "validate_submission",
329
+ "callee": "list",
330
+ "lineNumber": 189
331
+ },
332
+ {
333
+ "caller": "validate_submission",
334
+ "callee": "frame[\"query_id\"].tolist",
335
+ "lineNumber": 190
336
+ },
337
+ {
338
+ "caller": "validate_submission",
339
+ "callee": "set",
340
+ "lineNumber": 193
341
+ },
342
+ {
343
+ "caller": "validate_submission",
344
+ "callee": "frame.itertuples",
345
+ "lineNumber": 194
346
+ },
347
+ {
348
+ "caller": "validate_submission",
349
+ "callee": "value.split",
350
+ "lineNumber": 195
351
+ },
352
+ {
353
+ "caller": "validate_submission",
354
+ "callee": "len",
355
+ "lineNumber": 196
356
+ },
357
+ {
358
+ "caller": "validate_submission",
359
+ "callee": "len",
360
+ "lineNumber": 197
361
+ },
362
+ {
363
+ "caller": "validate_submission",
364
+ "callee": "set",
365
+ "lineNumber": 197
366
+ },
367
+ {
368
+ "caller": "validate_submission",
369
+ "callee": "set",
370
+ "lineNumber": 198
371
+ },
372
+ {
373
+ "caller": "extract_view",
374
+ "callee": "RetrievalDataset",
375
+ "lineNumber": 253
376
+ },
377
+ {
378
+ "caller": "extract_view",
379
+ "callee": "DataLoader",
380
+ "lineNumber": 254
381
+ },
382
+ {
383
+ "caller": "extract_view",
384
+ "callee": "extract_features",
385
+ "lineNumber": 255
386
+ },
387
+ {
388
+ "caller": "show_changed_top1",
389
+ "callee": "torch.where",
390
+ "lineNumber": 334
391
+ },
392
+ {
393
+ "caller": "show_changed_top1",
394
+ "callee": "len",
395
+ "lineNumber": 335
396
+ },
397
+ {
398
+ "caller": "show_changed_top1",
399
+ "callee": "print",
400
+ "lineNumber": 336
401
+ },
402
+ {
403
+ "caller": "show_changed_top1",
404
+ "callee": "(tta_top1 - baseline_top1).abs",
405
+ "lineNumber": 339
406
+ },
407
+ {
408
+ "caller": "show_changed_top1",
409
+ "callee": "torch.argsort",
410
+ "lineNumber": 340
411
+ },
412
+ {
413
+ "caller": "show_changed_top1",
414
+ "callee": "dict",
415
+ "lineNumber": 341
416
+ },
417
+ {
418
+ "caller": "show_changed_top1",
419
+ "callee": "zip",
420
+ "lineNumber": 341
421
+ },
422
+ {
423
+ "caller": "show_changed_top1",
424
+ "callee": "plt.subplots",
425
+ "lineNumber": 342
426
+ },
427
+ {
428
+ "caller": "show_changed_top1",
429
+ "callee": "len",
430
+ "lineNumber": 342
431
+ },
432
+ {
433
+ "caller": "show_changed_top1",
434
+ "callee": "len",
435
+ "lineNumber": 342
436
+ },
437
+ {
438
+ "caller": "show_changed_top1",
439
+ "callee": "np.atleast_2d",
440
+ "lineNumber": 343
441
+ },
442
+ {
443
+ "caller": "show_changed_top1",
444
+ "callee": "enumerate",
445
+ "lineNumber": 345
446
+ },
447
+ {
448
+ "caller": "show_changed_top1",
449
+ "callee": "int",
450
+ "lineNumber": 346
451
+ },
452
+ {
453
+ "caller": "show_changed_top1",
454
+ "callee": "int",
455
+ "lineNumber": 347
456
+ },
457
+ {
458
+ "caller": "show_changed_top1",
459
+ "callee": "int",
460
+ "lineNumber": 348
461
+ },
462
+ {
463
+ "caller": "show_changed_top1",
464
+ "callee": "enumerate",
465
+ "lineNumber": 359
466
+ },
467
+ {
468
+ "caller": "show_changed_top1",
469
+ "callee": "zip",
470
+ "lineNumber": 359
471
+ },
472
+ {
473
+ "caller": "show_changed_top1",
474
+ "callee": "Image.open",
475
+ "lineNumber": 360
476
+ },
477
+ {
478
+ "caller": "show_changed_top1",
479
+ "callee": "axes[plot_row, column].imshow",
480
+ "lineNumber": 361
481
+ },
482
+ {
483
+ "caller": "show_changed_top1",
484
+ "callee": "image.convert",
485
+ "lineNumber": 361
486
+ },
487
+ {
488
+ "caller": "show_changed_top1",
489
+ "callee": "axes[plot_row, column].set_title",
490
+ "lineNumber": 362
491
+ },
492
+ {
493
+ "caller": "show_changed_top1",
494
+ "callee": "axes[plot_row, column].axis",
495
+ "lineNumber": 363
496
+ },
497
+ {
498
+ "caller": "show_changed_top1",
499
+ "callee": "plt.tight_layout",
500
+ "lineNumber": 365
501
+ },
502
+ {
503
+ "caller": "show_changed_top1",
504
+ "callee": "plt.show",
505
+ "lineNumber": 366
506
+ },
507
+ {
508
+ "caller": "show_retrievals",
509
+ "callee": "dict",
510
+ "lineNumber": 374
511
+ },
512
+ {
513
+ "caller": "show_retrievals",
514
+ "callee": "zip",
515
+ "lineNumber": 374
516
+ },
517
+ {
518
+ "caller": "show_retrievals",
519
+ "callee": "len",
520
+ "lineNumber": 375
521
+ },
522
+ {
523
+ "caller": "show_retrievals",
524
+ "callee": "plt.subplots",
525
+ "lineNumber": 376
526
+ },
527
+ {
528
+ "caller": "show_retrievals",
529
+ "callee": "np.atleast_2d",
530
+ "lineNumber": 377
531
+ },
532
+ {
533
+ "caller": "show_retrievals",
534
+ "callee": "enumerate",
535
+ "lineNumber": 379
536
+ },
537
+ {
538
+ "caller": "show_retrievals",
539
+ "callee": "Image.open",
540
+ "lineNumber": 380
541
+ },
542
+ {
543
+ "caller": "show_retrievals",
544
+ "callee": "axes[plot_row, 0].imshow",
545
+ "lineNumber": 381
546
+ },
547
+ {
548
+ "caller": "show_retrievals",
549
+ "callee": "image.convert",
550
+ "lineNumber": 381
551
+ },
552
+ {
553
+ "caller": "show_retrievals",
554
+ "callee": "axes[plot_row, 0].set_title",
555
+ "lineNumber": 382
556
+ },
557
+ {
558
+ "caller": "show_retrievals",
559
+ "callee": "range",
560
+ "lineNumber": 384
561
+ },
562
+ {
563
+ "caller": "show_retrievals",
564
+ "callee": "Image.open",
565
+ "lineNumber": 386
566
+ },
567
+ {
568
+ "caller": "show_retrievals",
569
+ "callee": "axes[plot_row, rank + 1].imshow",
570
+ "lineNumber": 387
571
+ },
572
+ {
573
+ "caller": "show_retrievals",
574
+ "callee": "image.convert",
575
+ "lineNumber": 387
576
+ },
577
+ {
578
+ "caller": "show_retrievals",
579
+ "callee": "top_scores[query_index, rank].item",
580
+ "lineNumber": 388
581
+ },
582
+ {
583
+ "caller": "show_retrievals",
584
+ "callee": "axes[plot_row, rank + 1].set_title",
585
+ "lineNumber": 389
586
+ },
587
+ {
588
+ "caller": "show_retrievals",
589
+ "callee": "axes.ravel",
590
+ "lineNumber": 391
591
+ },
592
+ {
593
+ "caller": "show_retrievals",
594
+ "callee": "axis.axis",
595
+ "lineNumber": 392
596
+ },
597
+ {
598
+ "caller": "show_retrievals",
599
+ "callee": "plt.tight_layout",
600
+ "lineNumber": 393
601
+ },
602
+ {
603
+ "caller": "show_retrievals",
604
+ "callee": "plt.show",
605
+ "lineNumber": 394
606
+ }
607
+ ],
608
+ "metrics": {
609
+ "importCount": 0,
610
+ "exportCount": 8,
611
+ "functionCount": 7,
612
+ "classCount": 1
613
+ }
614
+ },
615
+ {
616
+ "path": "de_bai_image_to_image_retrieval.md",
617
+ "language": "markdown",
618
+ "fileCategory": "docs",
619
+ "totalLines": 67,
620
+ "nonEmptyLines": 44,
621
+ "sections": [
622
+ {
623
+ "heading": "Đề thi Olympic AI — Image-to-Image Instance Retrieval (không nhãn)",
624
+ "level": 1,
625
+ "line": 1
626
+ },
627
+ {
628
+ "heading": "1. Bài toán",
629
+ "level": 2,
630
+ "line": 3
631
+ },
632
+ {
633
+ "heading": "2. Dữ liệu — không có nhãn nào được cung cấp",
634
+ "level": 2,
635
+ "line": 13
636
+ },
637
+ {
638
+ "heading": "3. Cấu trúc cuộc thi (train / public test / private test)",
639
+ "level": 2,
640
+ "line": 23
641
+ },
642
+ {
643
+ "heading": "4. Định dạng nộp bài",
644
+ "level": 2,
645
+ "line": 29
646
+ },
647
+ {
648
+ "heading": "5. Chấm điểm",
649
+ "level": 2,
650
+ "line": 43
651
+ },
652
+ {
653
+ "heading": "6. Ràng buộc",
654
+ "level": 2,
655
+ "line": 61
656
+ }
657
+ ],
658
+ "metrics": {
659
+ "importCount": 0,
660
+ "exportCount": 0,
661
+ "functionCount": 0,
662
+ "classCount": 0,
663
+ "sectionCount": 7
664
+ }
665
+ },
666
+ {
667
+ "path": "eda.py",
668
+ "language": "python",
669
+ "fileCategory": "code",
670
+ "totalLines": 341,
671
+ "nonEmptyLines": 297,
672
+ "functions": [
673
+ {
674
+ "name": "parse_args",
675
+ "startLine": 43,
676
+ "endLine": 49,
677
+ "params": []
678
+ },
679
+ {
680
+ "name": "load_manifest",
681
+ "startLine": 52,
682
+ "endLine": 60,
683
+ "params": [
684
+ "path"
685
+ ]
686
+ },
687
+ {
688
+ "name": "resolve_image",
689
+ "startLine": 63,
690
+ "endLine": 73,
691
+ "params": [
692
+ "data_root",
693
+ "manifest",
694
+ "relative"
695
+ ]
696
+ },
697
+ {
698
+ "name": "sha256",
699
+ "startLine": 76,
700
+ "endLine": 81,
701
+ "params": [
702
+ "path"
703
+ ]
704
+ },
705
+ {
706
+ "name": "image_metrics",
707
+ "startLine": 84,
708
+ "endLine": 104,
709
+ "params": [
710
+ "rgb"
711
+ ]
712
+ },
713
+ {
714
+ "name": "inspect_dataset",
715
+ "startLine": 107,
716
+ "endLine": 168,
717
+ "params": [
718
+ "data_root"
719
+ ]
720
+ },
721
+ {
722
+ "name": "create_summary",
723
+ "startLine": 171,
724
+ "endLine": 176,
725
+ "params": [
726
+ "metrics"
727
+ ]
728
+ },
729
+ {
730
+ "name": "thumbnail",
731
+ "startLine": 179,
732
+ "endLine": 181,
733
+ "params": [
734
+ "path",
735
+ "size"
736
+ ]
737
+ },
738
+ {
739
+ "name": "save_grid",
740
+ "startLine": 184,
741
+ "endLine": 200,
742
+ "params": [
743
+ "rows",
744
+ "output",
745
+ "title",
746
+ "limit"
747
+ ]
748
+ },
749
+ {
750
+ "name": "save_grids",
751
+ "startLine": 203,
752
+ "endLine": 218,
753
+ "params": [
754
+ "metrics",
755
+ "output_dir",
756
+ "seed",
757
+ "grid_size"
758
+ ]
759
+ },
760
+ {
761
+ "name": "save_distributions",
762
+ "startLine": 221,
763
+ "endLine": 237,
764
+ "params": [
765
+ "metrics",
766
+ "output"
767
+ ]
768
+ },
769
+ {
770
+ "name": "write_integrity_report",
771
+ "startLine": 240,
772
+ "endLine": 262,
773
+ "params": [
774
+ "path",
775
+ "integrity",
776
+ "problems"
777
+ ]
778
+ },
779
+ {
780
+ "name": "write_markdown_report",
781
+ "startLine": 265,
782
+ "endLine": 303,
783
+ "params": [
784
+ "path",
785
+ "metrics",
786
+ "integrity"
787
+ ]
788
+ },
789
+ {
790
+ "name": "main",
791
+ "startLine": 306,
792
+ "endLine": 337,
793
+ "params": []
794
+ }
795
+ ],
796
+ "exports": [
797
+ {
798
+ "name": "parse_args",
799
+ "line": 43,
800
+ "isDefault": false
801
+ },
802
+ {
803
+ "name": "load_manifest",
804
+ "line": 52,
805
+ "isDefault": false
806
+ },
807
+ {
808
+ "name": "resolve_image",
809
+ "line": 63,
810
+ "isDefault": false
811
+ },
812
+ {
813
+ "name": "sha256",
814
+ "line": 76,
815
+ "isDefault": false
816
+ },
817
+ {
818
+ "name": "image_metrics",
819
+ "line": 84,
820
+ "isDefault": false
821
+ },
822
+ {
823
+ "name": "inspect_dataset",
824
+ "line": 107,
825
+ "isDefault": false
826
+ },
827
+ {
828
+ "name": "create_summary",
829
+ "line": 171,
830
+ "isDefault": false
831
+ },
832
+ {
833
+ "name": "thumbnail",
834
+ "line": 179,
835
+ "isDefault": false
836
+ },
837
+ {
838
+ "name": "save_grid",
839
+ "line": 184,
840
+ "isDefault": false
841
+ },
842
+ {
843
+ "name": "save_grids",
844
+ "line": 203,
845
+ "isDefault": false
846
+ },
847
+ {
848
+ "name": "save_distributions",
849
+ "line": 221,
850
+ "isDefault": false
851
+ },
852
+ {
853
+ "name": "write_integrity_report",
854
+ "line": 240,
855
+ "isDefault": false
856
+ },
857
+ {
858
+ "name": "write_markdown_report",
859
+ "line": 265,
860
+ "isDefault": false
861
+ },
862
+ {
863
+ "name": "main",
864
+ "line": 306,
865
+ "isDefault": false
866
+ }
867
+ ],
868
+ "callGraph": [
869
+ {
870
+ "caller": "parse_args",
871
+ "callee": "argparse.ArgumentParser",
872
+ "lineNumber": 44
873
+ },
874
+ {
875
+ "caller": "parse_args",
876
+ "callee": "parser.add_argument",
877
+ "lineNumber": 45
878
+ },
879
+ {
880
+ "caller": "parse_args",
881
+ "callee": "Path",
882
+ "lineNumber": 45
883
+ },
884
+ {
885
+ "caller": "parse_args",
886
+ "callee": "parser.add_argument",
887
+ "lineNumber": 46
888
+ },
889
+ {
890
+ "caller": "parse_args",
891
+ "callee": "Path",
892
+ "lineNumber": 46
893
+ },
894
+ {
895
+ "caller": "parse_args",
896
+ "callee": "parser.add_argument",
897
+ "lineNumber": 47
898
+ },
899
+ {
900
+ "caller": "parse_args",
901
+ "callee": "parser.add_argument",
902
+ "lineNumber": 48
903
+ },
904
+ {
905
+ "caller": "parse_args",
906
+ "callee": "parser.parse_args",
907
+ "lineNumber": 49
908
+ },
909
+ {
910
+ "caller": "load_manifest",
911
+ "callee": "path.open",
912
+ "lineNumber": 53
913
+ },
914
+ {
915
+ "caller": "load_manifest",
916
+ "callee": "json.load",
917
+ "lineNumber": 54
918
+ },
919
+ {
920
+ "caller": "load_manifest",
921
+ "callee": "isinstance",
922
+ "lineNumber": 55
923
+ },
924
+ {
925
+ "caller": "load_manifest",
926
+ "callee": "ValueError",
927
+ "lineNumber": 56
928
+ },
929
+ {
930
+ "caller": "load_manifest",
931
+ "callee": "enumerate",
932
+ "lineNumber": 57
933
+ },
934
+ {
935
+ "caller": "load_manifest",
936
+ "callee": "isinstance",
937
+ "lineNumber": 58
938
+ },
939
+ {
940
+ "caller": "load_manifest",
941
+ "callee": "isinstance",
942
+ "lineNumber": 58
943
+ },
944
+ {
945
+ "caller": "load_manifest",
946
+ "callee": "row.get",
947
+ "lineNumber": 58
948
+ },
949
+ {
950
+ "caller": "load_manifest",
951
+ "callee": "isinstance",
952
+ "lineNumber": 58
953
+ },
954
+ {
955
+ "caller": "load_manifest",
956
+ "callee": "row.get",
957
+ "lineNumber": 58
958
+ },
959
+ {
960
+ "caller": "load_manifest",
961
+ "callee": "ValueError",
962
+ "lineNumber": 59
963
+ },
964
+ {
965
+ "caller": "resolve_image",
966
+ "callee": "Path",
967
+ "lineNumber": 64
968
+ },
969
+ {
970
+ "caller": "resolve_image",
971
+ "callee": "candidate.is_file",
972
+ "lineNumber": 71
973
+ },
974
+ {
975
+ "caller": "resolve_image",
976
+ "callee": "candidate.resolve",
977
+ "lineNumber": 72
978
+ },
979
+ {
980
+ "caller": "resolve_image",
981
+ "callee": "candidates[0].resolve",
982
+ "lineNumber": 73
983
+ },
984
+ {
985
+ "caller": "sha256",
986
+ "callee": "hashlib.sha256",
987
+ "lineNumber": 77
988
+ },
989
+ {
990
+ "caller": "sha256",
991
+ "callee": "path.open",
992
+ "lineNumber": 78
993
+ },
994
+ {
995
+ "caller": "sha256",
996
+ "callee": "iter",
997
+ "lineNumber": 79
998
+ },
999
+ {
1000
+ "caller": "sha256",
1001
+ "callee": "handle.read",
1002
+ "lineNumber": 79
1003
+ },
1004
+ {
1005
+ "caller": "sha256",
1006
+ "callee": "digest.update",
1007
+ "lineNumber": 80
1008
+ },
1009
+ {
1010
+ "caller": "sha256",
1011
+ "callee": "digest.hexdigest",
1012
+ "lineNumber": 81
1013
+ },
1014
+ {
1015
+ "caller": "image_metrics",
1016
+ "callee": "cv2.cvtColor",
1017
+ "lineNumber": 85
1018
+ },
1019
+ {
1020
+ "caller": "image_metrics",
1021
+ "callee": "np.bincount(gray.ravel(), minlength=256).astype",
1022
+ "lineNumber": 86
1023
+ },
1024
+ {
1025
+ "caller": "image_metrics",
1026
+ "callee": "np.bincount",
1027
+ "lineNumber": 86
1028
+ },
1029
+ {
1030
+ "caller": "image_metrics",
1031
+ "callee": "gray.ravel",
1032
+ "lineNumber": 86
1033
+ },
1034
+ {
1035
+ "caller": "image_metrics",
1036
+ "callee": "cv2.GaussianBlur",
1037
+ "lineNumber": 88
1038
+ },
1039
+ {
1040
+ "caller": "image_metrics",
1041
+ "callee": "cv2.Canny",
1042
+ "lineNumber": 89
1043
+ },
1044
+ {
1045
+ "caller": "image_metrics",
1046
+ "callee": "float",
1047
+ "lineNumber": 91
1048
+ },
1049
+ {
1050
+ "caller": "image_metrics",
1051
+ "callee": "gray.mean",
1052
+ "lineNumber": 91
1053
+ },
1054
+ {
1055
+ "caller": "image_metrics",
1056
+ "callee": "float",
1057
+ "lineNumber": 92
1058
+ },
1059
+ {
1060
+ "caller": "image_metrics",
1061
+ "callee": "gray.std",
1062
+ "lineNumber": 92
1063
+ },
1064
+ {
1065
+ "caller": "image_metrics",
1066
+ "callee": "float",
1067
+ "lineNumber": 93
1068
+ },
1069
+ {
1070
+ "caller": "image_metrics",
1071
+ "callee": "rgb[..., 0].mean",
1072
+ "lineNumber": 93
1073
+ },
1074
+ {
1075
+ "caller": "image_metrics",
1076
+ "callee": "float",
1077
+ "lineNumber": 94
1078
+ },
1079
+ {
1080
+ "caller": "image_metrics",
1081
+ "callee": "rgb[..., 0].std",
1082
+ "lineNumber": 94
1083
+ },
1084
+ {
1085
+ "caller": "image_metrics",
1086
+ "callee": "float",
1087
+ "lineNumber": 95
1088
+ },
1089
+ {
1090
+ "caller": "image_metrics",
1091
+ "callee": "rgb[..., 1].mean",
1092
+ "lineNumber": 95
1093
+ },
1094
+ {
1095
+ "caller": "image_metrics",
1096
+ "callee": "float",
1097
+ "lineNumber": 96
1098
+ },
1099
+ {
1100
+ "caller": "image_metrics",
1101
+ "callee": "rgb[..., 1].std",
1102
+ "lineNumber": 96
1103
+ },
1104
+ {
1105
+ "caller": "image_metrics",
1106
+ "callee": "float",
1107
+ "lineNumber": 97
1108
+ },
1109
+ {
1110
+ "caller": "image_metrics",
1111
+ "callee": "rgb[..., 2].mean",
1112
+ "lineNumber": 97
1113
+ },
1114
+ {
1115
+ "caller": "image_metrics",
1116
+ "callee": "float",
1117
+ "lineNumber": 98
1118
+ },
1119
+ {
1120
+ "caller": "image_metrics",
1121
+ "callee": "rgb[..., 2].std",
1122
+ "lineNumber": 98
1123
+ },
1124
+ {
1125
+ "caller": "image_metrics",
1126
+ "callee": "float",
1127
+ "lineNumber": 99
1128
+ },
1129
+ {
1130
+ "caller": "image_metrics",
1131
+ "callee": "cv2.Laplacian(gray, cv2.CV_64F).var",
1132
+ "lineNumber": 99
1133
+ },
1134
+ {
1135
+ "caller": "image_metrics",
1136
+ "callee": "cv2.Laplacian",
1137
+ "lineNumber": 99
1138
+ },
1139
+ {
1140
+ "caller": "image_metrics",
1141
+ "callee": "float",
1142
+ "lineNumber": 100
1143
+ },
1144
+ {
1145
+ "caller": "image_metrics",
1146
+ "callee": "(probabilities * np.log2(probabilities)).sum",
1147
+ "lineNumber": 100
1148
+ },
1149
+ {
1150
+ "caller": "image_metrics",
1151
+ "callee": "np.log2",
1152
+ "lineNumber": 100
1153
+ },
1154
+ {
1155
+ "caller": "image_metrics",
1156
+ "callee": "float",
1157
+ "lineNumber": 101
1158
+ },
1159
+ {
1160
+ "caller": "image_metrics",
1161
+ "callee": "np.mean",
1162
+ "lineNumber": 101
1163
+ },
1164
+ {
1165
+ "caller": "image_metrics",
1166
+ "callee": "np.abs",
1167
+ "lineNumber": 101
1168
+ },
1169
+ {
1170
+ "caller": "image_metrics",
1171
+ "callee": "gray.astype",
1172
+ "lineNumber": 101
1173
+ },
1174
+ {
1175
+ "caller": "image_metrics",
1176
+ "callee": "blurred.astype",
1177
+ "lineNumber": 101
1178
+ },
1179
+ {
1180
+ "caller": "image_metrics",
1181
+ "callee": "float",
1182
+ "lineNumber": 102
1183
+ },
1184
+ {
1185
+ "caller": "image_metrics",
1186
+ "callee": "np.mean",
1187
+ "lineNumber": 102
1188
+ },
1189
+ {
1190
+ "caller": "image_metrics",
1191
+ "callee": "np.all",
1192
+ "lineNumber": 102
1193
+ },
1194
+ {
1195
+ "caller": "image_metrics",
1196
+ "callee": "float",
1197
+ "lineNumber": 103
1198
+ },
1199
+ {
1200
+ "caller": "image_metrics",
1201
+ "callee": "np.mean",
1202
+ "lineNumber": 103
1203
+ },
1204
+ {
1205
+ "caller": "inspect_dataset",
1206
+ "callee": "defaultdict",
1207
+ "lineNumber": 111
1208
+ },
1209
+ {
1210
+ "caller": "inspect_dataset",
1211
+ "callee": "MANIFESTS.items",
1212
+ "lineNumber": 113
1213
+ },
1214
+ {
1215
+ "caller": "inspect_dataset",
1216
+ "callee": "load_manifest",
1217
+ "lineNumber": 115
1218
+ },
1219
+ {
1220
+ "caller": "inspect_dataset",
1221
+ "callee": "len",
1222
+ "lineNumber": 119
1223
+ },
1224
+ {
1225
+ "caller": "inspect_dataset",
1226
+ "callee": "len",
1227
+ "lineNumber": 120
1228
+ },
1229
+ {
1230
+ "caller": "inspect_dataset",
1231
+ "callee": "set",
1232
+ "lineNumber": 120
1233
+ },
1234
+ {
1235
+ "caller": "inspect_dataset",
1236
+ "callee": "len",
1237
+ "lineNumber": 121
1238
+ },
1239
+ {
1240
+ "caller": "inspect_dataset",
1241
+ "callee": "set",
1242
+ "lineNumber": 121
1243
+ },
1244
+ {
1245
+ "caller": "inspect_dataset",
1246
+ "callee": "sorted",
1247
+ "lineNumber": 122
1248
+ },
1249
+ {
1250
+ "caller": "inspect_dataset",
1251
+ "callee": "Counter(ids).items",
1252
+ "lineNumber": 122
1253
+ },
1254
+ {
1255
+ "caller": "inspect_dataset",
1256
+ "callee": "Counter",
1257
+ "lineNumber": 122
1258
+ },
1259
+ {
1260
+ "caller": "inspect_dataset",
1261
+ "callee": "sorted",
1262
+ "lineNumber": 123
1263
+ },
1264
+ {
1265
+ "caller": "inspect_dataset",
1266
+ "callee": "Counter(paths).items",
1267
+ "lineNumber": 123
1268
+ },
1269
+ {
1270
+ "caller": "inspect_dataset",
1271
+ "callee": "Counter",
1272
+ "lineNumber": 123
1273
+ },
1274
+ {
1275
+ "caller": "inspect_dataset",
1276
+ "callee": "resolve_image",
1277
+ "lineNumber": 130
1278
+ },
1279
+ {
1280
+ "caller": "inspect_dataset",
1281
+ "callee": "path.is_file",
1282
+ "lineNumber": 131
1283
+ },
1284
+ {
1285
+ "caller": "inspect_dataset",
1286
+ "callee": "split_info[\"missing\"].append",
1287
+ "lineNumber": 132
1288
+ },
1289
+ {
1290
+ "caller": "inspect_dataset",
1291
+ "callee": "str",
1292
+ "lineNumber": 132
1293
+ },
1294
+ {
1295
+ "caller": "inspect_dataset",
1296
+ "callee": "problems.append",
1297
+ "lineNumber": 133
1298
+ },
1299
+ {
1300
+ "caller": "inspect_dataset",
1301
+ "callee": "Image.open",
1302
+ "lineNumber": 136
1303
+ },
1304
+ {
1305
+ "caller": "inspect_dataset",
1306
+ "callee": "image.load",
1307
+ "lineNumber": 137
1308
+ },
1309
+ {
1310
+ "caller": "inspect_dataset",
1311
+ "callee": "np.asarray",
1312
+ "lineNumber": 139
1313
+ },
1314
+ {
1315
+ "caller": "inspect_dataset",
1316
+ "callee": "image.convert",
1317
+ "lineNumber": 139
1318
+ },
1319
+ {
1320
+ "caller": "inspect_dataset",
1321
+ "callee": "sha256",
1322
+ "lineNumber": 140
1323
+ },
1324
+ {
1325
+ "caller": "inspect_dataset",
1326
+ "callee": "hashes[digest].append",
1327
+ "lineNumber": 141
1328
+ },
1329
+ {
1330
+ "caller": "inspect_dataset",
1331
+ "callee": "records.append",
1332
+ "lineNumber": 142
1333
+ },
1334
+ {
1335
+ "caller": "inspect_dataset",
1336
+ "callee": "str",
1337
+ "lineNumber": 147
1338
+ },
1339
+ {
1340
+ "caller": "inspect_dataset",
1341
+ "callee": "path.stat",
1342
+ "lineNumber": 153
1343
+ },
1344
+ {
1345
+ "caller": "inspect_dataset",
1346
+ "callee": "image_metrics",
1347
+ "lineNumber": 154
1348
+ },
1349
+ {
1350
+ "caller": "inspect_dataset",
1351
+ "callee": "type",
1352
+ "lineNumber": 158
1353
+ },
1354
+ {
1355
+ "caller": "inspect_dataset",
1356
+ "callee": "split_info[\"broken\"].append",
1357
+ "lineNumber": 159
1358
+ },
1359
+ {
1360
+ "caller": "inspect_dataset",
1361
+ "callee": "problems.append",
1362
+ "lineNumber": 160
1363
+ },
1364
+ {
1365
+ "caller": "inspect_dataset",
1366
+ "callee": "problems.append",
1367
+ "lineNumber": 163
1368
+ },
1369
+ {
1370
+ "caller": "inspect_dataset",
1371
+ "callee": "problems.append",
1372
+ "lineNumber": 165
1373
+ },
1374
+ {
1375
+ "caller": "inspect_dataset",
1376
+ "callee": "hashes.items",
1377
+ "lineNumber": 167
1378
+ },
1379
+ {
1380
+ "caller": "inspect_dataset",
1381
+ "callee": "len",
1382
+ "lineNumber": 167
1383
+ },
1384
+ {
1385
+ "caller": "inspect_dataset",
1386
+ "callee": "pd.DataFrame",
1387
+ "lineNumber": 168
1388
+ },
1389
+ {
1390
+ "caller": "create_summary",
1391
+ "callee": "metrics.groupby(\"split\")[numeric].agg",
1392
+ "lineNumber": 176
1393
+ },
1394
+ {
1395
+ "caller": "create_summary",
1396
+ "callee": "metrics.groupby",
1397
+ "lineNumber": 176
1398
+ },
1399
+ {
1400
+ "caller": "thumbnail",
1401
+ "callee": "Image.open",
1402
+ "lineNumber": 180
1403
+ },
1404
+ {
1405
+ "caller": "thumbnail",
1406
+ "callee": "ImageOps.fit",
1407
+ "lineNumber": 181
1408
+ },
1409
+ {
1410
+ "caller": "thumbnail",
1411
+ "callee": "image.convert",
1412
+ "lineNumber": 181
1413
+ },
1414
+ {
1415
+ "caller": "save_grid",
1416
+ "callee": "rows.head",
1417
+ "lineNumber": 185
1418
+ },
1419
+ {
1420
+ "caller": "save_grid",
1421
+ "callee": "min",
1422
+ "lineNumber": 188
1423
+ },
1424
+ {
1425
+ "caller": "save_grid",
1426
+ "callee": "len",
1427
+ "lineNumber": 188
1428
+ },
1429
+ {
1430
+ "caller": "save_grid",
1431
+ "callee": "math.ceil",
1432
+ "lineNumber": 190
1433
+ },
1434
+ {
1435
+ "caller": "save_grid",
1436
+ "callee": "len",
1437
+ "lineNumber": 190
1438
+ },
1439
+ {
1440
+ "caller": "save_grid",
1441
+ "callee": "Image.new",
1442
+ "lineNumber": 191
1443
+ },
1444
+ {
1445
+ "caller": "save_grid",
1446
+ "callee": "ImageDraw.Draw",
1447
+ "lineNumber": 192
1448
+ },
1449
+ {
1450
+ "caller": "save_grid",
1451
+ "callee": "draw.text",
1452
+ "lineNumber": 193
1453
+ },
1454
+ {
1455
+ "caller": "save_grid",
1456
+ "callee": "enumerate",
1457
+ "lineNumber": 194
1458
+ },
1459
+ {
1460
+ "caller": "save_grid",
1461
+ "callee": "rows.iterrows",
1462
+ "lineNumber": 194
1463
+ },
1464
+ {
1465
+ "caller": "save_grid",
1466
+ "callee": "canvas.paste",
1467
+ "lineNumber": 197
1468
+ },
1469
+ {
1470
+ "caller": "save_grid",
1471
+ "callee": "thumbnail",
1472
+ "lineNumber": 197
1473
+ },
1474
+ {
1475
+ "caller": "save_grid",
1476
+ "callee": "draw.text",
1477
+ "lineNumber": 198
1478
+ },
1479
+ {
1480
+ "caller": "save_grid",
1481
+ "callee": "str",
1482
+ "lineNumber": 198
1483
+ },
1484
+ {
1485
+ "caller": "save_grid",
1486
+ "callee": "draw.text",
1487
+ "lineNumber": 199
1488
+ },
1489
+ {
1490
+ "caller": "save_grid",
1491
+ "callee": "str",
1492
+ "lineNumber": 199
1493
+ },
1494
+ {
1495
+ "caller": "save_grid",
1496
+ "callee": "canvas.save",
1497
+ "lineNumber": 200
1498
+ },
1499
+ {
1500
+ "caller": "save_grids",
1501
+ "callee": "subset.sample",
1502
+ "lineNumber": 206
1503
+ },
1504
+ {
1505
+ "caller": "save_grids",
1506
+ "callee": "min",
1507
+ "lineNumber": 206
1508
+ },
1509
+ {
1510
+ "caller": "save_grids",
1511
+ "callee": "len",
1512
+ "lineNumber": 206
1513
+ },
1514
+ {
1515
+ "caller": "save_grids",
1516
+ "callee": "save_grid",
1517
+ "lineNumber": 207
1518
+ },
1519
+ {
1520
+ "caller": "save_grids",
1521
+ "callee": "extremes.items",
1522
+ "lineNumber": 216
1523
+ },
1524
+ {
1525
+ "caller": "save_grids",
1526
+ "callee": "metrics.sort_values",
1527
+ "lineNumber": 217
1528
+ },
1529
+ {
1530
+ "caller": "save_grids",
1531
+ "callee": "save_grid",
1532
+ "lineNumber": 218
1533
+ },
1534
+ {
1535
+ "caller": "save_grids",
1536
+ "callee": "name.replace(\"_\", \" \").title",
1537
+ "lineNumber": 218
1538
+ },
1539
+ {
1540
+ "caller": "save_grids",
1541
+ "callee": "name.replace",
1542
+ "lineNumber": 218
1543
+ },
1544
+ {
1545
+ "caller": "save_distributions",
1546
+ "callee": "plt.subplots",
1547
+ "lineNumber": 222
1548
+ },
1549
+ {
1550
+ "caller": "save_distributions",
1551
+ "callee": "axes.ravel",
1552
+ "lineNumber": 223
1553
+ },
1554
+ {
1555
+ "caller": "save_distributions",
1556
+ "callee": "zip",
1557
+ "lineNumber": 225
1558
+ },
1559
+ {
1560
+ "caller": "save_distributions",
1561
+ "callee": "metrics.loc[metrics[\"split\"] == split, metric].dropna",
1562
+ "lineNumber": 227
1563
+ },
1564
+ {
1565
+ "caller": "save_distributions",
1566
+ "callee": "axis.hist",
1567
+ "lineNumber": 228
1568
+ },
1569
+ {
1570
+ "caller": "save_distributions",
1571
+ "callee": "axis.set_title",
1572
+ "lineNumber": 229
1573
+ },
1574
+ {
1575
+ "caller": "save_distributions",
1576
+ "callee": "metric.replace",
1577
+ "lineNumber": 229
1578
+ },
1579
+ {
1580
+ "caller": "save_distributions",
1581
+ "callee": "axis.grid",
1582
+ "lineNumber": 230
1583
+ },
1584
+ {
1585
+ "caller": "save_distributions",
1586
+ "callee": "len",
1587
+ "lineNumber": 231
1588
+ },
1589
+ {
1590
+ "caller": "save_distributions",
1591
+ "callee": "axis.axis",
1592
+ "lineNumber": 232
1593
+ },
1594
+ {
1595
+ "caller": "save_distributions",
1596
+ "callee": "axes[0].legend",
1597
+ "lineNumber": 233
1598
+ },
1599
+ {
1600
+ "caller": "save_distributions",
1601
+ "callee": "figure.suptitle",
1602
+ "lineNumber": 234
1603
+ },
1604
+ {
1605
+ "caller": "save_distributions",
1606
+ "callee": "figure.tight_layout",
1607
+ "lineNumber": 235
1608
+ },
1609
+ {
1610
+ "caller": "save_distributions",
1611
+ "callee": "figure.savefig",
1612
+ "lineNumber": 236
1613
+ },
1614
+ {
1615
+ "caller": "save_distributions",
1616
+ "callee": "plt.close",
1617
+ "lineNumber": 237
1618
+ },
1619
+ {
1620
+ "caller": "write_integrity_report",
1621
+ "callee": "integrity[\"splits\"].items",
1622
+ "lineNumber": 242
1623
+ },
1624
+ {
1625
+ "caller": "write_integrity_report",
1626
+ "callee": "lines.extend",
1627
+ "lineNumber": 243
1628
+ },
1629
+ {
1630
+ "caller": "write_integrity_report",
1631
+ "callee": "len",
1632
+ "lineNumber": 250
1633
+ },
1634
+ {
1635
+ "caller": "write_integrity_report",
1636
+ "callee": "len",
1637
+ "lineNumber": 251
1638
+ },
1639
+ {
1640
+ "caller": "write_integrity_report",
1641
+ "callee": "lines.extend",
1642
+ "lineNumber": 256
1643
+ },
1644
+ {
1645
+ "caller": "write_integrity_report",
1646
+ "callee": "lines.extend",
1647
+ "lineNumber": 258
1648
+ },
1649
+ {
1650
+ "caller": "write_integrity_report",
1651
+ "callee": "', '.join",
1652
+ "lineNumber": 258
1653
+ },
1654
+ {
1655
+ "caller": "write_integrity_report",
1656
+ "callee": "integrity[\"hash_groups\"].items",
1657
+ "lineNumber": 258
1658
+ },
1659
+ {
1660
+ "caller": "write_integrity_report",
1661
+ "callee": "lines.append",
1662
+ "lineNumber": 260
1663
+ },
1664
+ {
1665
+ "caller": "write_integrity_report",
1666
+ "callee": "lines.extend",
1667
+ "lineNumber": 261
1668
+ },
1669
+ {
1670
+ "caller": "write_integrity_report",
1671
+ "callee": "path.write_text",
1672
+ "lineNumber": 262
1673
+ },
1674
+ {
1675
+ "caller": "write_integrity_report",
1676
+ "callee": "\"\\n\".join",
1677
+ "lineNumber": 262
1678
+ },
1679
+ {
1680
+ "caller": "write_markdown_report",
1681
+ "callee": "metrics.groupby(\"split\").size().to_dict",
1682
+ "lineNumber": 266
1683
+ },
1684
+ {
1685
+ "caller": "write_markdown_report",
1686
+ "callee": "metrics.groupby(\"split\").size",
1687
+ "lineNumber": 266
1688
+ },
1689
+ {
1690
+ "caller": "write_markdown_report",
1691
+ "callee": "metrics.groupby",
1692
+ "lineNumber": 266
1693
+ },
1694
+ {
1695
+ "caller": "write_markdown_report",
1696
+ "callee": "metrics.groupby(\"split\")[PLOT_METRICS].median().reindex",
1697
+ "lineNumber": 267
1698
+ },
1699
+ {
1700
+ "caller": "write_markdown_report",
1701
+ "callee": "metrics.groupby(\"split\")[PLOT_METRICS].median",
1702
+ "lineNumber": 267
1703
+ },
1704
+ {
1705
+ "caller": "write_markdown_report",
1706
+ "callee": "metrics.groupby",
1707
+ "lineNumber": 267
1708
+ },
1709
+ {
1710
+ "caller": "write_markdown_report",
1711
+ "callee": "len",
1712
+ "lineNumber": 273
1713
+ },
1714
+ {
1715
+ "caller": "write_markdown_report",
1716
+ "callee": "counts.get",
1717
+ "lineNumber": 274
1718
+ },
1719
+ {
1720
+ "caller": "write_markdown_report",
1721
+ "callee": "len",
1722
+ "lineNumber": 275
1723
+ },
1724
+ {
1725
+ "caller": "write_markdown_report",
1726
+ "callee": "medians.round(4).to_markdown",
1727
+ "lineNumber": 279
1728
+ },
1729
+ {
1730
+ "caller": "write_markdown_report",
1731
+ "callee": "medians.round",
1732
+ "lineNumber": 279
1733
+ },
1734
+ {
1735
+ "caller": "write_markdown_report",
1736
+ "callee": "abs",
1737
+ "lineNumber": 288
1738
+ },
1739
+ {
1740
+ "caller": "write_markdown_report",
1741
+ "callee": "float",
1742
+ "lineNumber": 288
1743
+ },
1744
+ {
1745
+ "caller": "write_markdown_report",
1746
+ "callee": "lines.append",
1747
+ "lineNumber": 289
1748
+ },
1749
+ {
1750
+ "caller": "write_markdown_report",
1751
+ "callee": "lines.extend",
1752
+ "lineNumber": 290
1753
+ },
1754
+ {
1755
+ "caller": "write_markdown_report",
1756
+ "callee": "path.write_text",
1757
+ "lineNumber": 303
1758
+ },
1759
+ {
1760
+ "caller": "write_markdown_report",
1761
+ "callee": "\"\\n\".join",
1762
+ "lineNumber": 303
1763
+ },
1764
+ {
1765
+ "caller": "main",
1766
+ "callee": "parse_args",
1767
+ "lineNumber": 307
1768
+ },
1769
+ {
1770
+ "caller": "main",
1771
+ "callee": "args.data_root.resolve",
1772
+ "lineNumber": 308
1773
+ },
1774
+ {
1775
+ "caller": "main",
1776
+ "callee": "args.output_dir.resolve",
1777
+ "lineNumber": 309
1778
+ },
1779
+ {
1780
+ "caller": "main",
1781
+ "callee": "print",
1782
+ "lineNumber": 311
1783
+ },
1784
+ {
1785
+ "caller": "main",
1786
+ "callee": "str",
1787
+ "lineNumber": 313
1788
+ },
1789
+ {
1790
+ "caller": "main",
1791
+ "callee": "MANIFESTS.values",
1792
+ "lineNumber": 313
1793
+ },
1794
+ {
1795
+ "caller": "main",
1796
+ "callee": "(data_root / relative).is_file",
1797
+ "lineNumber": 313
1798
+ },
1799
+ {
1800
+ "caller": "main",
1801
+ "callee": "print",
1802
+ "lineNumber": 315
1803
+ },
1804
+ {
1805
+ "caller": "main",
1806
+ "callee": "\"\\n \".join",
1807
+ "lineNumber": 315
1808
+ },
1809
+ {
1810
+ "caller": "main",
1811
+ "callee": "output_dir.mkdir",
1812
+ "lineNumber": 318
1813
+ },
1814
+ {
1815
+ "caller": "main",
1816
+ "callee": "inspect_dataset",
1817
+ "lineNumber": 320
1818
+ },
1819
+ {
1820
+ "caller": "main",
1821
+ "callee": "print",
1822
+ "lineNumber": 322
1823
+ },
1824
+ {
1825
+ "caller": "main",
1826
+ "callee": "metrics.to_csv",
1827
+ "lineNumber": 325
1828
+ },
1829
+ {
1830
+ "caller": "main",
1831
+ "callee": "create_summary(metrics).to_csv",
1832
+ "lineNumber": 327
1833
+ },
1834
+ {
1835
+ "caller": "main",
1836
+ "callee": "create_summary",
1837
+ "lineNumber": 327
1838
+ },
1839
+ {
1840
+ "caller": "main",
1841
+ "callee": "save_grids",
1842
+ "lineNumber": 328
1843
+ },
1844
+ {
1845
+ "caller": "main",
1846
+ "callee": "save_distributions",
1847
+ "lineNumber": 329
1848
+ },
1849
+ {
1850
+ "caller": "main",
1851
+ "callee": "write_markdown_report",
1852
+ "lineNumber": 330
1853
+ },
1854
+ {
1855
+ "caller": "main",
1856
+ "callee": "write_integrity_report",
1857
+ "lineNumber": 331
1858
+ },
1859
+ {
1860
+ "caller": "main",
1861
+ "callee": "print",
1862
+ "lineNumber": 333
1863
+ },
1864
+ {
1865
+ "caller": "main",
1866
+ "callee": "len",
1867
+ "lineNumber": 333
1868
+ },
1869
+ {
1870
+ "caller": "main",
1871
+ "callee": "print",
1872
+ "lineNumber": 335
1873
+ },
1874
+ {
1875
+ "caller": "main",
1876
+ "callee": "len",
1877
+ "lineNumber": 335
1878
+ }
1879
+ ],
1880
+ "metrics": {
1881
+ "importCount": 0,
1882
+ "exportCount": 14,
1883
+ "functionCount": 14,
1884
+ "classCount": 0
1885
+ }
1886
+ },
1887
+ {
1888
+ "path": "notebook324f4a11f8_upgraded.ipynb",
1889
+ "language": "ipynb",
1890
+ "fileCategory": "code",
1891
+ "totalLines": 3255,
1892
+ "nonEmptyLines": 3255,
1893
+ "metrics": {}
1894
+ },
1895
+ {
1896
+ "path": "retrieval_advanced.py",
1897
+ "language": "python",
1898
+ "fileCategory": "code",
1899
+ "totalLines": 399,
1900
+ "nonEmptyLines": 334,
1901
+ "functions": [
1902
+ {
1903
+ "name": "load_manifest",
1904
+ "startLine": 50,
1905
+ "endLine": 58,
1906
+ "params": [
1907
+ "path"
1908
+ ]
1909
+ },
1910
+ {
1911
+ "name": "resolve_image_path",
1912
+ "startLine": 61,
1913
+ "endLine": 67,
1914
+ "params": [
1915
+ "manifest",
1916
+ "relative_path"
1917
+ ]
1918
+ },
1919
+ {
1920
+ "name": "apply_d4",
1921
+ "startLine": 80,
1922
+ "endLine": 93,
1923
+ "params": [
1924
+ "image",
1925
+ "view"
1926
+ ]
1927
+ },
1928
+ {
1929
+ "name": "cache_key",
1930
+ "startLine": 114,
1931
+ "endLine": 118,
1932
+ "params": [
1933
+ "manifest",
1934
+ "split",
1935
+ "view"
1936
+ ]
1937
+ },
1938
+ {
1939
+ "name": "cache_path",
1940
+ "startLine": 121,
1941
+ "endLine": 123,
1942
+ "params": [
1943
+ "manifest",
1944
+ "split",
1945
+ "view"
1946
+ ]
1947
+ },
1948
+ {
1949
+ "name": "split_global_dense",
1950
+ "startLine": 126,
1951
+ "endLine": 146,
1952
+ "params": [
1953
+ "model",
1954
+ "raw_features"
1955
+ ]
1956
+ },
1957
+ {
1958
+ "name": "extract_and_cache",
1959
+ "startLine": 150,
1960
+ "endLine": 186,
1961
+ "params": [
1962
+ "model",
1963
+ "transform",
1964
+ "ids",
1965
+ "paths",
1966
+ "manifest",
1967
+ "split",
1968
+ "view"
1969
+ ]
1970
+ },
1971
+ {
1972
+ "name": "make_submission",
1973
+ "startLine": 247,
1974
+ "endLine": 258,
1975
+ "params": [
1976
+ "ranking",
1977
+ "output"
1978
+ ]
1979
+ },
1980
+ {
1981
+ "name": "row_minmax",
1982
+ "startLine": 266,
1983
+ "endLine": 268,
1984
+ "params": [
1985
+ "values"
1986
+ ]
1987
+ },
1988
+ {
1989
+ "name": "local_features",
1990
+ "startLine": 297,
1991
+ "endLine": 304,
1992
+ "params": [
1993
+ "path"
1994
+ ]
1995
+ },
1996
+ {
1997
+ "name": "geometric_score",
1998
+ "startLine": 307,
1999
+ "endLine": 322,
2000
+ "params": [
2001
+ "query_feature",
2002
+ "gallery_feature"
2003
+ ]
2004
+ },
2005
+ {
2006
+ "name": "overlap",
2007
+ "startLine": 349,
2008
+ "endLine": 350,
2009
+ "params": [
2010
+ "left",
2011
+ "right",
2012
+ "k"
2013
+ ]
2014
+ },
2015
+ {
2016
+ "name": "show_top1_comparison",
2017
+ "startLine": 379,
2018
+ "endLine": 396,
2019
+ "params": [
2020
+ "indices"
2021
+ ]
2022
+ }
2023
+ ],
2024
+ "classes": [
2025
+ {
2026
+ "name": "ImageDataset",
2027
+ "startLine": 96,
2028
+ "endLine": 110,
2029
+ "methods": [
2030
+ "__init__",
2031
+ "__len__",
2032
+ "__getitem__"
2033
+ ],
2034
+ "properties": []
2035
+ }
2036
+ ],
2037
+ "exports": [
2038
+ {
2039
+ "name": "load_manifest",
2040
+ "line": 50,
2041
+ "isDefault": false
2042
+ },
2043
+ {
2044
+ "name": "resolve_image_path",
2045
+ "line": 61,
2046
+ "isDefault": false
2047
+ },
2048
+ {
2049
+ "name": "apply_d4",
2050
+ "line": 80,
2051
+ "isDefault": false
2052
+ },
2053
+ {
2054
+ "name": "ImageDataset",
2055
+ "line": 96,
2056
+ "isDefault": false
2057
+ },
2058
+ {
2059
+ "name": "cache_key",
2060
+ "line": 114,
2061
+ "isDefault": false
2062
+ },
2063
+ {
2064
+ "name": "cache_path",
2065
+ "line": 121,
2066
+ "isDefault": false
2067
+ },
2068
+ {
2069
+ "name": "split_global_dense",
2070
+ "line": 126,
2071
+ "isDefault": false
2072
+ },
2073
+ {
2074
+ "name": "extract_and_cache",
2075
+ "line": 149,
2076
+ "isDefault": false
2077
+ },
2078
+ {
2079
+ "name": "make_submission",
2080
+ "line": 247,
2081
+ "isDefault": false
2082
+ },
2083
+ {
2084
+ "name": "row_minmax",
2085
+ "line": 266,
2086
+ "isDefault": false
2087
+ },
2088
+ {
2089
+ "name": "local_features",
2090
+ "line": 297,
2091
+ "isDefault": false
2092
+ },
2093
+ {
2094
+ "name": "geometric_score",
2095
+ "line": 307,
2096
+ "isDefault": false
2097
+ },
2098
+ {
2099
+ "name": "overlap",
2100
+ "line": 349,
2101
+ "isDefault": false
2102
+ },
2103
+ {
2104
+ "name": "show_top1_comparison",
2105
+ "line": 379,
2106
+ "isDefault": false
2107
+ }
2108
+ ],
2109
+ "callGraph": [
2110
+ {
2111
+ "caller": "load_manifest",
2112
+ "callee": "path.open",
2113
+ "lineNumber": 51
2114
+ },
2115
+ {
2116
+ "caller": "load_manifest",
2117
+ "callee": "json.load",
2118
+ "lineNumber": 52
2119
+ },
2120
+ {
2121
+ "caller": "load_manifest",
2122
+ "callee": "isinstance",
2123
+ "lineNumber": 53
2124
+ },
2125
+ {
2126
+ "caller": "load_manifest",
2127
+ "callee": "ValueError",
2128
+ "lineNumber": 54
2129
+ },
2130
+ {
2131
+ "caller": "load_manifest",
2132
+ "callee": "enumerate",
2133
+ "lineNumber": 55
2134
+ },
2135
+ {
2136
+ "caller": "load_manifest",
2137
+ "callee": "isinstance",
2138
+ "lineNumber": 56
2139
+ },
2140
+ {
2141
+ "caller": "load_manifest",
2142
+ "callee": "row.keys",
2143
+ "lineNumber": 56
2144
+ },
2145
+ {
2146
+ "caller": "load_manifest",
2147
+ "callee": "ValueError",
2148
+ "lineNumber": 57
2149
+ },
2150
+ {
2151
+ "caller": "resolve_image_path",
2152
+ "callee": "Path",
2153
+ "lineNumber": 62
2154
+ },
2155
+ {
2156
+ "caller": "resolve_image_path",
2157
+ "callee": "candidate.is_file",
2158
+ "lineNumber": 65
2159
+ },
2160
+ {
2161
+ "caller": "resolve_image_path",
2162
+ "callee": "FileNotFoundError",
2163
+ "lineNumber": 67
2164
+ },
2165
+ {
2166
+ "caller": "apply_d4",
2167
+ "callee": "image.transpose",
2168
+ "lineNumber": 92
2169
+ },
2170
+ {
2171
+ "caller": "__len__",
2172
+ "callee": "len",
2173
+ "lineNumber": 101
2174
+ },
2175
+ {
2176
+ "caller": "__getitem__",
2177
+ "callee": "Image.open",
2178
+ "lineNumber": 104
2179
+ },
2180
+ {
2181
+ "caller": "__getitem__",
2182
+ "callee": "image.convert",
2183
+ "lineNumber": 105
2184
+ },
2185
+ {
2186
+ "caller": "__getitem__",
2187
+ "callee": "apply_d4",
2188
+ "lineNumber": 107
2189
+ },
2190
+ {
2191
+ "caller": "__getitem__",
2192
+ "callee": "self.transform",
2193
+ "lineNumber": 109
2194
+ },
2195
+ {
2196
+ "caller": "cache_key",
2197
+ "callee": "hashlib.sha256",
2198
+ "lineNumber": 115
2199
+ },
2200
+ {
2201
+ "caller": "cache_key",
2202
+ "callee": "digest.update",
2203
+ "lineNumber": 116
2204
+ },
2205
+ {
2206
+ "caller": "cache_key",
2207
+ "callee": "manifest.read_bytes",
2208
+ "lineNumber": 116
2209
+ },
2210
+ {
2211
+ "caller": "cache_key",
2212
+ "callee": "digest.update",
2213
+ "lineNumber": 117
2214
+ },
2215
+ {
2216
+ "caller": "cache_key",
2217
+ "callee": "f\"{MODEL_NAME}|{split}|{view}|dense8x8-v1\".encode",
2218
+ "lineNumber": 117
2219
+ },
2220
+ {
2221
+ "caller": "cache_key",
2222
+ "callee": "digest.hexdigest",
2223
+ "lineNumber": 118
2224
+ },
2225
+ {
2226
+ "caller": "cache_path",
2227
+ "callee": "MODEL_NAME.replace(\"/\", \"_\").replace",
2228
+ "lineNumber": 122
2229
+ },
2230
+ {
2231
+ "caller": "cache_path",
2232
+ "callee": "MODEL_NAME.replace",
2233
+ "lineNumber": 122
2234
+ },
2235
+ {
2236
+ "caller": "cache_path",
2237
+ "callee": "cache_key",
2238
+ "lineNumber": 123
2239
+ },
2240
+ {
2241
+ "caller": "split_global_dense",
2242
+ "callee": "model.forward_head",
2243
+ "lineNumber": 127
2244
+ },
2245
+ {
2246
+ "caller": "split_global_dense",
2247
+ "callee": "global_features.flatten(2).mean",
2248
+ "lineNumber": 129
2249
+ },
2250
+ {
2251
+ "caller": "split_global_dense",
2252
+ "callee": "global_features.flatten",
2253
+ "lineNumber": 129
2254
+ },
2255
+ {
2256
+ "caller": "split_global_dense",
2257
+ "callee": "int",
2258
+ "lineNumber": 134
2259
+ },
2260
+ {
2261
+ "caller": "split_global_dense",
2262
+ "callee": "getattr",
2263
+ "lineNumber": 134
2264
+ },
2265
+ {
2266
+ "caller": "split_global_dense",
2267
+ "callee": "math.isqrt",
2268
+ "lineNumber": 136
2269
+ },
2270
+ {
2271
+ "caller": "split_global_dense",
2272
+ "callee": "ValueError",
2273
+ "lineNumber": 138
2274
+ },
2275
+ {
2276
+ "caller": "split_global_dense",
2277
+ "callee": "tokens.transpose(1, 2).reshape",
2278
+ "lineNumber": 139
2279
+ },
2280
+ {
2281
+ "caller": "split_global_dense",
2282
+ "callee": "tokens.transpose",
2283
+ "lineNumber": 139
2284
+ },
2285
+ {
2286
+ "caller": "split_global_dense",
2287
+ "callee": "ValueError",
2288
+ "lineNumber": 141
2289
+ },
2290
+ {
2291
+ "caller": "split_global_dense",
2292
+ "callee": "tuple",
2293
+ "lineNumber": 141
2294
+ },
2295
+ {
2296
+ "caller": "split_global_dense",
2297
+ "callee": "min",
2298
+ "lineNumber": 144
2299
+ },
2300
+ {
2301
+ "caller": "split_global_dense",
2302
+ "callee": "min",
2303
+ "lineNumber": 144
2304
+ },
2305
+ {
2306
+ "caller": "split_global_dense",
2307
+ "callee": "F.adaptive_avg_pool2d(dense, (target_h, target_w)).flatten(2).transpose",
2308
+ "lineNumber": 145
2309
+ },
2310
+ {
2311
+ "caller": "split_global_dense",
2312
+ "callee": "F.adaptive_avg_pool2d(dense, (target_h, target_w)).flatten",
2313
+ "lineNumber": 145
2314
+ },
2315
+ {
2316
+ "caller": "split_global_dense",
2317
+ "callee": "F.adaptive_avg_pool2d",
2318
+ "lineNumber": 145
2319
+ },
2320
+ {
2321
+ "caller": "split_global_dense",
2322
+ "callee": "F.normalize",
2323
+ "lineNumber": 146
2324
+ },
2325
+ {
2326
+ "caller": "split_global_dense",
2327
+ "callee": "global_features.float",
2328
+ "lineNumber": 146
2329
+ },
2330
+ {
2331
+ "caller": "split_global_dense",
2332
+ "callee": "F.normalize",
2333
+ "lineNumber": 146
2334
+ },
2335
+ {
2336
+ "caller": "split_global_dense",
2337
+ "callee": "dense.float",
2338
+ "lineNumber": 146
2339
+ },
2340
+ {
2341
+ "caller": "extract_and_cache",
2342
+ "callee": "cache_path",
2343
+ "lineNumber": 151
2344
+ },
2345
+ {
2346
+ "caller": "extract_and_cache",
2347
+ "callee": "output.is_file",
2348
+ "lineNumber": 152
2349
+ },
2350
+ {
2351
+ "caller": "extract_and_cache",
2352
+ "callee": "torch.load",
2353
+ "lineNumber": 153
2354
+ },
2355
+ {
2356
+ "caller": "extract_and_cache",
2357
+ "callee": "print",
2358
+ "lineNumber": 155
2359
+ },
2360
+ {
2361
+ "caller": "extract_and_cache",
2362
+ "callee": "DataLoader",
2363
+ "lineNumber": 158
2364
+ },
2365
+ {
2366
+ "caller": "extract_and_cache",
2367
+ "callee": "ImageDataset",
2368
+ "lineNumber": 159
2369
+ },
2370
+ {
2371
+ "caller": "extract_and_cache",
2372
+ "callee": "images.to",
2373
+ "lineNumber": 167
2374
+ },
2375
+ {
2376
+ "caller": "extract_and_cache",
2377
+ "callee": "torch.autocast",
2378
+ "lineNumber": 168
2379
+ },
2380
+ {
2381
+ "caller": "extract_and_cache",
2382
+ "callee": "nullcontext",
2383
+ "lineNumber": 168
2384
+ },
2385
+ {
2386
+ "caller": "extract_and_cache",
2387
+ "callee": "model.forward_features",
2388
+ "lineNumber": 170
2389
+ },
2390
+ {
2391
+ "caller": "extract_and_cache",
2392
+ "callee": "split_global_dense",
2393
+ "lineNumber": 171
2394
+ },
2395
+ {
2396
+ "caller": "extract_and_cache",
2397
+ "callee": "extracted_ids.extend",
2398
+ "lineNumber": 172
2399
+ },
2400
+ {
2401
+ "caller": "extract_and_cache",
2402
+ "callee": "global_batches.append",
2403
+ "lineNumber": 173
2404
+ },
2405
+ {
2406
+ "caller": "extract_and_cache",
2407
+ "callee": "global_features.cpu",
2408
+ "lineNumber": 173
2409
+ },
2410
+ {
2411
+ "caller": "extract_and_cache",
2412
+ "callee": "dense_batches.append",
2413
+ "lineNumber": 174
2414
+ },
2415
+ {
2416
+ "caller": "extract_and_cache",
2417
+ "callee": "dense_features.half().cpu",
2418
+ "lineNumber": 174
2419
+ },
2420
+ {
2421
+ "caller": "extract_and_cache",
2422
+ "callee": "dense_features.half",
2423
+ "lineNumber": 174
2424
+ },
2425
+ {
2426
+ "caller": "extract_and_cache",
2427
+ "callee": "torch.cat",
2428
+ "lineNumber": 178
2429
+ },
2430
+ {
2431
+ "caller": "extract_and_cache",
2432
+ "callee": "torch.cat",
2433
+ "lineNumber": 179
2434
+ },
2435
+ {
2436
+ "caller": "extract_and_cache",
2437
+ "callee": "torch.isfinite(payload[\"global\"]).all",
2438
+ "lineNumber": 183
2439
+ },
2440
+ {
2441
+ "caller": "extract_and_cache",
2442
+ "callee": "torch.isfinite",
2443
+ "lineNumber": 183
2444
+ },
2445
+ {
2446
+ "caller": "extract_and_cache",
2447
+ "callee": "torch.isfinite(payload[\"dense\"]).all",
2448
+ "lineNumber": 183
2449
+ },
2450
+ {
2451
+ "caller": "extract_and_cache",
2452
+ "callee": "torch.isfinite",
2453
+ "lineNumber": 183
2454
+ },
2455
+ {
2456
+ "caller": "extract_and_cache",
2457
+ "callee": "torch.save",
2458
+ "lineNumber": 184
2459
+ },
2460
+ {
2461
+ "caller": "extract_and_cache",
2462
+ "callee": "print",
2463
+ "lineNumber": 185
2464
+ },
2465
+ {
2466
+ "caller": "extract_and_cache",
2467
+ "callee": "tuple",
2468
+ "lineNumber": 185
2469
+ },
2470
+ {
2471
+ "caller": "extract_and_cache",
2472
+ "callee": "tuple",
2473
+ "lineNumber": 185
2474
+ },
2475
+ {
2476
+ "caller": "make_submission",
2477
+ "callee": "pd.DataFrame",
2478
+ "lineNumber": 248
2479
+ },
2480
+ {
2481
+ "caller": "make_submission",
2482
+ "callee": "\" \".join",
2483
+ "lineNumber": 251
2484
+ },
2485
+ {
2486
+ "caller": "make_submission",
2487
+ "callee": "ranking.tolist",
2488
+ "lineNumber": 251
2489
+ },
2490
+ {
2491
+ "caller": "make_submission",
2492
+ "callee": "len",
2493
+ "lineNumber": 254
2494
+ },
2495
+ {
2496
+ "caller": "make_submission",
2497
+ "callee": "len",
2498
+ "lineNumber": 254
2499
+ },
2500
+ {
2501
+ "caller": "make_submission",
2502
+ "callee": "all",
2503
+ "lineNumber": 255
2504
+ },
2505
+ {
2506
+ "caller": "make_submission",
2507
+ "callee": "len",
2508
+ "lineNumber": 255
2509
+ },
2510
+ {
2511
+ "caller": "make_submission",
2512
+ "callee": "value.split",
2513
+ "lineNumber": 255
2514
+ },
2515
+ {
2516
+ "caller": "make_submission",
2517
+ "callee": "len",
2518
+ "lineNumber": 255
2519
+ },
2520
+ {
2521
+ "caller": "make_submission",
2522
+ "callee": "set",
2523
+ "lineNumber": 255
2524
+ },
2525
+ {
2526
+ "caller": "make_submission",
2527
+ "callee": "value.split",
2528
+ "lineNumber": 255
2529
+ },
2530
+ {
2531
+ "caller": "make_submission",
2532
+ "callee": "frame.to_csv",
2533
+ "lineNumber": 256
2534
+ },
2535
+ {
2536
+ "caller": "make_submission",
2537
+ "callee": "print",
2538
+ "lineNumber": 257
2539
+ },
2540
+ {
2541
+ "caller": "row_minmax",
2542
+ "callee": "values.min",
2543
+ "lineNumber": 267
2544
+ },
2545
+ {
2546
+ "caller": "row_minmax",
2547
+ "callee": "values.max",
2548
+ "lineNumber": 267
2549
+ },
2550
+ {
2551
+ "caller": "row_minmax",
2552
+ "callee": "(high - low).clamp_min",
2553
+ "lineNumber": 268
2554
+ },
2555
+ {
2556
+ "caller": "local_features",
2557
+ "callee": "cv2.imread",
2558
+ "lineNumber": 298
2559
+ },
2560
+ {
2561
+ "caller": "local_features",
2562
+ "callee": "str",
2563
+ "lineNumber": 298
2564
+ },
2565
+ {
2566
+ "caller": "local_features",
2567
+ "callee": "ValueError",
2568
+ "lineNumber": 300
2569
+ },
2570
+ {
2571
+ "caller": "local_features",
2572
+ "callee": "cv2.resize",
2573
+ "lineNumber": 301
2574
+ },
2575
+ {
2576
+ "caller": "local_features",
2577
+ "callee": "cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)).apply",
2578
+ "lineNumber": 302
2579
+ },
2580
+ {
2581
+ "caller": "local_features",
2582
+ "callee": "cv2.createCLAHE",
2583
+ "lineNumber": 302
2584
+ },
2585
+ {
2586
+ "caller": "local_features",
2587
+ "callee": "cv2.SIFT_create",
2588
+ "lineNumber": 303
2589
+ },
2590
+ {
2591
+ "caller": "local_features",
2592
+ "callee": "sift.detectAndCompute",
2593
+ "lineNumber": 304
2594
+ },
2595
+ {
2596
+ "caller": "geometric_score",
2597
+ "callee": "len",
2598
+ "lineNumber": 310
2599
+ },
2600
+ {
2601
+ "caller": "geometric_score",
2602
+ "callee": "len",
2603
+ "lineNumber": 310
2604
+ },
2605
+ {
2606
+ "caller": "geometric_score",
2607
+ "callee": "cv2.BFMatcher(cv2.NORM_L2).knnMatch",
2608
+ "lineNumber": 312
2609
+ },
2610
+ {
2611
+ "caller": "geometric_score",
2612
+ "callee": "cv2.BFMatcher",
2613
+ "lineNumber": 312
2614
+ },
2615
+ {
2616
+ "caller": "geometric_score",
2617
+ "callee": "len",
2618
+ "lineNumber": 314
2619
+ },
2620
+ {
2621
+ "caller": "geometric_score",
2622
+ "callee": "len",
2623
+ "lineNumber": 315
2624
+ },
2625
+ {
2626
+ "caller": "geometric_score",
2627
+ "callee": "np.float32([query_keypoints[match.queryIdx].pt for match in good]).reshape",
2628
+ "lineNumber": 316
2629
+ },
2630
+ {
2631
+ "caller": "geometric_score",
2632
+ "callee": "np.float32",
2633
+ "lineNumber": 316
2634
+ },
2635
+ {
2636
+ "caller": "geometric_score",
2637
+ "callee": "np.float32([gallery_keypoints[match.trainIdx].pt for match in good]).reshape",
2638
+ "lineNumber": 317
2639
+ },
2640
+ {
2641
+ "caller": "geometric_score",
2642
+ "callee": "np.float32",
2643
+ "lineNumber": 317
2644
+ },
2645
+ {
2646
+ "caller": "geometric_score",
2647
+ "callee": "cv2.findHomography",
2648
+ "lineNumber": 318
2649
+ },
2650
+ {
2651
+ "caller": "geometric_score",
2652
+ "callee": "int",
2653
+ "lineNumber": 319
2654
+ },
2655
+ {
2656
+ "caller": "geometric_score",
2657
+ "callee": "mask.sum",
2658
+ "lineNumber": 319
2659
+ },
2660
+ {
2661
+ "caller": "geometric_score",
2662
+ "callee": "len",
2663
+ "lineNumber": 320
2664
+ },
2665
+ {
2666
+ "caller": "geometric_score",
2667
+ "callee": "math.log1p",
2668
+ "lineNumber": 321
2669
+ },
2670
+ {
2671
+ "caller": "geometric_score",
2672
+ "callee": "len",
2673
+ "lineNumber": 322
2674
+ },
2675
+ {
2676
+ "caller": "overlap",
2677
+ "callee": "float",
2678
+ "lineNumber": 350
2679
+ },
2680
+ {
2681
+ "caller": "overlap",
2682
+ "callee": "np.mean",
2683
+ "lineNumber": 350
2684
+ },
2685
+ {
2686
+ "caller": "overlap",
2687
+ "callee": "len",
2688
+ "lineNumber": 350
2689
+ },
2690
+ {
2691
+ "caller": "overlap",
2692
+ "callee": "set",
2693
+ "lineNumber": 350
2694
+ },
2695
+ {
2696
+ "caller": "overlap",
2697
+ "callee": "set",
2698
+ "lineNumber": 350
2699
+ },
2700
+ {
2701
+ "caller": "overlap",
2702
+ "callee": "zip",
2703
+ "lineNumber": 350
2704
+ },
2705
+ {
2706
+ "caller": "overlap",
2707
+ "callee": "left.tolist",
2708
+ "lineNumber": 350
2709
+ },
2710
+ {
2711
+ "caller": "overlap",
2712
+ "callee": "right.tolist",
2713
+ "lineNumber": 350
2714
+ },
2715
+ {
2716
+ "caller": "show_top1_comparison",
2717
+ "callee": "range",
2718
+ "lineNumber": 379
2719
+ },
2720
+ {
2721
+ "caller": "show_top1_comparison",
2722
+ "callee": "plt.subplots",
2723
+ "lineNumber": 381
2724
+ },
2725
+ {
2726
+ "caller": "show_top1_comparison",
2727
+ "callee": "len",
2728
+ "lineNumber": 381
2729
+ },
2730
+ {
2731
+ "caller": "show_top1_comparison",
2732
+ "callee": "tuple",
2733
+ "lineNumber": 381
2734
+ },
2735
+ {
2736
+ "caller": "show_top1_comparison",
2737
+ "callee": "len",
2738
+ "lineNumber": 381
2739
+ },
2740
+ {
2741
+ "caller": "show_top1_comparison",
2742
+ "callee": "tuple",
2743
+ "lineNumber": 381
2744
+ },
2745
+ {
2746
+ "caller": "show_top1_comparison",
2747
+ "callee": "np.atleast_2d",
2748
+ "lineNumber": 382
2749
+ },
2750
+ {
2751
+ "caller": "show_top1_comparison",
2752
+ "callee": "enumerate",
2753
+ "lineNumber": 383
2754
+ },
2755
+ {
2756
+ "caller": "show_top1_comparison",
2757
+ "callee": "Image.open",
2758
+ "lineNumber": 384
2759
+ },
2760
+ {
2761
+ "caller": "show_top1_comparison",
2762
+ "callee": "axes[row, 0].imshow",
2763
+ "lineNumber": 385
2764
+ },
2765
+ {
2766
+ "caller": "show_top1_comparison",
2767
+ "callee": "image.convert",
2768
+ "lineNumber": 385
2769
+ },
2770
+ {
2771
+ "caller": "show_top1_comparison",
2772
+ "callee": "axes[row, 0].set_title",
2773
+ "lineNumber": 386
2774
+ },
2775
+ {
2776
+ "caller": "show_top1_comparison",
2777
+ "callee": "enumerate",
2778
+ "lineNumber": 387
2779
+ },
2780
+ {
2781
+ "caller": "show_top1_comparison",
2782
+ "callee": "int",
2783
+ "lineNumber": 388
2784
+ },
2785
+ {
2786
+ "caller": "show_top1_comparison",
2787
+ "callee": "Image.open",
2788
+ "lineNumber": 389
2789
+ },
2790
+ {
2791
+ "caller": "show_top1_comparison",
2792
+ "callee": "axes[row, column].imshow",
2793
+ "lineNumber": 390
2794
+ },
2795
+ {
2796
+ "caller": "show_top1_comparison",
2797
+ "callee": "image.convert",
2798
+ "lineNumber": 390
2799
+ },
2800
+ {
2801
+ "caller": "show_top1_comparison",
2802
+ "callee": "axes[row, column].set_title",
2803
+ "lineNumber": 391
2804
+ },
2805
+ {
2806
+ "caller": "show_top1_comparison",
2807
+ "callee": "axis.axis",
2808
+ "lineNumber": 393
2809
+ },
2810
+ {
2811
+ "caller": "show_top1_comparison",
2812
+ "callee": "plt.tight_layout",
2813
+ "lineNumber": 394
2814
+ },
2815
+ {
2816
+ "caller": "show_top1_comparison",
2817
+ "callee": "plt.savefig",
2818
+ "lineNumber": 395
2819
+ },
2820
+ {
2821
+ "caller": "show_top1_comparison",
2822
+ "callee": "plt.show",
2823
+ "lineNumber": 396
2824
+ }
2825
+ ],
2826
+ "metrics": {
2827
+ "importCount": 0,
2828
+ "exportCount": 14,
2829
+ "functionCount": 13,
2830
+ "classCount": 1
2831
+ }
2832
+ }
2833
+ ]
2834
+ }
.understand-anything/tmp/ua-import-map-input.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "projectRoot": "/mnt/data/openai_cv",
3
+ "files": [
4
+ {"path":".understand-anything/.understandignore","language":"unknown","sizeLines":47,"fileCategory":"code"},
5
+ {"path":".understand-anything/config.json","language":"json","sizeLines":3,"fileCategory":"config"},
6
+ {"path":"baseline_dinov3.py","language":"python","sizeLines":397,"fileCategory":"code"},
7
+ {"path":"de_bai_image_to_image_retrieval.md","language":"markdown","sizeLines":66,"fileCategory":"docs"},
8
+ {"path":"eda.py","language":"python","sizeLines":341,"fileCategory":"code"},
9
+ {"path":"notebook324f4a11f8_upgraded.ipynb","language":"ipynb","sizeLines":3255,"fileCategory":"code"},
10
+ {"path":"retrieval_advanced.py","language":"python","sizeLines":399,"fileCategory":"code"}
11
+ ]
12
+ }
.understand-anything/tmp/ua-import-map-output.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "scriptCompleted": true,
3
+ "stats": {
4
+ "filesScanned": 7,
5
+ "filesWithImports": 0,
6
+ "totalEdges": 0
7
+ },
8
+ "importMap": {
9
+ ".understand-anything/.understandignore": [],
10
+ ".understand-anything/config.json": [],
11
+ "baseline_dinov3.py": [],
12
+ "de_bai_image_to_image_retrieval.md": [],
13
+ "eda.py": [],
14
+ "notebook324f4a11f8_upgraded.ipynb": [],
15
+ "retrieval_advanced.py": []
16
+ }
17
+ }
.understand-anything/tmp/ua-scan-files.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "scriptCompleted": true,
3
+ "files": [
4
+ {
5
+ "path": ".understand-anything/.understandignore",
6
+ "language": "unknown",
7
+ "sizeLines": 47,
8
+ "fileCategory": "code"
9
+ },
10
+ {
11
+ "path": ".understand-anything/config.json",
12
+ "language": "json",
13
+ "sizeLines": 3,
14
+ "fileCategory": "config"
15
+ },
16
+ {
17
+ "path": "baseline_dinov3.py",
18
+ "language": "python",
19
+ "sizeLines": 397,
20
+ "fileCategory": "code"
21
+ },
22
+ {
23
+ "path": "de_bai_image_to_image_retrieval.md",
24
+ "language": "markdown",
25
+ "sizeLines": 66,
26
+ "fileCategory": "docs"
27
+ },
28
+ {
29
+ "path": "eda.py",
30
+ "language": "python",
31
+ "sizeLines": 341,
32
+ "fileCategory": "code"
33
+ },
34
+ {
35
+ "path": "notebook324f4a11f8_upgraded.ipynb",
36
+ "language": "ipynb",
37
+ "sizeLines": 3255,
38
+ "fileCategory": "code"
39
+ },
40
+ {
41
+ "path": "retrieval_advanced.py",
42
+ "language": "python",
43
+ "sizeLines": 399,
44
+ "fileCategory": "code"
45
+ }
46
+ ],
47
+ "totalFiles": 7,
48
+ "filteredByIgnore": 32,
49
+ "estimatedComplexity": "small",
50
+ "stats": {
51
+ "filesScanned": 7,
52
+ "byCategory": {
53
+ "code": 5,
54
+ "config": 1,
55
+ "docs": 1
56
+ },
57
+ "byLanguage": {
58
+ "unknown": 1,
59
+ "json": 1,
60
+ "python": 3,
61
+ "markdown": 1,
62
+ "ipynb": 1
63
+ }
64
+ }
65
+ }
README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Self-supervised image retrieval
2
+
3
+ `ssl_retrieval` trains retrieval representations for the 64×64 unlabeled image dataset. It contains frozen DINO inference, SimCLR, an autoencoder pretext task, four-way rotation prediction, and joint training. Retrieval always uses the normalized encoder embedding and cosine similarity.
4
+
5
+ ## Commands
6
+
7
+ ```bash
8
+ python -m ssl_retrieval train --method simclr --output checkpoints/simclr.pt
9
+ python -m ssl_retrieval train --method joint --output checkpoints/joint.pt
10
+ python -m ssl_retrieval evaluate --method joint --checkpoint checkpoints/joint.pt
11
+ python -m ssl_retrieval retrieve --method joint --checkpoint checkpoints/joint.pt \
12
+ --gallery data/dataset2/public_test/public_test/gallery.json \
13
+ --queries data/dataset2/public_test/public_test/queries.json \
14
+ --output submission_public.csv
15
+ ```
16
+
17
+ Use `--from-scratch` to disable the default ImageNet initialization. Joint loss weights are configurable with `--contrastive-weight`, `--reconstruction-weight`, and `--rotation-weight`.
18
+
19
+ Training reserves a deterministic pseudo-gallery of 1,000 train images and creates 200 degraded queries from it. The remaining 2,000 images are used for optimization. The best checkpoint maximizes the mean of Recall@1, Recall@5, Recall@10, and mAP@10. Defaults target one 8 GB GPU and the competition's 20-minute limit; reduce `--epochs` if needed.
20
+
baseline_dinov3.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Deprecated compatibility entrypoint for frozen DINO retrieval."""
2
+
3
+ import sys
4
+
5
+ from ssl_retrieval.__main__ import main
6
+
7
+
8
+ if __name__ == "__main__":
9
+ print("Deprecated: use `python -m ssl_retrieval retrieve --method dino ...`", file=sys.stderr)
10
+ main(["retrieve", "--method", "dino", *sys.argv[1:]])
11
+
de_bai_image_to_image_retrieval.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Đề thi Olympic AI — Image-to-Image Instance Retrieval (không nhãn)
2
+
3
+ ## 1. Bài toán
4
+
5
+ Bạn được cung cấp một **gallery** gồm $N$ ảnh và một tập **queries** gồm $M$ ảnh truy vấn. Với **mỗi** ảnh truy vấn $q$, trong gallery có **đúng một ảnh** là "cùng một cảnh gốc" với $q$ (chỉ khác góc chụp/crop/xoay và có thể bị suy giảm chất lượng) — gọi là **ảnh khớp đúng**. Mọi ảnh gallery còn lại đều **không khớp**, kể cả khi chúng trông khá giống $q$ về mặt nội dung tổng quát (cùng loại địa hình, cùng tông màu...).
6
+
7
+ Nhiệm vụ: xây dựng một hệ thống trả về **top-10 ảnh trong gallery** có khả năng cao nhất là ảnh khớp đúng của $q$, xếp theo độ ưu tiên giảm dần.
8
+
9
+ Cách bạn biểu diễn ảnh, đo độ giống nhau, và (nếu muốn) huấn luyện mô hình như thế nào là **hoàn toàn tự do** — đề không yêu cầu thuật toán cụ thể.
10
+
11
+ **Khác biệt quan trọng so với bài toán phân loại ảnh:** đây **không phải** bài toán "đoán ảnh thuộc nhóm/thể loại nào rồi lấy đại diện của nhóm đó". Gallery có nhiều ảnh trông rất giống nhau về tổng thể (cùng kiểu địa hình), nhưng chỉ **một ảnh cụ thể duy nhất** là đáp án đúng cho mỗi query — hệ thống phải phân biệt được sự khớp ở mức **từng ảnh cụ thể** (instance), không chỉ ở mức "cùng thể loại chung chung". Một hệ thống chỉ biết gom nhóm/phân loại tổng quát sẽ liên tục nhầm giữa nhiều ảnh "giống loại" mà không tìm ra đúng ảnh gốc.
12
+
13
+ ## 2. Dữ liệu — không có nhãn nào được cung cấp
14
+
15
+ Ảnh trong bộ dữ liệu này **không đi kèm bất kỳ nhãn, thể loại, hay mô tả nào** — chỉ là các file ảnh. Bạn không được cho biết ảnh thuộc chủ đề gì, có bao nhiêu nhóm, hay các nhóm đó là gì. Đây là chủ đích của đề: bạn phải tự xây dựng biểu diễn ảnh (feature/embedding) từ chính cấu trúc dữ liệu, không dựa vào nhãn có sẵn.
16
+
17
+ - **`train_unlabeled/`**: 3.000 ảnh không nhãn, tự do sử dụng để pretraining biểu diễn ảnh (self-supervised learning, ví dụ contrastive learning kiểu SimCLR/MoCo, autoencoder, rotation prediction, hoặc trích đặc trưng tay). `train_unlabeled.json` chỉ có `image_id`/`image_path`, không có trường nhãn nào.
18
+ - **`public_test/gallery.json` + `queries.json`**: 1.000 ảnh gallery + 200 ảnh query, không nhãn. Ảnh đã bị suy giảm chất lượng (nhiễu, mờ, sai lệch sáng/tương phản, che khuất một phần, thay đổi góc chụp/crop...) so với ảnh gốc.
19
+ - **`private_test/gallery.json` + `queries.json`**: cùng cấu trúc, 1.000 gallery + 200 query, ảnh **bị suy giảm chất lượng nặng hơn/khác kiểu**, và **gallery cố tình chứa nhiều ảnh "giống loại" với ảnh đúng** (hard negative) để việc chỉ nhận diện thể loại chung chung không đủ tìm ra đáp án — bạn phải phân biệt đúng ảnh cụ thể.
20
+
21
+ `image_id` là chuỗi ngẫu nhiên, không mang thông tin gì về nội dung ảnh.
22
+
23
+ ## 3. Cấu trúc cuộc thi (train / public test / private test)
24
+
25
+ - `train_unlabeled/`: dùng tự do, không tính điểm.
26
+ - `public_test/`: nộp `submission_public.csv` **nhiều lần trong suốt thời gian thi** (tối đa N lần/ngày, ví dụ 5) để nhận điểm public leaderboard tức thời (tham khảo, không tính vào điểm cuối).
27
+ - `private_test/`: nộp `submission_private.csv` **một lần duy nhất** khi hết giờ thi. Không hiển thị điểm lúc thi — chỉ ban giám khảo chấm sau khi đóng cổng, dùng để **xếp hạng cuối cùng**.
28
+
29
+ ## 4. Định dạng nộp bài
30
+
31
+ Hai file CSV tách riêng, mỗi file 2 cột, dòng đầu là header bắt buộc:
32
+
33
+ ```csv
34
+ query_id,gallery_ids
35
+ q_abc123,gal_x1 gal_x2 gal_x3 gal_x4 gal_x5 gal_x6 gal_x7 gal_x8 gal_x9 gal_x10
36
+ ```
37
+
38
+ - Mỗi dòng ứng với đúng 1 `query_id`; cột `gallery_ids` là **đúng 10** `gallery_id` cách nhau bằng dấu cách, xếp theo độ ưu tiên giảm dần.
39
+ - `submission_public.csv` chỉ trỏ vào `gallery_id` thuộc `public_test/gallery.json`; `submission_private.csv` chỉ trỏ vào `private_test/gallery.json`.
40
+ - Phải có đủ dòng cho mọi `query_id` — thiếu dòng nào bị 0 điểm cho query đó. Trùng `gallery_id` trong 1 dòng → dòng đó bị 0 điểm (không ảnh hưởng các dòng khác).
41
+ - Kèm mã nguồn tái tạo được kết quả. Khuyến khích (không bắt buộc, không tính điểm) nộp thêm báo cáo ngắn mô tả cách tiếp cận.
42
+
43
+ ## 5. Chấm điểm
44
+
45
+ Với mỗi query, **chỉ có đúng 1 ảnh gallery liên quan** (ảnh khớp đúng — instance-level, không phải "cùng nhóm").
46
+
47
+ | Tiêu chí | Trọng số |
48
+ |---|---|
49
+ | Recall@1 (private) | 25% |
50
+ | Recall@5 (private) | 25% |
51
+ | Recall@10 (private) | 25% |
52
+ | mAP@10 (private) | 25% |
53
+
54
+ Vì mỗi query chỉ có 1 ảnh đúng duy nhất, mAP@10 ở đây tương đương **1/thứ hạng của ảnh đúng** (nếu lọt top-10), hoặc 0 nếu không lọt — **thứ tự trả về thực sự quan trọng**, không giống các bài toán mà "cùng nhóm là được".
55
+
56
+ **Công thức chính xác** (áp dụng cho từng query, rồi lấy trung bình trên toàn bộ query):
57
+
58
+ - **Recall@K** = 1 nếu ảnh khớp đúng nằm trong K vị trí đầu tiên bạn trả về, ngược lại = 0.
59
+ - **AP@10** (average precision, chỉ 1 ảnh liên quan/query): gọi $r$ là thứ hạng (1-indexed) của ảnh khớp đúng trong 10 ảnh bạn trả về — nếu có, AP = $1/r$; nếu ảnh khớp đúng không nằm trong top-10, AP = 0. **mAP@10** = trung bình AP@10 trên toàn bộ query.
60
+
61
+ ## 6. Ràng buộc
62
+
63
+ - Ngôn ngữ: tự chọn (Python khuyến nghị).
64
+ - Được phép dùng internet (tải backbone/mô hình pretrained, tra cứu tài liệu...).
65
+ - **Quy định danh dự (honor code)**: không được cố tình tra cứu/suy luận ngược nguồn gốc ảnh (reverse image search, tìm ra bộ dữ liệu gốc rồi tra cứu) để lấy thông tin ngoài hệ thống retrieval bạn tự xây dựng. Vi phạm bị xử lý theo quy chế thi nếu bị phát hiện.
66
+ - Thời gian chạy toàn bộ pipeline (từ ảnh thô đến CSV nộp bài) ≤ 20 phút trên máy thi.
67
+ - Được dùng backbone/mô hình pretrained sẵn có (torchvision, HuggingFace...), miễn không phải mô hình đã huấn luyện sẵn cho chính bộ dữ liệu/bài toán này.
eda.py ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Reproducible EDA for the unlabeled image-to-image retrieval dataset."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import hashlib
8
+ import json
9
+ import math
10
+ import os
11
+ import sys
12
+ import tempfile
13
+ from collections import Counter, defaultdict
14
+ from pathlib import Path
15
+
16
+ import cv2
17
+ os.environ.setdefault("MPLCONFIGDIR", str(Path(tempfile.gettempdir()) / "matplotlib-cache"))
18
+ import matplotlib
19
+ import numpy as np
20
+ import pandas as pd
21
+ from PIL import Image, ImageDraw, ImageOps
22
+
23
+ matplotlib.use("Agg")
24
+ import matplotlib.pyplot as plt # noqa: E402
25
+
26
+
27
+ MANIFESTS = {
28
+ "train": "train_unlabeled.json",
29
+ "gallery": "public_test/public_test/gallery.json",
30
+ "query": "public_test/public_test/queries.json",
31
+ }
32
+ PLOT_METRICS = [
33
+ "luminance_mean",
34
+ "luminance_std",
35
+ "blur_laplacian_var",
36
+ "entropy",
37
+ "high_frequency_energy",
38
+ "near_black_ratio",
39
+ "edge_density",
40
+ ]
41
+
42
+
43
+ def parse_args() -> argparse.Namespace:
44
+ parser = argparse.ArgumentParser(description=__doc__)
45
+ parser.add_argument("--data-root", type=Path, default=Path("data/dataset2"))
46
+ parser.add_argument("--output-dir", type=Path, default=Path("eda_output"))
47
+ parser.add_argument("--seed", type=int, default=42)
48
+ parser.add_argument("--grid-size", type=int, default=48)
49
+ return parser.parse_args()
50
+
51
+
52
+ def load_manifest(path: Path) -> list[dict[str, str]]:
53
+ with path.open(encoding="utf-8") as handle:
54
+ rows = json.load(handle)
55
+ if not isinstance(rows, list):
56
+ raise ValueError("manifest root must be a JSON list")
57
+ for index, row in enumerate(rows):
58
+ if not isinstance(row, dict) or not isinstance(row.get("image_id"), str) or not isinstance(row.get("image_path"), str):
59
+ raise ValueError(f"row {index} must contain string image_id and image_path")
60
+ return rows
61
+
62
+
63
+ def resolve_image(data_root: Path, manifest: Path, relative: str) -> Path:
64
+ rel = Path(relative)
65
+ candidates = [
66
+ data_root / rel,
67
+ manifest.parent / rel,
68
+ manifest.parent.parent / rel,
69
+ ]
70
+ for candidate in candidates:
71
+ if candidate.is_file():
72
+ return candidate.resolve()
73
+ return candidates[0].resolve()
74
+
75
+
76
+ def sha256(path: Path) -> str:
77
+ digest = hashlib.sha256()
78
+ with path.open("rb") as handle:
79
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
80
+ digest.update(chunk)
81
+ return digest.hexdigest()
82
+
83
+
84
+ def image_metrics(rgb: np.ndarray) -> dict[str, float]:
85
+ gray = cv2.cvtColor(rgb, cv2.COLOR_RGB2GRAY)
86
+ histogram = np.bincount(gray.ravel(), minlength=256).astype(np.float64)
87
+ probabilities = histogram[histogram > 0] / gray.size
88
+ blurred = cv2.GaussianBlur(gray, (0, 0), 1.0)
89
+ edges = cv2.Canny(gray, 50, 150)
90
+ return {
91
+ "luminance_mean": float(gray.mean()),
92
+ "luminance_std": float(gray.std()),
93
+ "red_mean": float(rgb[..., 0].mean()),
94
+ "red_std": float(rgb[..., 0].std()),
95
+ "green_mean": float(rgb[..., 1].mean()),
96
+ "green_std": float(rgb[..., 1].std()),
97
+ "blue_mean": float(rgb[..., 2].mean()),
98
+ "blue_std": float(rgb[..., 2].std()),
99
+ "blur_laplacian_var": float(cv2.Laplacian(gray, cv2.CV_64F).var()),
100
+ "entropy": float(-(probabilities * np.log2(probabilities)).sum()),
101
+ "high_frequency_energy": float(np.mean(np.abs(gray.astype(np.float32) - blurred.astype(np.float32)))),
102
+ "near_black_ratio": float(np.mean(np.all(rgb < 10, axis=2))),
103
+ "edge_density": float(np.mean(edges > 0)),
104
+ }
105
+
106
+
107
+ def inspect_dataset(data_root: Path) -> tuple[pd.DataFrame, dict, list[str]]:
108
+ records: list[dict] = []
109
+ integrity: dict = {"splits": {}, "hash_groups": {}}
110
+ problems: list[str] = []
111
+ hashes: defaultdict[str, list[str]] = defaultdict(list)
112
+
113
+ for split, relative_manifest in MANIFESTS.items():
114
+ manifest = data_root / relative_manifest
115
+ rows = load_manifest(manifest)
116
+ ids = [row["image_id"] for row in rows]
117
+ paths = [row["image_path"] for row in rows]
118
+ split_info = {
119
+ "rows": len(rows),
120
+ "unique_ids": len(set(ids)),
121
+ "unique_manifest_paths": len(set(paths)),
122
+ "duplicate_ids": sorted(key for key, count in Counter(ids).items() if count > 1),
123
+ "duplicate_manifest_paths": sorted(key for key, count in Counter(paths).items() if count > 1),
124
+ "missing": [],
125
+ "broken": [],
126
+ }
127
+ integrity["splits"][split] = split_info
128
+
129
+ for row in rows:
130
+ path = resolve_image(data_root, manifest, row["image_path"])
131
+ if not path.is_file():
132
+ split_info["missing"].append(str(path))
133
+ problems.append(f"missing: {path}")
134
+ continue
135
+ try:
136
+ with Image.open(path) as image:
137
+ image.load()
138
+ mode, image_format, size = image.mode, image.format, image.size
139
+ rgb = np.asarray(image.convert("RGB"))
140
+ digest = sha256(path)
141
+ hashes[digest].append(f"{split}:{row['image_id']}")
142
+ records.append(
143
+ {
144
+ "split": split,
145
+ "image_id": row["image_id"],
146
+ "manifest_path": row["image_path"],
147
+ "resolved_path": str(path),
148
+ "sha256": digest,
149
+ "format": image_format,
150
+ "mode": mode,
151
+ "width": size[0],
152
+ "height": size[1],
153
+ "file_size_bytes": path.stat().st_size,
154
+ **image_metrics(rgb),
155
+ }
156
+ )
157
+ except Exception as exc: # report corrupt/unsupported images and continue
158
+ message = f"{path}: {type(exc).__name__}: {exc}"
159
+ split_info["broken"].append(message)
160
+ problems.append(f"broken: {message}")
161
+
162
+ if split_info["duplicate_ids"]:
163
+ problems.append(f"{split}: duplicate image_id values")
164
+ if split_info["duplicate_manifest_paths"]:
165
+ problems.append(f"{split}: duplicate image_path values")
166
+
167
+ integrity["hash_groups"] = {digest: items for digest, items in hashes.items() if len(items) > 1}
168
+ return pd.DataFrame(records), integrity, problems
169
+
170
+
171
+ def create_summary(metrics: pd.DataFrame) -> pd.DataFrame:
172
+ numeric = [
173
+ "width", "height", "file_size_bytes", *PLOT_METRICS,
174
+ "red_mean", "red_std", "green_mean", "green_std", "blue_mean", "blue_std",
175
+ ]
176
+ return metrics.groupby("split")[numeric].agg(["count", "mean", "std", "min", "median", "max"])
177
+
178
+
179
+ def thumbnail(path: str, size: int = 128) -> Image.Image:
180
+ with Image.open(path) as image:
181
+ return ImageOps.fit(image.convert("RGB"), (size, size), method=Image.Resampling.LANCZOS)
182
+
183
+
184
+ def save_grid(rows: pd.DataFrame, output: Path, title: str, limit: int = 48) -> None:
185
+ rows = rows.head(limit)
186
+ if rows.empty:
187
+ return
188
+ columns = min(8, len(rows))
189
+ item_width, image_size, label_height = 128, 128, 32
190
+ grid_rows = math.ceil(len(rows) / columns)
191
+ canvas = Image.new("RGB", (columns * item_width, grid_rows * (image_size + label_height) + 28), "white")
192
+ draw = ImageDraw.Draw(canvas)
193
+ draw.text((6, 6), title, fill="black")
194
+ for index, (_, row) in enumerate(rows.iterrows()):
195
+ x = (index % columns) * item_width
196
+ y = 28 + (index // columns) * (image_size + label_height)
197
+ canvas.paste(thumbnail(row["resolved_path"], image_size), (x, y))
198
+ draw.text((x + 2, y + image_size + 2), str(row["image_id"])[:20], fill="black")
199
+ draw.text((x + 2, y + image_size + 16), str(row["split"]), fill="black")
200
+ canvas.save(output, quality=92)
201
+
202
+
203
+ def save_grids(metrics: pd.DataFrame, output_dir: Path, seed: int, grid_size: int) -> None:
204
+ for split in MANIFESTS:
205
+ subset = metrics[metrics["split"] == split]
206
+ sample = subset.sample(n=min(grid_size, len(subset)), random_state=seed)
207
+ save_grid(sample, output_dir / f"grid_random_{split}.jpg", f"Random sample: {split}", grid_size)
208
+
209
+ extremes = {
210
+ "most_blurred": ("blur_laplacian_var", True),
211
+ "most_noisy": ("high_frequency_energy", False),
212
+ "darkest": ("luminance_mean", True),
213
+ "brightest": ("luminance_mean", False),
214
+ "most_near_black": ("near_black_ratio", False),
215
+ }
216
+ for name, (column, ascending) in extremes.items():
217
+ ordered = metrics.sort_values([column, "image_id"], ascending=[ascending, True])
218
+ save_grid(ordered, output_dir / f"grid_{name}.jpg", name.replace("_", " ").title(), grid_size)
219
+
220
+
221
+ def save_distributions(metrics: pd.DataFrame, output: Path) -> None:
222
+ figure, axes = plt.subplots(3, 3, figsize=(15, 12))
223
+ axes = axes.ravel()
224
+ colors = {"train": "#4C78A8", "gallery": "#F58518", "query": "#E45756"}
225
+ for axis, metric in zip(axes, PLOT_METRICS):
226
+ for split in MANIFESTS:
227
+ values = metrics.loc[metrics["split"] == split, metric].dropna()
228
+ axis.hist(values, bins=40, density=True, alpha=0.4, label=split, color=colors[split])
229
+ axis.set_title(metric.replace("_", " "))
230
+ axis.grid(alpha=0.2)
231
+ for axis in axes[len(PLOT_METRICS):]:
232
+ axis.axis("off")
233
+ axes[0].legend()
234
+ figure.suptitle("Image degradation metrics by split", fontsize=16)
235
+ figure.tight_layout()
236
+ figure.savefig(output, dpi=150)
237
+ plt.close(figure)
238
+
239
+
240
+ def write_integrity_report(path: Path, integrity: dict, problems: list[str]) -> None:
241
+ lines = ["IMAGE RETRIEVAL DATASET INTEGRITY", "=" * 33]
242
+ for split, info in integrity["splits"].items():
243
+ lines.extend(
244
+ [
245
+ "",
246
+ f"[{split}]",
247
+ f"rows: {info['rows']}",
248
+ f"unique_ids: {info['unique_ids']}",
249
+ f"unique_manifest_paths: {info['unique_manifest_paths']}",
250
+ f"missing: {len(info['missing'])}",
251
+ f"broken: {len(info['broken'])}",
252
+ f"duplicate_ids: {info['duplicate_ids'] or 'none'}",
253
+ f"duplicate_manifest_paths: {info['duplicate_manifest_paths'] or 'none'}",
254
+ ]
255
+ )
256
+ lines.extend(["", "[exact duplicate SHA-256 groups]"])
257
+ if integrity["hash_groups"]:
258
+ lines.extend(f"{digest}: {', '.join(items)}" for digest, items in integrity["hash_groups"].items())
259
+ else:
260
+ lines.append("none")
261
+ lines.extend(["", "[problems]", *(problems or ["none"])])
262
+ path.write_text("\n".join(lines) + "\n", encoding="utf-8")
263
+
264
+
265
+ def write_markdown_report(path: Path, metrics: pd.DataFrame, integrity: dict) -> None:
266
+ counts = metrics.groupby("split").size().to_dict()
267
+ medians = metrics.groupby("split")[PLOT_METRICS].median().reindex(MANIFESTS)
268
+ lines = [
269
+ "# Image retrieval EDA",
270
+ "",
271
+ "## Dataset",
272
+ "",
273
+ f"- Readable images: **{len(metrics):,}**.",
274
+ *[f"- {split}: **{counts.get(split, 0):,}** images." for split in MANIFESTS],
275
+ f"- Exact duplicate groups: **{len(integrity['hash_groups'])}**.",
276
+ "",
277
+ "## Median degradation metrics",
278
+ "",
279
+ medians.round(4).to_markdown(),
280
+ "",
281
+ "## Distribution shift: query versus train",
282
+ "",
283
+ ]
284
+ for metric in PLOT_METRICS:
285
+ train = medians.loc["train", metric]
286
+ query = medians.loc["query", metric]
287
+ delta = query - train
288
+ relative = delta / abs(train) * 100 if train else float("nan")
289
+ lines.append(f"- `{metric}`: {delta:+.4f} ({relative:+.1f}% of train median).")
290
+ lines.extend(
291
+ [
292
+ "",
293
+ "## Retrieval implications",
294
+ "",
295
+ "- Large blur/noise shifts suggest matching augmentations for representation learning.",
296
+ "- Near-black regions can represent rotation borders or occlusion; avoid treating them as scene content.",
297
+ "- Inspect the extreme grids before choosing color, texture, or edge-sensitive descriptors.",
298
+ "- This EDA does not infer labels or perform retrieval.",
299
+ "",
300
+ "See `distributions.png` and the `grid_*.jpg` files for visual evidence.",
301
+ ]
302
+ )
303
+ path.write_text("\n".join(lines) + "\n", encoding="utf-8")
304
+
305
+
306
+ def main() -> int:
307
+ args = parse_args()
308
+ data_root = args.data_root.resolve()
309
+ output_dir = args.output_dir.resolve()
310
+ if args.grid_size < 1:
311
+ print("error: --grid-size must be at least 1", file=sys.stderr)
312
+ return 2
313
+ missing_manifests = [str(data_root / relative) for relative in MANIFESTS.values() if not (data_root / relative).is_file()]
314
+ if missing_manifests:
315
+ print("error: missing manifest(s):\n " + "\n ".join(missing_manifests), file=sys.stderr)
316
+ return 2
317
+
318
+ output_dir.mkdir(parents=True, exist_ok=True)
319
+ try:
320
+ metrics, integrity, problems = inspect_dataset(data_root)
321
+ except (OSError, json.JSONDecodeError, ValueError) as exc:
322
+ print(f"error: invalid manifest: {exc}", file=sys.stderr)
323
+ return 2
324
+
325
+ metrics.to_csv(output_dir / "image_metrics.csv", index=False)
326
+ if not metrics.empty:
327
+ create_summary(metrics).to_csv(output_dir / "summary.csv")
328
+ save_grids(metrics, output_dir, args.seed, args.grid_size)
329
+ save_distributions(metrics, output_dir / "distributions.png")
330
+ write_markdown_report(output_dir / "report.md", metrics, integrity)
331
+ write_integrity_report(output_dir / "integrity_report.txt", integrity, problems)
332
+
333
+ print(f"EDA complete: {len(metrics):,} readable images -> {output_dir}")
334
+ if problems:
335
+ print(f"Integrity failed with {len(problems)} problem(s); see integrity_report.txt", file=sys.stderr)
336
+ return 1
337
+ return 0
338
+
339
+
340
+ if __name__ == "__main__":
341
+ raise SystemExit(main())
notebook324f4a11f8_upgraded.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Pillow>=10
2
+ timm>=1.0
3
+ torch>=2.2
4
+ torchvision>=0.17
5
+
retrieval_advanced.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Deprecated compatibility entrypoint for learned retrieval checkpoints."""
2
+
3
+ import sys
4
+
5
+ from ssl_retrieval.__main__ import main
6
+
7
+
8
+ if __name__ == "__main__":
9
+ print("Deprecated: use `python -m ssl_retrieval retrieve ...`", file=sys.stderr)
10
+ main(["retrieve", *sys.argv[1:]])
11
+
ssl_retrieval/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """Learning-based self-supervised image retrieval."""
2
+
3
+ __version__ = "1.0.0"
4
+
ssl_retrieval/__main__.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+
5
+ import torch
6
+
7
+ from .engine import evaluate, retrieve, train
8
+
9
+
10
+ def parser():
11
+ root = argparse.ArgumentParser(description="Self-supervised image retrieval")
12
+ sub = root.add_subparsers(dest="command", required=True)
13
+ common = argparse.ArgumentParser(add_help=False)
14
+ common.add_argument("--data-root", default="data/dataset2")
15
+ common.add_argument("--batch-size", type=int, default=64)
16
+ common.add_argument("--device", default="cuda" if torch.cuda.is_available() else "cpu")
17
+ common.add_argument("--seed", type=int, default=42)
18
+ method = argparse.ArgumentParser(add_help=False, parents=[common])
19
+ method.add_argument("--method", choices=("dino", "simclr", "autoencoder", "rotation", "joint"), required=True)
20
+ method.add_argument("--checkpoint")
21
+
22
+ training = sub.add_parser("train", parents=[common])
23
+ training.add_argument("--method", choices=("simclr", "autoencoder", "rotation", "joint"), required=True)
24
+ training.add_argument("--train-manifest", default="data/dataset2/train_unlabeled.json")
25
+ training.add_argument("--output", default="checkpoints/best.pt")
26
+ training.add_argument("--epochs", type=int, default=20)
27
+ training.add_argument("--lr", type=float, default=3e-4)
28
+ training.add_argument("--temperature", type=float, default=0.2)
29
+ training.add_argument("--contrastive-weight", type=float, default=1.0)
30
+ training.add_argument("--reconstruction-weight", type=float, default=0.1)
31
+ training.add_argument("--rotation-weight", type=float, default=0.5)
32
+ training.add_argument("--from-scratch", action="store_true")
33
+ training.set_defaults(handler=train)
34
+
35
+ evaluation = sub.add_parser("evaluate", parents=[method])
36
+ evaluation.add_argument("--train-manifest", default="data/dataset2/train_unlabeled.json")
37
+ evaluation.set_defaults(handler=evaluate)
38
+
39
+ retrieval = sub.add_parser("retrieve", parents=[method])
40
+ retrieval.add_argument("--gallery", required=True)
41
+ retrieval.add_argument("--queries", required=True)
42
+ retrieval.add_argument("--output", required=True)
43
+ retrieval.set_defaults(handler=retrieve)
44
+ return root
45
+
46
+
47
+ def main(argv=None):
48
+ args = parser().parse_args(argv)
49
+ args.handler(args)
50
+
51
+
52
+ if __name__ == "__main__":
53
+ main()
54
+
ssl_retrieval/checkpoints.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ import torch
6
+
7
+ from . import __version__
8
+ from .models import SSLModel
9
+
10
+
11
+ def save_checkpoint(path, model, method, config, epoch, metrics):
12
+ payload = {
13
+ "version": __version__, "method": method, "epoch": epoch,
14
+ "config": config, "metrics": metrics, "encoder": model.encoder.state_dict(),
15
+ "projector": model.projector.state_dict() if model.projector else None,
16
+ "rotation_head": model.rotation_head.state_dict() if model.rotation_head else None,
17
+ "decoder": model.decoder.state_dict() if model.decoder else None,
18
+ }
19
+ Path(path).parent.mkdir(parents=True, exist_ok=True)
20
+ torch.save(payload, path)
21
+
22
+
23
+ def load_checkpoint(path, device="cpu"):
24
+ payload = torch.load(path, map_location=device, weights_only=True)
25
+ model = SSLModel(payload["method"], pretrained=False)
26
+ model.encoder.load_state_dict(payload["encoder"])
27
+ for name in ("projector", "rotation_head", "decoder"):
28
+ module, state = getattr(model, name), payload.get(name)
29
+ if module is not None and state is not None:
30
+ module.load_state_dict(state)
31
+ return model.to(device), payload
32
+
ssl_retrieval/data.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import random
5
+ from dataclasses import dataclass
6
+ from pathlib import Path
7
+
8
+ from PIL import Image
9
+ from torch.utils.data import Dataset
10
+
11
+
12
+ @dataclass(frozen=True)
13
+ class ImageRecord:
14
+ image_id: str
15
+ path: Path
16
+
17
+
18
+ def load_manifest(path: str | Path, data_root: str | Path | None = None) -> list[ImageRecord]:
19
+ manifest = Path(path)
20
+ root = Path(data_root) if data_root else manifest.parent
21
+ rows = json.loads(manifest.read_text(encoding="utf-8"))
22
+ if not isinstance(rows, list):
23
+ raise ValueError(f"{manifest}: expected a JSON list")
24
+ records = []
25
+ for index, row in enumerate(rows):
26
+ if not isinstance(row, dict) or not {"image_id", "image_path"} <= row.keys():
27
+ raise ValueError(f"{manifest}: invalid row {index}")
28
+ relative = Path(row["image_path"])
29
+ candidates = (relative,) if relative.is_absolute() else (
30
+ root / relative,
31
+ manifest.parent / relative,
32
+ manifest.parent.parent / relative,
33
+ manifest.parent.parent.parent / relative,
34
+ )
35
+ resolved = next((candidate for candidate in candidates if candidate.is_file()), None)
36
+ if resolved is None:
37
+ raise FileNotFoundError(f"Cannot resolve {relative} from {manifest}")
38
+ records.append(ImageRecord(str(row["image_id"]), resolved.resolve()))
39
+ if len({record.image_id for record in records}) != len(records):
40
+ raise ValueError(f"{manifest}: duplicate image IDs")
41
+ return records
42
+
43
+
44
+ def pseudo_split(records: list[ImageRecord], seed: int = 42, gallery_size: int = 1000, query_size: int = 200):
45
+ if len(records) < gallery_size:
46
+ raise ValueError(f"Need at least {gallery_size} records")
47
+ shuffled = records.copy()
48
+ random.Random(seed).shuffle(shuffled)
49
+ gallery = shuffled[:gallery_size]
50
+ query_indices = random.Random(seed + 1).sample(range(gallery_size), query_size)
51
+ queries = [(gallery[index], seed * 100_000 + order) for order, index in enumerate(query_indices)]
52
+ return shuffled[gallery_size:], gallery, queries
53
+
54
+
55
+ class ImageDataset(Dataset):
56
+ def __init__(self, records: list[ImageRecord], transform):
57
+ self.records, self.transform = records, transform
58
+
59
+ def __len__(self):
60
+ return len(self.records)
61
+
62
+ def __getitem__(self, index):
63
+ record = self.records[index]
64
+ with Image.open(record.path) as image:
65
+ return record.image_id, self.transform(image.convert("RGB"))
66
+
67
+
68
+ class TrainingDataset(Dataset):
69
+ def __init__(self, records: list[ImageRecord], method: str, transforms):
70
+ self.records, self.method, self.transforms = records, method, transforms
71
+
72
+ def __len__(self):
73
+ return len(self.records)
74
+
75
+ def __getitem__(self, index):
76
+ with Image.open(self.records[index].path) as source:
77
+ image = source.convert("RGB")
78
+ clean = self.transforms.clean(image)
79
+ sample = {"clean": clean}
80
+ if self.method in {"simclr", "joint"}:
81
+ sample["view1"] = self.transforms.contrastive(image)
82
+ sample["view2"] = self.transforms.contrastive(image)
83
+ if self.method in {"autoencoder", "joint"}:
84
+ sample["degraded"] = self.transforms.degraded(image)
85
+ if self.method in {"rotation", "joint"}:
86
+ rotated, label = self.transforms.rotation(image)
87
+ sample["rotated"], sample["rotation_label"] = rotated, label
88
+ return sample
89
+
ssl_retrieval/engine.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import random
5
+ from contextlib import nullcontext
6
+ from pathlib import Path
7
+
8
+ import torch
9
+ from PIL import Image
10
+ from torch.nn import functional as F
11
+ from torch.utils.data import DataLoader
12
+
13
+ from .checkpoints import load_checkpoint, save_checkpoint
14
+ from .data import ImageDataset, TrainingDataset, load_manifest, pseudo_split
15
+ from .losses import nt_xent
16
+ from .models import DINOEncoder, SSLModel
17
+ from .retrieval import rank_embeddings, rankings, retrieval_metrics, validate_rankings, write_submission
18
+ from .transforms import TrainTransforms, deterministic_degrade, inference_transform
19
+
20
+
21
+ @torch.inference_mode()
22
+ def encode(model, records, batch_size, device, transform=inference_transform):
23
+ loader = DataLoader(ImageDataset(records, transform), batch_size=batch_size, shuffle=False)
24
+ ids, batches = [], []
25
+ model.eval()
26
+ for batch_ids, images in loader:
27
+ ids.extend(batch_ids)
28
+ batches.append(model(images.to(device)).cpu())
29
+ return ids, torch.cat(batches)
30
+
31
+
32
+ @torch.inference_mode()
33
+ def evaluate_pseudo(model, train_manifest, data_root, batch_size, device, seed=42):
34
+ records = load_manifest(train_manifest, data_root)
35
+ _, gallery, query_pairs = pseudo_split(records, seed)
36
+ query_records = []
37
+ query_tensors = []
38
+ for order, (record, degradation_seed) in enumerate(query_pairs):
39
+ query_records.append(f"pseudo_q_{order:04d}")
40
+ with Image.open(record.path) as image:
41
+ query_tensors.append(inference_transform(deterministic_degrade(image, degradation_seed)))
42
+ gallery_ids, gallery_features = encode(model, gallery, batch_size, device)
43
+ query_features = []
44
+ for start in range(0, len(query_tensors), batch_size):
45
+ query_features.append(model(torch.stack(query_tensors[start:start + batch_size]).to(device)).cpu())
46
+ _, indices = rank_embeddings(torch.cat(query_features), gallery_features)
47
+ predictions = rankings(query_records, gallery_ids, indices)
48
+ truth = {query_records[i]: record.image_id for i, (record, _) in enumerate(query_pairs)}
49
+ return retrieval_metrics(predictions, truth)
50
+
51
+
52
+ def train(args):
53
+ random.seed(args.seed)
54
+ torch.manual_seed(args.seed)
55
+ if torch.cuda.is_available():
56
+ torch.cuda.manual_seed_all(args.seed)
57
+ device = torch.device(args.device)
58
+ records = load_manifest(args.train_manifest, args.data_root)
59
+ training, _, _ = pseudo_split(records, args.seed)
60
+ dataset = TrainingDataset(training, args.method, TrainTransforms())
61
+ loader = DataLoader(dataset, batch_size=args.batch_size, shuffle=True, drop_last=args.method in {"simclr", "joint"})
62
+ model = SSLModel(args.method, pretrained=not args.from_scratch).to(device)
63
+ optimizer = torch.optim.AdamW(model.parameters(), lr=args.lr, weight_decay=1e-4)
64
+ scaler = torch.amp.GradScaler("cuda", enabled=device.type == "cuda")
65
+ best = -1.0
66
+ config = {key: value for key, value in vars(args).items() if key != "handler"}
67
+ for epoch in range(1, args.epochs + 1):
68
+ model.train()
69
+ total = 0.0
70
+ for sample in loader:
71
+ optimizer.zero_grad(set_to_none=True)
72
+ amp = torch.autocast("cuda", dtype=torch.float16) if device.type == "cuda" else nullcontext()
73
+ with amp:
74
+ loss = torch.zeros((), device=device)
75
+ if args.method in {"simclr", "joint"}:
76
+ loss = loss + args.contrastive_weight * nt_xent(model.project(sample["view1"].to(device)), model.project(sample["view2"].to(device)), args.temperature)
77
+ if args.method in {"autoencoder", "joint"}:
78
+ loss = loss + args.reconstruction_weight * F.mse_loss(model.reconstruct(sample["degraded"].to(device)), sample["clean"].to(device))
79
+ if args.method in {"rotation", "joint"}:
80
+ loss = loss + args.rotation_weight * F.cross_entropy(model.predict_rotation(sample["rotated"].to(device)), sample["rotation_label"].to(device))
81
+ scaler.scale(loss).backward()
82
+ scaler.step(optimizer)
83
+ scaler.update()
84
+ total += float(loss.detach())
85
+ metrics = evaluate_pseudo(model.encoder, args.train_manifest, args.data_root, args.batch_size, device, args.seed)
86
+ print(json.dumps({"epoch": epoch, "loss": total / len(loader), **metrics}))
87
+ if metrics["score"] > best:
88
+ best = metrics["score"]
89
+ save_checkpoint(args.output, model, args.method, config, epoch, metrics)
90
+
91
+
92
+ def load_encoder(method, checkpoint, device):
93
+ if method == "dino":
94
+ return DINOEncoder().eval().to(device)
95
+ if not checkpoint:
96
+ raise ValueError(f"--checkpoint is required for {method}")
97
+ model, _ = load_checkpoint(checkpoint, device)
98
+ if model.method != method:
99
+ raise ValueError(f"Checkpoint method is {model.method}, not {method}")
100
+ return model.encoder.eval()
101
+
102
+
103
+ def evaluate(args):
104
+ device = torch.device(args.device)
105
+ model = load_encoder(args.method, args.checkpoint, device)
106
+ print(json.dumps(evaluate_pseudo(model, args.train_manifest, args.data_root, args.batch_size, device, args.seed), indent=2))
107
+
108
+
109
+ def retrieve(args):
110
+ device = torch.device(args.device)
111
+ model = load_encoder(args.method, args.checkpoint, device)
112
+ gallery = load_manifest(args.gallery, args.data_root)
113
+ queries = load_manifest(args.queries, args.data_root)
114
+ gallery_ids, gallery_features = encode(model, gallery, args.batch_size, device)
115
+ query_ids, query_features = encode(model, queries, args.batch_size, device)
116
+ _, indices = rank_embeddings(query_features, gallery_features)
117
+ predictions = rankings(query_ids, gallery_ids, indices)
118
+ validate_rankings(predictions, query_ids, gallery_ids)
119
+ write_submission(predictions, args.output)
120
+ print(f"saved {args.output}")
ssl_retrieval/losses.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch.nn import functional as F
3
+
4
+
5
+ def nt_xent(left: torch.Tensor, right: torch.Tensor, temperature: float = 0.2) -> torch.Tensor:
6
+ batch = left.shape[0]
7
+ if batch < 2:
8
+ raise ValueError("NT-Xent requires batch size >= 2")
9
+ features = torch.cat((left, right), dim=0)
10
+ logits = features @ features.T / temperature
11
+ logits.fill_diagonal_(float("-inf"))
12
+ targets = (torch.arange(2 * batch, device=features.device) + batch) % (2 * batch)
13
+ return F.cross_entropy(logits, targets)
14
+
ssl_retrieval/models.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import timm
4
+ import torch
5
+ from torch import nn
6
+ from torch.nn import functional as F
7
+ from torchvision.models import ResNet18_Weights, resnet18
8
+
9
+
10
+ class Encoder(nn.Module):
11
+ output_dim = 512
12
+
13
+ def __init__(self, pretrained: bool = True):
14
+ super().__init__()
15
+ model = resnet18(weights=ResNet18_Weights.DEFAULT if pretrained else None)
16
+ model.conv1 = nn.Conv2d(3, 64, 3, 1, 1, bias=False)
17
+ model.maxpool = nn.Identity()
18
+ model.fc = nn.Identity()
19
+ self.model = model
20
+
21
+ def forward(self, images):
22
+ return F.normalize(self.model(images), dim=1)
23
+
24
+
25
+ class SSLModel(nn.Module):
26
+ def __init__(self, method: str, pretrained: bool = True, projection_dim: int = 128):
27
+ super().__init__()
28
+ self.method = method
29
+ self.encoder = Encoder(pretrained)
30
+ dim = self.encoder.output_dim
31
+ self.projector = nn.Sequential(nn.Linear(dim, dim), nn.ReLU(), nn.Linear(dim, projection_dim)) if method in {"simclr", "joint"} else None
32
+ self.rotation_head = nn.Linear(dim, 4) if method in {"rotation", "joint"} else None
33
+ self.decoder = nn.Sequential(
34
+ nn.Linear(dim, 512 * 4 * 4), nn.Unflatten(1, (512, 4, 4)),
35
+ nn.ConvTranspose2d(512, 256, 4, 2, 1), nn.ReLU(),
36
+ nn.ConvTranspose2d(256, 128, 4, 2, 1), nn.ReLU(),
37
+ nn.ConvTranspose2d(128, 64, 4, 2, 1), nn.ReLU(),
38
+ nn.ConvTranspose2d(64, 3, 4, 2, 1), nn.Sigmoid(),
39
+ ) if method in {"autoencoder", "joint"} else None
40
+
41
+ def embedding(self, images):
42
+ return self.encoder(images)
43
+
44
+ def project(self, images):
45
+ return F.normalize(self.projector(self.encoder(images)), dim=1)
46
+
47
+ def reconstruct(self, images):
48
+ return self.decoder(self.encoder(images))
49
+
50
+ def predict_rotation(self, images):
51
+ return self.rotation_head(self.encoder(images))
52
+
53
+
54
+ class DINOEncoder(nn.Module):
55
+ def __init__(self, model_name="convnext_tiny.dinov3_lvd1689m"):
56
+ super().__init__()
57
+ self.model = timm.create_model(model_name, pretrained=True, num_classes=0)
58
+
59
+ def forward(self, images):
60
+ features = self.model(images)
61
+ if features.ndim > 2:
62
+ features = features.flatten(2).mean(-1)
63
+ return F.normalize(features.float(), dim=1)
64
+
ssl_retrieval/retrieval.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import csv
4
+ from pathlib import Path
5
+
6
+ import torch
7
+ from torch.nn import functional as F
8
+
9
+
10
+ def rank_embeddings(query: torch.Tensor, gallery: torch.Tensor, top_k: int = 10):
11
+ if gallery.shape[0] < top_k:
12
+ raise ValueError(f"Gallery has fewer than {top_k} images")
13
+ scores = F.normalize(query.float(), dim=1) @ F.normalize(gallery.float(), dim=1).T
14
+ return scores.topk(top_k, dim=1, sorted=True)
15
+
16
+
17
+ def rankings(query_ids, gallery_ids, indices):
18
+ return {query_id: [gallery_ids[i] for i in row] for query_id, row in zip(query_ids, indices.tolist())}
19
+
20
+
21
+ def retrieval_metrics(predictions: dict[str, list[str]], truth: dict[str, str]):
22
+ ranks = []
23
+ for query_id, correct in truth.items():
24
+ row = predictions.get(query_id, [])[:10]
25
+ ranks.append(row.index(correct) + 1 if correct in row else None)
26
+ metrics = {f"recall@{k}": sum(rank is not None and rank <= k for rank in ranks) / len(ranks) for k in (1, 5, 10)}
27
+ metrics["map@10"] = sum(1 / rank if rank else 0 for rank in ranks) / len(ranks)
28
+ metrics["score"] = sum(metrics.values()) / 4
29
+ return metrics
30
+
31
+
32
+ def validate_rankings(predictions, query_ids, gallery_ids, top_k=10):
33
+ if set(predictions) != set(query_ids):
34
+ raise ValueError("Predictions do not contain exactly the expected queries")
35
+ valid = set(gallery_ids)
36
+ for query_id, row in predictions.items():
37
+ if len(row) != top_k or len(set(row)) != top_k or not set(row) <= valid:
38
+ raise ValueError(f"Invalid ranking for {query_id}")
39
+
40
+
41
+ def write_submission(predictions, path: str | Path):
42
+ with Path(path).open("w", newline="", encoding="utf-8") as file:
43
+ writer = csv.writer(file)
44
+ writer.writerow(("query_id", "gallery_ids"))
45
+ writer.writerows((query_id, " ".join(row)) for query_id, row in predictions.items())
46
+
ssl_retrieval/transforms.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import io
4
+ import random
5
+
6
+ import torch
7
+ from PIL import Image, ImageEnhance, ImageFilter, ImageOps
8
+ from torchvision import transforms as T
9
+ from torchvision.transforms import functional as TF
10
+
11
+ MEAN = (0.485, 0.456, 0.406)
12
+ STD = (0.229, 0.224, 0.225)
13
+
14
+
15
+ def _tensor(image: Image.Image) -> torch.Tensor:
16
+ return TF.normalize(TF.to_tensor(image.resize((64, 64), Image.Resampling.BICUBIC)), MEAN, STD)
17
+
18
+
19
+ class TrainTransforms:
20
+ def __init__(self):
21
+ self.clean_transform = T.Compose([T.Resize((64, 64)), T.ToTensor()])
22
+ self.contrastive_transform = T.Compose([
23
+ T.RandomResizedCrop(64, scale=(0.45, 1.0)),
24
+ T.RandomHorizontalFlip(),
25
+ T.RandomApply([T.ColorJitter(0.45, 0.45, 0.25, 0.05)], p=0.8),
26
+ T.RandomGrayscale(p=0.1),
27
+ T.RandomApply([T.GaussianBlur(5, sigma=(0.2, 2.0))], p=0.4),
28
+ T.ToTensor(), T.Normalize(MEAN, STD),
29
+ ])
30
+ self.degraded_transform = T.Compose([
31
+ T.RandomResizedCrop(64, scale=(0.45, 1.0)),
32
+ T.RandomPerspective(0.15, p=0.4),
33
+ T.ColorJitter(0.45, 0.45, 0.25, 0.05),
34
+ T.RandomApply([T.GaussianBlur(7, sigma=(0.5, 2.5))], p=0.5),
35
+ T.ToTensor(), T.Normalize(MEAN, STD),
36
+ ])
37
+
38
+ def clean(self, image):
39
+ return self.clean_transform(image)
40
+
41
+ def contrastive(self, image):
42
+ return self.contrastive_transform(image)
43
+
44
+ def degraded(self, image):
45
+ return self.degraded_transform(image)
46
+
47
+ def rotation(self, image):
48
+ label = random.randrange(4)
49
+ return _tensor(image.rotate(90 * label)), label
50
+
51
+
52
+ def inference_transform(image: Image.Image) -> torch.Tensor:
53
+ return _tensor(image)
54
+
55
+
56
+ def deterministic_degrade(image: Image.Image, seed: int) -> Image.Image:
57
+ rng = random.Random(seed)
58
+ image = image.convert("RGB")
59
+ width, height = image.size
60
+ scale = rng.uniform(0.45, 0.9)
61
+ crop_w, crop_h = max(8, int(width * scale)), max(8, int(height * scale))
62
+ left, top = rng.randrange(width - crop_w + 1), rng.randrange(height - crop_h + 1)
63
+ image = image.crop((left, top, left + crop_w, top + crop_h)).resize((64, 64), Image.Resampling.BICUBIC)
64
+ image = image.rotate(rng.uniform(-30, 30), resample=Image.Resampling.BICUBIC)
65
+ margin = rng.randint(1, 7)
66
+ image = TF.perspective(
67
+ image,
68
+ [[0, 0], [63, 0], [63, 63], [0, 63]],
69
+ [[rng.randint(0, margin), rng.randint(0, margin)],
70
+ [63 - rng.randint(0, margin), rng.randint(0, margin)],
71
+ [63 - rng.randint(0, margin), 63 - rng.randint(0, margin)],
72
+ [rng.randint(0, margin), 63 - rng.randint(0, margin)]],
73
+ interpolation=T.InterpolationMode.BILINEAR,
74
+ )
75
+ image = ImageEnhance.Brightness(image).enhance(rng.uniform(0.55, 1.45))
76
+ image = ImageEnhance.Contrast(image).enhance(rng.uniform(0.5, 1.5))
77
+ if rng.random() < 0.6:
78
+ image = image.filter(ImageFilter.GaussianBlur(rng.uniform(0.4, 2.2)))
79
+ if rng.random() < 0.55:
80
+ generator = torch.Generator().manual_seed(seed + 17)
81
+ pixels = TF.to_tensor(image)
82
+ pixels = (pixels + torch.randn(pixels.shape, generator=generator) * rng.uniform(0.02, 0.12)).clamp(0, 1)
83
+ image = TF.to_pil_image(pixels)
84
+ if rng.random() < 0.5:
85
+ small = rng.randint(18, 48)
86
+ image = image.resize((small, small), Image.Resampling.BILINEAR).resize((64, 64), Image.Resampling.BILINEAR)
87
+ if rng.random() < 0.45:
88
+ x, y, size = rng.randrange(52), rng.randrange(52), rng.randrange(5, 13)
89
+ image.paste(tuple(rng.randrange(256) for _ in range(3)), (x, y, x + size, y + size))
90
+ buffer = io.BytesIO()
91
+ image.save(buffer, "JPEG", quality=rng.randint(20, 75))
92
+ buffer.seek(0)
93
+ return Image.open(buffer).convert("RGB").copy()
tests/test_ssl_retrieval.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import torch
4
+ from PIL import Image
5
+ from torch.nn import functional as F
6
+
7
+ from ssl_retrieval.checkpoints import load_checkpoint, save_checkpoint
8
+ from ssl_retrieval.data import load_manifest, pseudo_split
9
+ from ssl_retrieval.losses import nt_xent
10
+ from ssl_retrieval.models import SSLModel
11
+ from ssl_retrieval.retrieval import rank_embeddings, rankings, retrieval_metrics, validate_rankings
12
+ from ssl_retrieval.transforms import deterministic_degrade
13
+
14
+
15
+ def test_manifest_and_pseudo_split(tmp_path):
16
+ records = []
17
+ for index in range(12):
18
+ path = tmp_path / f"{index}.jpg"
19
+ Image.new("RGB", (64, 64), (index, index, index)).save(path)
20
+ records.append({"image_id": str(index), "image_path": path.name})
21
+ manifest = tmp_path / "images.json"
22
+ manifest.write_text(json.dumps(records))
23
+ loaded = load_manifest(manifest)
24
+ train, gallery, queries = pseudo_split(loaded, gallery_size=10, query_size=2)
25
+ assert (len(train), len(gallery), len(queries)) == (2, 10, 2)
26
+
27
+
28
+ def test_models_losses_and_checkpoint(tmp_path):
29
+ images = torch.randn(2, 3, 64, 64)
30
+ for method in ("simclr", "autoencoder", "rotation", "joint"):
31
+ model = SSLModel(method, pretrained=False)
32
+ assert model.embedding(images).shape == (2, 512)
33
+ assert torch.allclose(model.embedding(images).norm(dim=1), torch.ones(2), atol=1e-5)
34
+ if model.projector:
35
+ assert torch.isfinite(nt_xent(model.project(images), model.project(images)))
36
+ if model.decoder:
37
+ assert model.reconstruct(images).shape == images.shape
38
+ if model.rotation_head:
39
+ assert model.predict_rotation(images).shape == (2, 4)
40
+ loss = torch.zeros(())
41
+ if model.projector:
42
+ loss = loss + nt_xent(model.project(images), model.project(images + 0.01))
43
+ if model.decoder:
44
+ loss = loss + 0.1 * F.mse_loss(model.reconstruct(images), torch.sigmoid(images))
45
+ if model.rotation_head:
46
+ loss = loss + 0.5 * F.cross_entropy(model.predict_rotation(images), torch.tensor([0, 1]))
47
+ loss.backward()
48
+ assert all(torch.isfinite(parameter.grad).all() for parameter in model.parameters() if parameter.grad is not None)
49
+ path = tmp_path / f"{method}.pt"
50
+ save_checkpoint(path, model, method, {}, 1, {"score": 0.0})
51
+ restored, payload = load_checkpoint(path)
52
+ assert payload["method"] == method and restored.embedding(images).shape == (2, 512)
53
+
54
+
55
+ def test_degradation_ranking_and_metrics():
56
+ image = Image.new("RGB", (64, 64), "green")
57
+ assert list(deterministic_degrade(image, 7).getdata()) == list(deterministic_degrade(image, 7).getdata())
58
+ gallery = torch.eye(10)
59
+ _, indices = rank_embeddings(gallery[:2], gallery)
60
+ prediction = rankings(["q0", "q1"], [f"g{i}" for i in range(10)], indices)
61
+ validate_rankings(prediction, ["q0", "q1"], [f"g{i}" for i in range(10)])
62
+ metrics = retrieval_metrics(prediction, {"q0": "g0", "q1": "g1"})
63
+ assert metrics == {"recall@1": 1.0, "recall@5": 1.0, "recall@10": 1.0, "map@10": 1.0, "score": 1.0}
upload_milk10k.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import os
3
+ from pathlib import Path
4
+
5
+ from huggingface_hub import HfApi
6
+
7
+ REPO_ID = "duyle2408/milk10k_new_code"
8
+ REPO_TYPE = "dataset"
9
+ FOLDER = Path(__file__).resolve().parent
10
+
11
+ IGNORE = [
12
+ "**/__pycache__/**",
13
+ "**/*.pyc",
14
+ "**/.cache/**",
15
+ "**/.git/**",
16
+ "**/.agents/**",
17
+ "**/.codex/**",
18
+ "**/.understand-anything/**",
19
+ "**/.pytest_cache/**",
20
+ "**/.venv/**",
21
+ "data/**",
22
+ "feature_cache/**",
23
+ "checkpoints/**",
24
+ "eda_output/**",
25
+ "diagnostics_*.csv",
26
+ "diagnostics_*.png",
27
+ "submission*.csv",
28
+ "**/*.zip",
29
+ "**/*.pt",
30
+ "**/*.pth",
31
+ "**/*.ckpt",
32
+ ]
33
+
34
+
35
+ def main():
36
+ api = HfApi(token=os.environ.get("HF_TOKEN"))
37
+ api.create_repo(
38
+ repo_id=REPO_ID,
39
+ repo_type=REPO_TYPE,
40
+ private=False,
41
+ exist_ok=True,
42
+ )
43
+ api.upload_folder(
44
+ repo_id=REPO_ID,
45
+ repo_type=REPO_TYPE,
46
+ folder_path=str(FOLDER),
47
+ ignore_patterns=IGNORE,
48
+ commit_message="Upload milk10k code",
49
+ )
50
+
51
+
52
+ if __name__ == "__main__":
53
+ main()