Tran1312 commited on
Commit
7fb73b4
·
verified ·
1 Parent(s): d9ba0b4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +209 -481
README.md CHANGED
@@ -5,7 +5,7 @@ task_categories:
5
  size_categories:
6
  - 1M<n<10M
7
  source_datasets:
8
- - extended
9
  annotations_creators:
10
  - found
11
  license: cc-by-4.0
@@ -22,268 +22,231 @@ tags:
22
  - 80-classes
23
  ---
24
 
25
- # Objects365 Label Organization and DataLoader Architecture (80 Classes)
26
 
27
- This dataset provides a filtered **80-class subset of Objects365** for large-scale object-detection pretraining and training. It contains COCO-style bounding-box annotations reorganized into JSONL files, explicit image-path mappings, train/validation metadata, and optional class-repeat factors for long-tail rebalancing.
28
 
29
- The accompanying DataLoader uses **disk-backed JSONL records with cached in-memory indexes** for direct byte-offset access, deterministic epoch-level sampling, train-time class oversampling, bounding-box validation, letterbox resizing, Albumentations-based augmentation, and retry/error logging for malformed samples.
30
 
31
- This card documents the label organization, directory structure, schemas, relationships between files, and the runtime data-loading architecture. It has been aligned with the current `dataloader.py` implementation.
 
 
 
 
32
 
33
  ---
34
 
35
- ## 1. Overview
 
 
36
 
37
- Labels and metadata are stored primarily in **JSON Lines (`.jsonl`)** format rather than one deeply nested JSON file.
38
 
39
- ### Why JSONL is used
 
 
 
 
40
 
41
- - Suitable for large datasets containing more than 1.7 million image records and nearly 16 million annotations.
42
- - Records can be scanned sequentially without deserializing the entire source file.
43
- - Byte offsets can be cached and later used with `f.seek()` for direct random access to individual records.
44
- - Corrupted lines can be skipped during index construction without invalidating the rest of the file.
45
- - The format is easy to filter, shard, inspect, and regenerate.
46
 
47
- > **Important:** the JSONL files themselves are not fully loaded into RAM, but the current DataLoader does keep several Python data structures in memory: the image-ID offset index, annotation-group index, image-path map, image-category map during dataset construction, and the final image-ID list. Therefore, the implementation should be described as **disk-backed record access with in-memory indexes**, not as an `O(1)`-memory loader.
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  ---
50
 
51
- ## 2. Directory Structure and Dataset Statistics
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- The `labels/` directory is split into independent `train/` and `val/` subsets.
 
 
 
 
54
 
55
  ```text
56
  labels/
57
  ├── README.md
58
  ├── train/
59
- │ ├── annotations.jsonl # 15,538,897 annotations (~2.64 GB)
60
- │ ├── categories.jsonl # 80 object classes (~2.4 KB)
61
- │ ├── class_sampling.jsonl # Class repeat/oversampling factors (~2.5 KB)
62
- │ ├── images_info.jsonl # 1,652,206 labeled images (~177.93 MB)
63
- │ └── images_train.jsonl # 1,742,289 physical image paths (~150.87 MB)
64
  └── val/
65
- ├── annotations.jsonl # 442,988 annotations (~75.53 MB)
66
- ├── categories.jsonl # 80 object classes (~2.4 KB)
67
- ├── images_info.jsonl # 67,749 labeled images (~7.30 MB)
68
- └── images_val.jsonl # 80,000 physical image paths (~6.93 MB)
69
  ```
70
 
71
- ### Detailed statistics
72
 
73
- | Split | File | Records | Approx. size | Main purpose |
74
  | :--- | :--- | ---: | ---: | :--- |
75
- | **train** | `annotations.jsonl` | 15,538,897 | 2.64 GB | Bounding boxes and annotation flags such as `iscrowd` and `isfake` |
76
- | | `categories.jsonl` | 80 | 2.4 KB | Definition of the 80 target classes |
77
- | | `class_sampling.jsonl` | 80 | 2.5 KB | Per-class repeat factors used for train-time oversampling |
78
- | | `images_info.jsonl` | 1,652,206 | 177.93 MB | Image IDs, original dimensions, file names, and metadata |
79
- | | `images_train.jsonl` | 1,742,289 | 150.87 MB | Maps image file names to physical patch paths |
80
  | **val** | `annotations.jsonl` | 442,988 | 75.53 MB | Validation bounding boxes and labels |
81
- | | `categories.jsonl` | 80 | 2.4 KB | Same target-class definition as the train split |
82
- | | `images_info.jsonl` | 67,749 | 7.30 MB | Metadata for labeled validation images |
83
- | | `images_val.jsonl` | 80,000 | 6.93 MB | Maps validation image names to physical patch paths |
84
 
85
- > **Notes**
86
- >
87
- > - `images_train.jsonl` contains more records than `images_info.jsonl` because the downloaded image collection includes images that do not contain any of the retained 80 target classes or whose labels were filtered during preprocessing.
88
- > - Every labeled image represented by `images_info.jsonl` is expected to have a corresponding physical-path entry.
89
- > - `class_sampling.jsonl` exists only for the training split because class rebalancing must not alter the validation distribution.
90
 
91
  ---
92
 
