Skip to content

Commit 414867d

Browse files
committed
[DOC] Improved README
1 parent 91533fa commit 414867d

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

README.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,31 @@ The library has three main components:
2929
The `AnnotationSet` class contains static methods to read different dataset formats:
3030

3131
```python
32+
import globox as gx
33+
34+
3235
# COCO
33-
coco = AnnotationSet.from_coco(file_path="path/to/file.json")
36+
coco = gx.AnnotationSet.from_coco(file_path="path/to/file.json")
3437

3538
# YOLOv5
36-
yolo = AnnotationSet.from_yolo_v5(
39+
yolo = gx.AnnotationSet.from_yolo_v5(
3740
folder="path/to/files/",
38-
image_folder="path/to/images/"
41+
image_folder="path/to/images/",
3942
)
4043

4144
# Pascal VOC
42-
pascal = AnnotationSet.from_pascal_voc(folder="path/to/files/")
45+
pascal = gx.AnnotationSet.from_pascal_voc(folder="path/to/files/")
4346
```
4447

4548
`Annotation` offers file-level granularity for compatible datasets:
4649

4750
```python
48-
annotation = Annotation.from_labelme(file_path="path/to/file.xml")
51+
annotation = gx.Annotation.from_labelme(file_path="path/to/file.xml")
4952
```
5053

5154
For more specific implementations the `BoundingBox` class contains lots of utilities to parse bounding boxes in different formats, like the `create()` method.
5255

53-
`AnnotationsSets` are set-like objects. They can be combined and annotations can be added:
56+
`AnnotationsSet`s are set-like objects. They can be combined and annotations can be added:
5457

5558
```python
5659
gts = coco | yolo
@@ -112,6 +115,24 @@ coco_gts.show_stats()
112115
└─────────────┴────────┴───────┘
113116
```
114117

118+
### Edit and Filter Datasets
119+
120+
AnnotationSets can be filtered and mapped:
121+
122+
```python
123+
# Keep annotations that are not empty.
124+
annotations = annotations.filter(lambda a: len(a.boxes) > 0)
125+
126+
# Only keep training annotations.
127+
annotations = annotations.filter(lambda a: a.image_id in train_ids)
128+
129+
# Replace "/" with "_" in all image ids.
130+
annotations = annotations.map(lambda a: a.with_image_id(a.image_id.replace("/", "_")))
131+
132+
# Treat all animals as one class using a convenience method to map labels (in-place update).
133+
annotations.map_labels({"cat": "animal", "dog": "animal"})
134+
```
135+
115136
### Convert and Save to Many Formats
116137

117138
Datasets can be converted to and saved in other formats:
@@ -123,7 +144,7 @@ gts.save_imagenet(save_dir="pascalVOC_db/")
123144
# YOLO Darknet
124145
gts.save_yolo_darknet(
125146
save_dir="yolo_train/",
126-
label_to_id={"cat": 0, "dog": 1, "racoon": 2}
147+
label_to_id={"cat": 0, "dog": 1, "racoon": 2},
127148
)
128149

129150
# YOLOv5
@@ -141,9 +162,9 @@ gts.save_cvat(path="train.xml")
141162
COCO Evaluation is also supported:
142163

143164
```python
144-
evaluator = COCOEvaluator(
165+
evaluator = gx.COCOEvaluator(
145166
ground_truths=gts,
146-
predictions=dets
167+
predictions=dets,
147168
)
148169

149170
ap = evaluator.ap()
@@ -190,7 +211,7 @@ Custom evaluations can be achieved with:
190211
evaluation = evaluator.evaluate(
191212
iou_threshold=0.33,
192213
max_detections=1_000,
193-
size_range=(0.0, 10_000)
214+
size_range=(0.0, 10_000),
194215
)
195216

196217
ap = evaluation.ap()
@@ -278,24 +299,6 @@ Saving |0.32s|0.17s|0.14s |1.06s |1.08s |0.91s|0.85s
278299

279300
</details>
280301

281-
## Todo
282-
283-
* [x] Basic data structures and utilities
284-
* [x] Parsers (ImageNet, COCO, YOLO, Pascal, OpenImage, CVAT, LabelMe)
285-
* [x] Parser tests
286-
* [x] Database summary and stats
287-
* [x] Database converters
288-
* [x] Visualization options
289-
* [x] COCO Evaluation
290-
* [x] Tests with a huge load (5k images)
291-
* [x] CLI interface
292-
* [x] Make `image_size` optional and raise err when required (bbox conversion)
293-
* [x] Make file saving atomic with a temporary to avoid file corruption
294-
* [x] Pip package!
295-
* [ ] PascalVOC Evaluation
296-
* [ ] Parsers for TFRecord and TensorFlow
297-
* [ ] UI interface?
298-
299302
## Acknowledgement
300303

301304
This repo is based on the work of [Rafael Padilla](https://github.com/rafaelpadilla/review_object_detection_metrics).

0 commit comments

Comments
 (0)