93
- ## 3. Entity Relationships
94
-
95
- The JSONL files are linked through explicit keys in a relational-database-like structure.
96
-
97
- ```mermaid
98
- erDiagram
99
- CATEGORIES ||--o{ ANNOTATIONS : "category_id"
100
- CATEGORIES ||--o{ CLASS_SAMPLING : "id"
101
- IMAGES_INFO ||--o{ ANNOTATIONS : "image_id"
102
- IMAGES_INFO ||--|| IMAGE_PATH_MAP : "file_name == image_name"
103
-
104
- CATEGORIES {
105
- int id PK "Raw category identifier"
106
- string name "Object-class name"
107
- }
108
-
109
- CLASS_SAMPLING {
110
- int id FK "Category identifier"
111
- float probability "Sampling percentage"
112
- }
113
-
114
- IMAGES_INFO {
115
- int id PK "Image identifier"
116
- string file_name "Original image filename"
117
- int width "Original width in pixels"
118
- int height "Original height in pixels"
119
- int license "Source license identifier"
120
- string url "Source URL"
121
- }
122
-
123
- IMAGE_PATH_MAP {
124
- string image_name PK "Image filename"
125
- string path "Relative physical path"
126
- }
127
-
128
- ANNOTATIONS {
129
- int id PK "Annotation identifier"
130
- int image_id FK "References IMAGES_INFO.id"
131
- int category_id FK "References CATEGORIES.id"
132
- array bbox "[x_min, y_min, width, height]"
133
- float area "Bounding-box area"
134
- int iscrowd "Crowd-region flag"
135
- int isfake "Synthetic/drawn-object flag"
136
- int isreflected "Reflection flag"
137
- int flag_reflected "Auxiliary reflection flag"
138
- }
139
- ```
140
 
141
- The loader normalizes the category records and constructs a `cat_id_to_idx` mapping from raw dataset category IDs to contiguous model-class indices.
142
 
143
- ---
144
 
145
- ## 4. Data Schemas
146
 
147
- Each non-empty line in a `.jsonl` file is an independent JSON object.
148
 
149
- ### 4.1. `categories.jsonl`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
- Defines the **80-class object vocabulary**.
152
 
153
- **Schema**
 
 
 
 
 
 
154
 
155
  - `id` (`int`): raw category identifier.
156
- - `name` (`str`): English class name.
157
 
158
- **Example**
159
 
160
  ```json
161
  {"name": "Person", "id": 0}
162
- {"name": "Sneakers", "id": 2}
163
  {"name": "Chair", "id": 1}
 
164
  ```
165
 
166
- The current DataLoader passes these records through `normalize_categories()` before constructing the model-facing class-index mapping.
167
-
168
  ---
169
 
170
- ### 4.2. `images_info.jsonl`
171
 
172
- Stores geometric and identifying metadata for each labeled image.
173
 
174
- **Schema**
175
 
176
  - `id` (`int`): unique image identifier.
177
  - `file_name` (`str`): original image filename.
178
- - `width` (`int`): original image width in pixels.
179
- - `height` (`int`): original image height in pixels.
180
- - `license` (`int`): source license identifier.
181
- - `url` (`str`): source URL, often an empty string.
182
 
183
- **Example**
184
 
185
  ```json
186
  {"height": 512, "id": 420917, "license": 5, "width": 769, "file_name": "objects365_v1_00420917.jpg", "url": ""}
187
- {"height": 500, "id": 900001, "license": 5, "width": 333, "file_name": "objects365_v2_00900001.jpg", "url": ""}
188
- ```
189
-
190
- The DataLoader builds a cached mapping:
191
-
192
- ```text
193
- image_id -> byte_offset_in_images_info.jsonl
194
  ```
195
 
196
- This allows metadata for one image to be retrieved by seeking directly to the corresponding byte position.
197
 
198
  ---
199
 
200
- ### 4.3. `images_train.jsonl` and `images_val.jsonl`
201
 
202
- The physical image collection downloaded from Hugging Face (`Tran1312/object365-images`) is distributed across patch directories such as `patch0/`, `patch1/`, ..., `patch50/`.
203
 
204
- These files map an image filename to its relative path on disk.
205
 
206
- **Schema**
 
207
 
208
- - `image_name` (`str`): image filename; expected to match `file_name` in `images_info.jsonl`.
209
- - `path` (`str`): relative path from the corresponding image-split root directory.
210
-
211
- **Example**
212
 
213
  ```json
214
  {"image_name": "objects365_v2_00953995.jpg", "path": "patch17/objects365_v2_00953995.jpg"}
215
- {"image_name": "objects365_v2_01598998.jpg", "path": "patch33/objects365_v2_01598998.jpg"}
216
  ```
217
 
218
- The current implementation loads this mapping into a Python dictionary and optionally caches the dictionary as a pickle file.
219
 
220
  ---
221
 
222
- ### 4.4. `annotations.jsonl`
223
 
224
- Stores bounding boxes and annotation attributes.
225
 
226
- **Schema**
227
 
228
- - `id` (`int`): unique annotation identifier.
229
- - `image_id` (`int`): foreign key referencing an image in `images_info.jsonl`.
230
- - `category_id` (`int`): foreign key referencing a category in `categories.jsonl`.
231
- - `bbox` (`list[float]`): COCO-style box `[x_min, y_min, width, height]`, expressed in original-image pixels.
232
  - `area` (`float`): bounding-box area.
233
  - `iscrowd` (`int`): crowd-region flag.
234
  - `isfake` (`int`): synthetic/drawn-object flag.
235
- - `isreflected` (`int`) and `flag_reflected` (`int`): reflection-related metadata.
 
236
 
237
- **Example**
238
 
239
  ```json
240
  {"id": 26899493, "iscrowd": 0, "isfake": 0, "area": 3764.58, "isreflected": 0, "bbox": [20.3, 260.25, 82.69, 45.52], "image_id": 0, "category_id": 0, "flag_reflected": 0}
241
  ```
242
 
243
- The DataLoader constructs a cached annotation-group index:
244
-
245
- ```text
246
- image_id -> [annotation_byte_offset_1, annotation_byte_offset_2, ...]
247
- ```
248
-
249
- At runtime, only the annotation records associated with the requested image are read from the JSONL file.
250
-
251
  ---
252
 
253
- ### 4.5. `class_sampling.jsonl`
254
 
255
- Used only by the training split to mitigate long-tail class imbalance.
256
 
257
- **Schema**
258
 
259
- - `id` (`int`): raw category identifier.
260
- - `probability` (`int` or `float`): repeat percentage, where `100` corresponds to a repeat factor of `1.0`.
261
-
262
- The loader computes
263
-
264
- \[
265
- \text{factor}(c)=\max\left(1,\frac{\text{probability}(c)}{100}\right).
266
- \]
267
-
268
- For an image containing multiple retained classes, its image-level repeat factor is
269
-
270
- \[
271
- r_i=\max_{c\in C_i}\text{factor}(c),
272
- \]
273
-
274
- where \(C_i\) is the set of valid categories present in image \(i\).
275
-
276
- The actual repeat count uses **stochastic rounding**:
277
-
278
- \[
279
- n_i = \lfloor r_i \rfloor +
280
- \mathbf{1}\left[u < r_i-\lfloor r_i \rfloor\right],
281
- \qquad u\sim U(0,1).
282
- \]
283
 
284
- Therefore, a factor such as `2.39` produces two copies deterministically and a third copy with probability `0.39`.
285
-
286
- **Example**
287
 
288
  ```json
289
  {"id": 0, "probability": 100}
@@ -291,359 +254,124 @@ Therefore, a factor such as `2.39` produces two copies deterministically and a t
291
  {"id": 78, "probability": 202}
292
  ```
293
 
294
- Classes absent from the sampling file effectively fall back to a repeat factor of `1.0` when images are oversampled.
295
 
296
  ---
297
 
298
- ## 5. DataLoader Architecture
299
-
300
- The current implementation has four conceptually distinct phases.
301
-
302
- ```mermaid
303
- flowchart TD
304
- subgraph Indexing ["1. Index Construction / Cache Loading"]
305
- A1["images_info.jsonl"] -->|"build_id_offset_index()"| B1["image_id -> byte offset"]
306
- A2["annotations.jsonl"] -->|"build_annotation_group_index()"| B2["image_id -> annotation offsets"]
307
- A3["images_train/val.jsonl"] -->|"load_image_path_map()"| B3["file_name -> relative path"]
308
- end
309
-
310
- subgraph DatasetBuild ["2. Dataset Construction"]
311
- B1 --> C["Collect valid categories per image"]
312
- B2 --> C
313
- C --> D{"Keep images without valid annotations?"}
314
- D --> E["Final image-ID list"]
315
- S["class_sampling.jsonl"] -->|"train only"| F["Image-level repeat factors"]
316
- E --> F
317
- F --> G["Oversampled train image-ID list"]
318
- end
319
-
320
- subgraph SampleLoad ["3. Per-Sample Loading"]
321
- G --> H["Select image_id"]
322
- H --> I["Seek image metadata"]
323
- H --> J["Seek relevant annotations"]
324
- H --> K["Resolve physical image path"]
325
- K --> L["cv2.imread()"]
326
- I & J & L --> M["Filter / clip boxes"]
327
- M --> N["Letterbox to square input size"]
328
- N --> O["Albumentations train augmentation"]
329
- O --> P["Tensor image + target dict"]
330
- end
331
-
332
- subgraph Batching ["4. Batching"]
333
- P --> Q["collate_fn()"]
334
- Q --> R["Tensor batch + list[target]"]
335
- end
336
- ```
337
-
338
- ### 5.1. Cached indexes
339
-
340
- Three expensive data structures are persisted as pickle files when caching is enabled:
341
-
342
- 1. **Image metadata offset index**
343
- ```text
344
- image_id -> byte_offset
345
- ```
346
-
347
- 2. **Annotation-group index**
348
- ```text
349
- image_id -> [byte_offset, byte_offset, ...]
350
- ```
351
-
352
- 3. **Image-path map**
353
- ```text
354
- file_name -> relative_path
355
- ```
356
-
357
- If a cache file already exists and `force_rebuild` / `cfg.rebuild_index` is false, it is loaded directly.
358
-
359
- > The current cache mechanism does not automatically validate source-file modification time, file size, or content hash. If a JSONL source file changes, `cfg.rebuild_index=True` should be used to rebuild the corresponding cache.
360
-
361
- ### 5.2. Dataset-construction pass
362
-
363
- After the indexes are available, `collect_image_categories()` traverses the image IDs and their annotation offsets to determine the set of valid categories present in each image.
364
-
365
- This pass is used to:
366
-
367
- - exclude images without retained annotations when `include_images_without_annotations=False`;
368
- - compute image-level repeat factors for class-balanced training.
369
-
370
- This category map is created during dataset construction and is not currently persisted as its own cache.
371
-
372
- ### 5.3. Per-sample annotation filtering
373
-
374
- For every annotation associated with an image, `annotation_target()`:
375
-
376
- 1. optionally removes `iscrowd == 1`;
377
- 2. optionally removes `isfake == 1`;
378
- 3. removes categories not present in the normalized class mapping;
379
- 4. rejects missing, malformed, non-finite, zero-width, zero-height, or negative-size boxes;
380
- 5. converts `[x, y, w, h]` to `[x1, y1, x2, y2]`;
381
- 6. **clips** coordinates to image boundaries;
382
- 7. rejects the box only if its area becomes non-positive after clipping.
383
-
384
- Therefore, boxes that partially extend outside the image are not automatically discarded; they are clipped to the valid image region.
385
-
386
- ### 5.4. Image resizing and augmentation order
387
-
388
- The implementation performs transformations in this order:
389
-
390
- 1. Read BGR image with OpenCV.
391
- 2. Validate that the decoded image has shape `H x W x 3`.
392
- 3. Convert BGR to RGB.
393
- 4. Apply square **letterbox resizing** unless the image is already exactly `imgsz x imgsz`.
394
- 5. Transform bounding boxes using the same scale and padding.
395
- 6. Apply training augmentation with Albumentations.
396
- 7. Convert the final uint8 RGB array to a contiguous PyTorch tensor.
397
- 8. Convert pixel values to `float32` in `[0, 1]`.
398
-
399
- The train-time augmentation pipeline contains:
400
-
401
- ```text
402
- HorizontalFlip
403
- -> ShiftScaleRotate
404
- -> RandomBrightnessContrast
405
- -> HueSaturationValue
406
- -> GaussNoise
407
- -> Blur
408
- ```
409
-
410
- Bounding boxes use Albumentations `pascal_voc` format (`[x1, y1, x2, y2]`) with `min_visibility=0.4`.
411
-
412
- If a sample has no boxes before augmentation, `DetectionAugmenter.__call__()` currently returns immediately, so no image-only augmentation is applied to that sample.
413
-
414
- ### 5.5. Returned sample format
415
-
416
- Each dataset item is returned as
417
-
418
- ```python
419
- image_tensor, {
420
- "boxes": boxes_tensor,
421
- "labels": labels_tensor,
422
- }
423
- ```
424
-
425
- with:
426
-
427
- ```text
428
- image_tensor : float32 [3, imgsz, imgsz], range [0, 1]
429
- boxes : float32 [N, 4], pixel-space xyxy coordinates
430
- labels : int64 [N], contiguous model-class indices
431
- ```
432
-
433
- An image with no retained objects receives:
434
-
435
- ```text
436
- boxes -> shape [0, 4]
437
- labels -> shape [0]
438
- ```
439
 
440
- The custom `collate_fn()` stacks image tensors into one batch while preserving targets as a Python list because the number of objects varies between images.
 
441
 
442
  ---
443
 
444
- ## 6. Deterministic Sampling, Epochs, and Resume Support
445
-
446
- Training uses a custom `EpochBatchSampler` instead of DataLoader's ordinary `batch_size + shuffle` path.
447
-
448
- For epoch \(e\), shuffled indices are generated from
449
 
450
- ```python
451
- torch.Generator().manual_seed(seed + epoch)
452
- ```
453
-
454
- so a given seed and epoch produce the same permutation.
455
-
456
- The sampler yields tuples of
457
 
458
  ```text
459
- (sample_seed, dataset_index)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  ```
461
 
462
- rather than only the dataset index. The dataset uses `sample_seed` to seed:
463
-
464
- - the local retry RNG;
465
- - the Albumentations transform for that specific sample.
466
-
467
- The per-sample seed is computed as
468
-
469
- \[
470
- \text{sample\_seed} =
471
- \text{seed} + e\cdot |\mathcal D| + i,
472
- \]
473
-
474
- where \(i\) is the sampled dataset index.
475
-
476
- `EpochBatchSampler.start_batch` allows iteration to begin from a later batch, which is useful for exact or near-exact mid-epoch resume when the training loop restores the corresponding sampler state.
477
-
478
- ---
479
-
480
- ## 7. Bad-Sample Recovery
481
-
482
- `ObjectDetectionDataset.__getitem__()` does not immediately terminate training when one sample cannot be loaded.
483
-
484
- For each requested sample, it can retry up to `max_load_retries` times.
485
-
486
- A failed sample can arise from conditions such as:
487
-
488
- - missing path-map entry;
489
- - unreadable or missing image file;
490
- - unexpected decoded image shape;
491
- - malformed metadata or annotations.
492
-
493
- When a load fails:
494
-
495
- 1. the exception is printed;
496
- 2. the error is optionally appended to a split-specific log file;
497
- 3. another dataset index is drawn from a deterministic local RNG;
498
- 4. loading is retried.
499
-
500
- If all attempts fail, the dataset raises a `RuntimeError`.
501
-
502
- > Because a failed sample is replaced by another index, a batch can contain a replacement image instead of the originally requested one. This keeps training alive but means silent replacement is part of the effective sampling distribution and should be monitored through the error log.
503
 
504
  ---
505
 
506
- ## 8. Memory and I/O Characteristics
507
-
508
- The implementation avoids loading the raw 2.6 GB annotation JSONL or the full image pixel dataset into memory, but it is **not constant-memory with respect to dataset size**.
509
-
510
- ### Structures held in RAM
511
-
512
- Depending on split and configuration, RAM includes at least:
513
-
514
- - `images_offset_index`: one dictionary entry per labeled image;
515
- - `ann_group_index`: one dictionary/list structure containing an offset for every indexed annotation;
516
- - `image_path_map`: one filename/path pair per physical image-map record;
517
- - `image_ids`: the final dataset index list, potentially expanded by oversampling;
518
- - `image_categories`: category sets constructed for every image during dataset initialization;
519
- - loaded pickle representations of the above cached indexes.
520
-
521
- The annotation-group index is especially significant because Python integers, lists, and dictionary entries introduce substantially more overhead than their raw binary values.
522
-
523
- ### Per-sample I/O
524
-
525
- For each sample, the current dataset implementation:
526
-
527
- - opens `images_info.jsonl`, seeks to one metadata offset, reads one line, then closes the file;
528
- - opens `annotations.jsonl`, seeks to each relevant annotation offset, reads the associated lines, then closes the file;
529
- - reads the image file with `cv2.imread()`.
530
-
531
- This design is worker-safe because file handles are local to each call/process, but repeated file opening introduces additional system-call overhead.
532
 
533
- ### Practical characterization
534
 
535
- The architecture is best summarized as:
536
 
537
- > **Disk-backed JSONL storage + cached in-memory random-access indexes + on-demand image/record reads.**
538
 
539
- Its primary benefit is avoiding full deserialization of the raw metadata files and avoiding image preloading, while still providing direct lookup by image ID.
540
 
541
- ---
542
-
543
- ## 9. Multi-Worker DataLoader Behavior
544
-
545
- The DataLoader supports standard PyTorch multiprocessing through `num_workers`.
546
-
547
- When workers are enabled:
548
 
549
- - `persistent_workers` can keep them alive across epochs;
550
- - `prefetch_factor` controls how many batches are prepared ahead of consumption;
551
- - `pin_memory` can accelerate host-to-device transfer when used appropriately;
552
- - dataset records are read through worker-local file opens rather than one shared mutable file pointer.
553
 
554
- The training loader delegates shuffling and batch formation to `EpochBatchSampler`. The validation loader uses ordinary deterministic ordering with `shuffle=False`.
555
 
556
- ---
557
 
558
- ## 10. Validation-Split Consistency Checks
559
 
560
- Before building the datasets, the loader:
561
 
562
- 1. loads and normalizes training categories;
563
- 2. checks that `cfg.nc` matches the number of normalized classes;
564
- 3. if validation metadata exists, loads validation categories;
565
- 4. requires the normalized train and validation class definitions to match exactly.
566
 
567
- If validation image metadata is absent, the loader skips construction of `val_loader` rather than failing the entire training setup.
568
 
569
- ---
570
 
571
- ## 11. List of 80 Object Classes
572
 
573
- | ID | Class Name | ID | Class Name | ID | Class Name | ID | Class Name |
574
- | :---: | :--- | :---: | :--- | :---: | :--- | :---: | :--- |
575
- | **0** | Person | **20** | Potted Plant | **40** | Umbrella | **60** | Bed |
576
- | **1** | Chair | **21** | Flower | **41** | Bicycle | **61** | Laptop |
577
- | **2** | Sneakers | **22** | Bench | **42** | Stool | **62** | Hockey Stick |
578
- | **3** | Desk | **23** | Pillow | **43** | Couch | **63** | Stuffed Toy |
579
- | **4** | Hat | **24** | SUV | **44** | Trash bin Can | **64** | Tent |
580
- | **5** | Car | **25** | Bowl/Basin | **45** | Drum | **65** | Awning |
581
- | **6** | Lamp | **26** | Leather Shoes | **46** | Van | **66** | Pickup Truck |
582
- | **7** | Street Lights | **27** | Necklace | **47** | Barrel/bucket | **67** | Paddle |
583
- | **8** | Cabinet/shelf | **28** | Microphone | **48** | Guitar | **68** | Sailboat |
584
- | **9** | Glasses | **29** | Boots | **49** | Bus | **69** | Mirror |
585
- | **10** | Bottle | **30** | Bracelet | **50** | Carpet | **70** | Camera |
586
- | **11** | Cup | **31** | Moniter/TV | **51** | Slippers | **71** | Horse |
587
- | **12** | Handbag/Satchel | **32** | Vase | **52** | Watch | **72** | Cell Phone |
588
- | **13** | Picture/Frame | **33** | Flag | **53** | Bakset | **73** | Wild Bird |
589
- | **14** | Other Shoes | **34** | Backpack | **54** | Motorcycle | **74** | Dog |
590
- | **15** | Helmet | **35** | Book | **55** | High Heels | **75** | Towel |
591
- | **16** | Plate | **36** | Speaker | **56** | Sandals | **76** | Tripod |
592
- | **17** | Storage box | **37** | Belt | **57** | Truck | **77** | Canned |
593
- | **18** | Gloves | **38** | Wine Glass | **58** | Traffic Light | **78** | Traffic cone |
594
- | **19** | Boat | **39** | Tie | **59** | Cymbal | **79** | Sink |
595
-
596
- > The names above preserve the dataset labels as documented in the source metadata, including existing spelling/capitalization such as `Moniter/TV` and `Bakset`.
597
 
598
  ---
599
 
600
- ## 12. Minimal Usage Example
601
 
602
- The normal entry point is `build_dataloaders()`:
603
 
604
- ```python
605
- from src.config import TrainConfig
606
- from train.dataloader import build_dataloaders
607
 
608
- cfg = TrainConfig()
609
- train_loader, val_loader, classes, num_classes = build_dataloaders(cfg)
610
-
611
- images, targets = next(iter(train_loader))
612
-
613
- print(images.shape) # [B, 3, imgsz, imgsz]
614
- print(len(targets)) # B
615
- print(targets[0]["boxes"]) # [N, 4], xyxy pixels
616
- print(targets[0]["labels"]) # [N]
617
- ```
618
-
619
- For training code that modifies epoch/resume state, access the custom sampler through:
620
-
621
- ```python
622
- sampler = train_loader.batch_sampler
623
- sampler.epoch = epoch
624
- sampler.start_batch = start_batch
625
  ```
626
 
627
- The training loop is responsible for resetting or updating these values consistently across epochs and checkpoint resume.
628
-
629
  ---
630
 
631
- ## 13. Source and License
 
 
 
 
632
 
633
- This repository is an **extended/filtered derivative of Objects365**: the original label space has been reduced and standardized to 80 target classes for the training setup documented here.
 
634
 
635
- The original Objects365 project states that its **annotations and website are licensed under CC BY 4.0**. The Objects365 Consortium does **not** own the copyright to the underlying images, and image use remains subject to the original image-source terms and the Objects365 dataset conditions. Accordingly, the `cc-by-4.0` metadata in this card refers to the annotation-derived content in this repository and must not be interpreted as relicensing third-party images.
 
636
 
637
- Original dataset: **Objects365: A Large-scale, High-quality Dataset for Object Detection**.
 
638
 
639
  ---
640
 
641
- ## 14. Operational Notes
642
 
643
- - Set `cfg.rebuild_index=True` whenever the source JSONL metadata changes and cached pickle indexes may be stale.
644
- - Monitor the bad-sample log instead of assuming all fallback retries are harmless.
645
- - Large Python index structures can consume substantial RAM even though the raw JSONL data remains on disk.
646
- - Class oversampling changes the effective number of training samples per epoch and therefore changes the number of optimizer steps unless the training schedule compensates for it.
647
- - `min_visibility=0.4` in Albumentations can remove boxes after geometric augmentation.
648
- - Validation data is not oversampled and is not augmented by `DetectionAugmenter`.
649
- - Images are normalized only to `[0, 1]` in this DataLoader; no mean/std normalization is applied here.
 
5
  size_categories:
6
  - 1M<n<10M
7
  source_datasets:
8
+ - Objects365
9
  annotations_creators:
10
  - found
11
  license: cc-by-4.0
 
22
  - 80-classes
23
  ---
24
 
25
+ # Objects365 80-Class Object Detection Subset
26
 
27
+ ## Dataset Description
28
 
29
+ This dataset is a filtered **80-class subset of Objects365** prepared for large-scale object-detection pretraining and training.
30
 
31
+ The original Objects365 dataset contains **365 object categories**, more than **600,000 training images**, and over **10 million manually annotated bounding boxes**. This derived version retains 80 target classes and reorganizes the corresponding metadata and annotations into JSON Lines (`.jsonl`) files for large-scale sequential and random-access processing.
32
+
33
+ The dataset card focuses on the **data itself**: provenance, statistics, directory organization, schemas, class definitions, annotation representation, and licensing.
34
+
35
+ The original Objects365 dataset should be cited whenever this derived subset is used in research.
36
 
37
  ---
38
 
39
+ ## Source Dataset
40
+
41
+ This dataset is derived from:
42
 
43
+ **Objects365: A Large-Scale, High-Quality Dataset for Object Detection**
44
 
45
+ - Authors: Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, Jian Sun
46
+ - Venue: IEEE/CVF International Conference on Computer Vision (ICCV), 2019
47
+ - Pages: 8430–8439
48
+ - Official project: https://www.objects365.org/
49
+ - Paper: https://openaccess.thecvf.com/content_ICCV_2019/html/Shao_Objects365_A_Large-Scale_High-Quality_Dataset_for_Object_Detection_ICCV_2019_paper.html
50
 
51
+ ### Citation
 
 
 
 
52
 
53
+ ```bibtex
54
+ @inproceedings{Shao_2019_ICCV,
55
+ author = {Shao, Shuai and Li, Zeming and Zhang, Tianyuan and Peng, Chao and Yu, Gang and Zhang, Xiangyu and Li, Jing and Sun, Jian},
56
+ title = {Objects365: A Large-Scale, High-Quality Dataset for Object Detection},
57
+ booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
58
+ month = {October},
59
+ year = {2019},
60
+ pages = {8430--8439}
61
+ }
62
+ ```
63
+
64
+ Please cite the original Objects365 paper rather than treating this 80-class reorganization as an independently collected image dataset.
65
 
66
  ---
67
 
68
+ ## Dataset Derivation
69
+
70
+ The dataset is an **extended/filtered derivative** of Objects365.
71
+
72
+ The transformation consists primarily of:
73
+
74
+ 1. selecting 80 target object categories from the original Objects365 label space;
75
+ 2. retaining image metadata associated with the selected categories;
76
+ 3. retaining and reorganizing corresponding bounding-box annotations;
77
+ 4. converting large metadata structures into JSONL files;
78
+ 5. creating explicit image-name-to-path mappings for locally stored image patches;
79
+ 6. optionally storing class-frequency / sampling metadata separately from the original annotations.
80
 
81
+ No claim is made that the underlying images were created or owned by the maintainers of this derived dataset.
82
+
83
+ ---
84
+
85
+ ## Directory Structure
86
 
87
  ```text
88
  labels/
89
  ├── README.md
90
  ├── train/
91
+ │ ├── annotations.jsonl
92
+ │ ├── categories.jsonl
93
+ │ ├── class_sampling.jsonl
94
+ │ ├── images_info.jsonl
95
+ │ └── images_train.jsonl
96
  └── val/
97
+ ├── annotations.jsonl
98
+ ├── categories.jsonl
99
+ ├── images_info.jsonl
100
+ └── images_val.jsonl
101
  ```
102
 
103
+ ### Dataset Statistics
104
 
105
+ | Split | File | Records | Approx. size | Purpose |
106
  | :--- | :--- | ---: | ---: | :--- |
107
+ | **train** | `annotations.jsonl` | 15,538,897 | 2.64 GB | Bounding boxes and annotation attributes |
108
+ | | `categories.jsonl` | 80 | 2.4 KB | Definition of the retained object classes |
109
+ | | `class_sampling.jsonl` | 80 | 2.5 KB | Per-class sampling metadata |
110
+ | | `images_info.jsonl` | 1,652,206 | 177.93 MB | Image IDs, dimensions, names, licenses, and URLs |
111
+ | | `images_train.jsonl` | 1,742,289 | 150.87 MB | Image-name to physical-path mappings |
112
  | **val** | `annotations.jsonl` | 442,988 | 75.53 MB | Validation bounding boxes and labels |
113
+ | | `categories.jsonl` | 80 | 2.4 KB | Validation class definitions |
114
+ | | `images_info.jsonl` | 67,749 | 7.30 MB | Validation image metadata |
115
+ | | `images_val.jsonl` | 80,000 | 6.93 MB | Validation image-path mappings |
116
 
117
+ `images_train.jsonl` may contain more physical image records than `images_info.jsonl` because not every downloaded image contains one of the retained 80 categories after filtering.
 
 
 
 
118
 
119
  ---
120
 
121
+ ## Data Organization
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
+ Metadata is stored primarily in **JSON Lines (`.jsonl`)** format.
124
 
125
+ Each non-empty line contains one independent JSON object.
126
 
127
+ This representation is useful for very large annotation collections because individual records can be scanned, filtered, sharded, or indexed without deserializing one monolithic JSON object.
128
 
129
+ The principal relations are:
130
 
131
+ ```text
132
+ categories.jsonl
133
+ │
134
+ └── id
135
+ │
136
+ ▼
137
+ annotations.jsonl
138
+ │
139
+ ├── category_id
140
+ └── image_id
141
+ │
142
+ ▼
143
+ images_info.jsonl
144
+ │
145
+ └── file_name
146
+ │
147
+ ▼
148
+ images_train.jsonl / images_val.jsonl
149
+ ```
150
 
151
+ ---
152
 
153
+ ## Data Schemas
154
+
155
+ ### `categories.jsonl`
156
+
157
+ Defines the retained **80-class object vocabulary**.
158
+
159
+ Fields:
160
 
161
  - `id` (`int`): raw category identifier.
162
+ - `name` (`str`): category name.
163
 
164
+ Example:
165
 
166
  ```json
167
  {"name": "Person", "id": 0}
 
168
  {"name": "Chair", "id": 1}
169
+ {"name": "Sneakers", "id": 2}
170
  ```
171
 
 
 
172
  ---
173
 
174
+ ### `images_info.jsonl`
175
 
176
+ Stores metadata for labeled images.
177
 
178
+ Fields:
179
 
180
  - `id` (`int`): unique image identifier.
181
  - `file_name` (`str`): original image filename.
182
+ - `width` (`int`): original image width.
183
+ - `height` (`int`): original image height.
184
+ - `license` (`int`): license identifier inherited from the source metadata.
185
+ - `url` (`str`): source URL when available.
186
 
187
+ Example:
188
 
189
  ```json
190
  {"height": 512, "id": 420917, "license": 5, "width": 769, "file_name": "objects365_v1_00420917.jpg", "url": ""}
 
 
 
 
 
 
 
191
  ```
192
 
193
+ The `license` field is source metadata and should not be interpreted, by itself, as granting new rights over the underlying image.
194
 
195
  ---
196
 
197
+ ### `images_train.jsonl` and `images_val.jsonl`
198
 
199
+ These files map image filenames to their relative physical storage paths.
200
 
201
+ Fields:
202
 
203
+ - `image_name` (`str`): image filename.
204
+ - `path` (`str`): relative path to the image file.
205
 
206
+ Example:
 
 
 
207
 
208
  ```json
209
  {"image_name": "objects365_v2_00953995.jpg", "path": "patch17/objects365_v2_00953995.jpg"}
 
210
  ```
211
 
212
+ These path files are storage metadata for this dataset organization and are not original Objects365 annotations.
213
 
214
  ---
215
 
216
+ ### `annotations.jsonl`
217
 
218
+ Stores object-detection annotations.
219
 
220
+ Fields:
221
 
222
+ - `id` (`int`): annotation identifier.
223
+ - `image_id` (`int`): associated image identifier.
224
+ - `category_id` (`int`): associated object category.
225
+ - `bbox` (`list[float]`): COCO-style bounding box `[x_min, y_min, width, height]`.
226
  - `area` (`float`): bounding-box area.
227
  - `iscrowd` (`int`): crowd-region flag.
228
  - `isfake` (`int`): synthetic/drawn-object flag.
229
+ - `isreflected` (`int`): reflection-related metadata.
230
+ - `flag_reflected` (`int`): auxiliary reflection-related metadata.
231
 
232
+ Example:
233
 
234
  ```json
235
  {"id": 26899493, "iscrowd": 0, "isfake": 0, "area": 3764.58, "isreflected": 0, "bbox": [20.3, 260.25, 82.69, 45.52], "image_id": 0, "category_id": 0, "flag_reflected": 0}
236
  ```
237
 
 
 
 
 
 
 
 
 
238
  ---
239
 
240
+ ### `class_sampling.jsonl`
241
 
242
+ Contains auxiliary per-class sampling metadata for the training split.
243
 
244
+ Fields:
245
 
246
+ - `id` (`int`): category identifier.
247
+ - `probability` (`int` or `float`): stored sampling percentage / repeat metadata.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
+ Example:
 
 
250
 
251
  ```json
252
  {"id": 0, "probability": 100}
 
254
  {"id": 78, "probability": 202}
255
  ```
256
 
257
+ This file is not part of the original Objects365 annotation format; it is derived metadata associated with this 80-class subset.
258
 
259
  ---
260
 
261
+ ## 11. List of 80 Object Classes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
263
+ | ID | Class Name | ID | Class Name | ID | Class Name | ID | Class Name |
264
+ | :
265
 
266
  ---
267
 
268
+ ## Provenance
 
 
 
 
269
 
270
+ The data lineage is:
 
 
 
 
 
 
271
 
272
  ```text
273
+ Objects365
274
+ │
275
+ ├── original images
276
+ ├── image metadata
277
+ ├── 365-category label space
278
+ └── bounding-box annotations
279
+ │
280
+ ▼
281
+ 80-class selection
282
+ │
283
+ ▼
284
+ metadata / annotation filtering
285
+ │
286
+ ▼
287
+ JSONL reorganization
288
+ │
289
+ ▼
290
+ Objects365 80-Class Object Detection Subset
291
  ```
292
 
293
+ The derived dataset changes the organization and retained label space but does not alter the provenance of the original images.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
  ---
296
 
297
+ ## License and Copyright
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
 
299
+ ### Objects365 annotations and website
300
 
301
+ The official Objects365 project states that its **annotations and website are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0)**.
302
 
303
+ Accordingly, annotation-derived metadata in this repository should retain attribution to Objects365.
304
 
305
+ CC BY 4.0:
306
 
307
+ https://creativecommons.org/licenses/by/4.0/
 
 
 
 
 
 
308
 
309
+ ### Underlying images
 
 
 
310
 
311
+ The **CC BY 4.0 license does not automatically apply to the underlying images**.
312
 
313
+ The Objects365 Consortium explicitly states that it does **not own the copyright to the images**. Image use remains subject to the terms and copyright conditions of the original image sources and the Objects365 dataset conditions.
314
 
315
+ The official Objects365 download page further states that users must accept responsibility for their use of copyrighted images and places restrictions on redistribution of those images.
316
 
317
+ Therefore:
318
 
319
+ - `license: cc-by-4.0` in this dataset card should be interpreted as applying to the Objects365 annotation-derived content and associated metadata where applicable;
320
+ - it must **not** be interpreted as relicensing third-party images under CC BY 4.0;
321
+ - redistribution of the underlying image files should be evaluated separately against the Objects365 terms and the rights of the original image owners.
 
322
 
323
+ Official Objects365 license / download page:
324
 
325
+ https://www.objects365.org/download.html
326
 
327
+ ### Derived metadata
328
 
329
+ Files generated specifically for this reorganization, such as image-path mappings or class-selection metadata, may be distributed separately by the maintainers, but they do not change the legal status of the underlying Objects365 images or annotations.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
 
331
  ---
332
 
333
+ ## Attribution
334
 
335
+ When using this dataset, please acknowledge that it is derived from Objects365 and cite the original paper:
336
 
337
+ > Shuai Shao, Zeming Li, Tianyuan Zhang, Chao Peng, Gang Yu, Xiangyu Zhang, Jing Li, and Jian Sun.
338
+ > **Objects365: A Large-Scale, High-Quality Dataset for Object Detection.**
339
+ > Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2019, pp. 8430–8439.
340
 
341
+ ```bibtex
342
+ @inproceedings{Shao_2019_ICCV,
343
+ author = {Shao, Shuai and Li, Zeming and Zhang, Tianyuan and Peng, Chao and Yu, Gang and Zhang, Xiangyu and Li, Jing and Sun, Jian},
344
+ title = {Objects365: A Large-Scale, High-Quality Dataset for Object Detection},
345
+ booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
346
+ month = {October},
347
+ year = {2019},
348
+ pages = {8430--8439}
349
+ }
 
 
 
 
 
 
 
 
350
  ```
351
 
 
 
352
  ---
353
 
354
+ ## References
355
+
356
+ 1. **Shao, S., Li, Z., Zhang, T., Peng, C., Yu, G., Zhang, X., Li, J., Sun, J.**
357
+ *Objects365: A Large-Scale, High-Quality Dataset for Object Detection.* ICCV 2019.
358
+ https://openaccess.thecvf.com/content_ICCV_2019/html/Shao_Objects365_A_Large-Scale_High-Quality_Dataset_for_Object_Detection_ICCV_2019_paper.html
359
 
360
+ 2. **Objects365 Official Project**
361
+ https://www.objects365.org/
362
 
363
+ 3. **Objects365 Download and License Terms**
364
+ https://www.objects365.org/download.html
365
 
366
+ 4. **Creative Commons Attribution 4.0 International**
367
+ https://creativecommons.org/licenses/by/4.0/
368
 
369
  ---
370
 
371
+ ## Notes
372
 
373
+ - This is a **filtered 80-class derivative**, not the complete 365-class Objects365 dataset.
374
+ - The original Objects365 paper and project remain the authoritative sources for the parent dataset.
375
+ - Annotation provenance should be preserved when redistributing derived label files.
376
+ - Image copyright is distinct from annotation licensing.
377
+ - The presence of an image in Objects365 does not imply that the image itself is licensed under CC BY 4.0.